You are here

function homebox_admin_page_validate in Homebox 7.3

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. 6.2 homebox.admin.inc \homebox_admin_page_validate()
  4. 7.2 homebox.admin.inc \homebox_admin_page_validate()

Validation functino for the admin page form.

2 string references to 'homebox_admin_page_validate'
homebox_admin_page in ./homebox.admin.inc
@file Homebox admin file, takes care admin interface for homebox
homebox_clone_page in ./homebox.admin.inc
Form callback for cloning a 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 (!isset($form_state['values']['import']) || $form_state['values']['import'] == NULL) {

    // Validate title.
    $test = strip_tags($form_state['values']['title']);
    if ($test != $form_state['values']['title']) {
      form_set_error('title', t('Limit the title to non HTML characters.'));
    }

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

    // Check if the path exists
    if (empty($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 (empty($form_state['values']['name']) && isset($form_state['values']['op']) && $form_state['values']['op'] == t('Add page')) {
      homebox_check_name($form_state['values']['name'], 'name');
    }
  }
  else {
    return homebox_check_page_object($form_state['values']['import']);
  }
}