You are here

function homebox_admin_page_submit in Homebox 7.2

Same name and namespace in other branches
  1. 6.3 homebox.admin.inc \homebox_admin_page_submit()
  2. 6 homebox.admin.inc \homebox_admin_page_submit()
  3. 6.2 homebox.admin.inc \homebox_admin_page_submit()
  4. 7.3 homebox.admin.inc \homebox_admin_page_submit()

Submit function for the admin page form.

1 string reference to 'homebox_admin_page_submit'
homebox_admin_page in ./homebox.admin.inc
@file Homebox admin file, takes care admin interface for homebox

File

./homebox.admin.inc, line 231
Homebox admin file, takes care admin interface for homebox

Code

function homebox_admin_page_submit($form, &$form_state) {
  $op = $form_state['values']['op'];
  if ($op == t('Delete page') || $op == t('Revert page')) {

    // Redirect to the confirmation message
    // Reverting and deleting is the same operation
    $form_state['redirect'] = 'admin/structure/homebox/delete/' . $form_state['values']['name'];
    return;
  }
  elseif ($op == t('Add page')) {

    // Build page object
    $page = new stdClass();
    $page->name = $form_state['values']['name'];

    // Check to see if imported homebox object is present
    if (!empty($form_state['values']['import'])) {
      $page->settings = $form_state['values']['import']->settings;
    }
    else {

      // Build default settings
      $page->settings = array(
        'regions' => HOMEBOX_DEFAULT_REGIONS,
        'cache' => 0,
        'color' => 0,
        'colors' => array(),
        'blocks' => array(),
        'widths' => array(),
      );

      // Map form settings to page object
      homebox_admin_form_to_page($page, $form_state);
    }

    // Save page
    homebox_save_page($page);
    drupal_set_message(t('The page has been added.'));
  }
  elseif ($op == t('Save page')) {

    // Fetch old page to amend
    $page = homebox_get_page($form_state['values']['name']);

    // Map form settings to page object
    homebox_admin_form_to_page($page, $form_state);

    // Save settings
    homebox_save_page($page);
    drupal_set_message(t('Changes have been saved'));
  }
  $form_state['redirect'] = 'admin/structure/homebox';
  menu_rebuild();
  return;
}