You are here

function autoassignrole_page_form_submit in Auto Assign Role 7.2

Same name and namespace in other branches
  1. 7 autoassignrole.admin.inc \autoassignrole_page_form_submit()

Implements hook_form_submit().

File

./autoassignrole.admin.inc, line 331
Administrative functionality for auto assign role.

Code

function autoassignrole_page_form_submit($form_id, &$form_state) {
  $values =& $form_state['values'];
  $is_new = $values['is_new'];
  $page = (object) array(
    'name' => $values['name'],
    'roles' => array_keys(array_filter($values['roles'])),
    'path' => $values['path'],
    'menu' => $values['menu'],
    'title' => $values['title'],
    'display' => $values['display'],
    'export_type' => $values['export_type'],
  );
  ctools_include('export');
  $return = ctools_export_crud_save('autoassignrole_page', $page);
  if ($return !== FALSE) {
    menu_rebuild();
    if ($is_new) {
      drupal_set_message(t('Successfully created page @page.', array(
        '@page' => $page->title,
      )));
    }
    else {
      drupal_set_message(t('Successfully updated page @page.', array(
        '@page' => $page->title,
      )));
    }
    drupal_goto('admin/config/people/autoassignrole/pages');
  }
  else {
    drupal_set_message(t('Error when trying to save page.'), 'error');
  }
}