You are here

function homebox_admin_page_validate in Homebox 6

Same name and namespace in other branches
  1. 6.3 homebox.admin.inc \homebox_admin_page_validate()
  2. 6.2 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 Home box admin file, takes care admin interface for homebox

File

./homebox.admin.inc, line 115
Home box admin file, takes care admin interface for homebox

Code

function homebox_admin_page_validate($form, &$form_state) {
  if ($form_state['values']['name']) {
    if ($form_state['values']['op'] == t('Save page')) {
      if (db_result(db_query("SELECT COUNT(*) FROM {homebox_pages} WHERE name = '%s' AND pid <> %d", $form_state['values']['name'], $form_state['values']['pid']))) {
        form_set_error('name', t('The page name %name already exists. Please choose another page name.', array(
          '%name' => $form_state['values']['name'],
        )));
      }
    }
    else {
      if ($form_state['values']['op'] == t('Add page')) {
        if (db_result(db_query("SELECT COUNT(*) FROM {homebox_pages} WHERE name = '%s'", $form_state['values']['name']))) {
          form_set_error('name', t('The page name %name already exists. Please choose another page name.', array(
            '%name' => $form_state['values']['name'],
          )));
        }
      }
    }
  }
  else {
    form_set_error('name', t('You must specify a valid page name.'));
  }
}