You are here

function homebox_admin_page_submit in Homebox 6.3

Same name and namespace in other branches
  1. 6 homebox.admin.inc \homebox_admin_page_submit()
  2. 6.2 homebox.admin.inc \homebox_admin_page_submit()
  3. 7.3 homebox.admin.inc \homebox_admin_page_submit()
  4. 7.2 homebox.admin.inc \homebox_admin_page_submit()
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 237
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/build/homebox/delete/' . $form_state['values']['name'];
    return;
  }
  else {
    if ($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 ($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.'));
    }
    else {
      if ($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/build/homebox';
  menu_rebuild();
  return;
}