You are here

function homebox_admin_page_validate in Homebox 6.2

Same name and namespace in other branches
  1. 6.3 homebox.admin.inc \homebox_admin_page_validate()
  2. 6 homebox.admin.inc \homebox_admin_page_validate()
  3. 7.3 homebox.admin.inc \homebox_admin_page_validate()
  4. 7.2 homebox.admin.inc \homebox_admin_page_validate()
1 string reference to 'homebox_admin_page_validate'
homebox_admin_page in ./homebox.admin.inc
@file Homebox admin file, takes care admin interface for homebox

File

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

Code

function homebox_admin_page_validate($form, &$form_state) {

  // No valifation needed on Delete or Revert
  if ($form_state['values']['op'] == t('Delete page') || $form_state['values']['op'] == t('Revert page')) {
    return;
  }

  // If no imported settings...
  if (!$form_state['values']['import']) {

    // Filter title
    $form_state['values']['title'] = filter_xss($form_state['values']['title']);

    // Make sure a title is present
    if (!$form_state['values']['title']) {
      form_set_error('title', t('You must enter a page title.'));
    }

    // Check if the path exists
    if (!$form_state['values']['path']) {
      form_set_error('path', t('You must enter a path.'));
    }
    else {
      homebox_check_path($form_state['values']['path'], $form_state['values']['name'], 'path');
    }

    // Check machine name
    if ($form_state['values']['name'] && $form_state['values']['op'] == t('Add page')) {
      homebox_check_name($form_state['values']['name'], 'name');
    }
  }
  else {

    /*
     * The following checks the import data object and validates
     * all of the components as done above
     */

    // Add object back to the form
    $form_state['values']['import'] = homebox_check_page_object($form_state['values']['import'], $form_state['values']['name'], 'import');
  }
}