You are here

function protected_pages_edit_validate in Protected Pages 7

Same name and namespace in other branches
  1. 7.2 protected_pages.admin.inc \protected_pages_edit_validate()

Implements hook_validate().

File

./protected_pages.admin.inc, line 201
Provides page callbacks for configuration page.

Code

function protected_pages_edit_validate($form, &$form_state) {
  $form_state['values']['path'] = drupal_get_normal_path($form_state['values']['path']);
  if (!drupal_valid_path($form_state['values']['path'])) {
    form_set_error('path', t('Please enter a correct path!'));
  }
  $pid = db_select('protected_pages')
    ->fields('protected_pages', array(
    'pid',
  ))
    ->condition('path', $form_state['values']['path'])
    ->condition('pid', $form_state['values']['pid'], '<>')
    ->range(0, 1)
    ->execute()
    ->fetchField();
  if ($pid) {
    form_set_error('path', t('Duplicate path entry is not allowed. There is already a path or its alias exists.'));
  }
}