function protected_pages_configure_validate in Protected Pages 7.2
Same name and namespace in other branches
- 7 protected_pages.admin.inc \protected_pages_configure_validate()
Implements hook_validate().
File
- ./
protected_pages.admin.inc, line 118 - Provides page callbacks for configuration page.
Code
function protected_pages_configure_validate($form, &$form_state) {
$form_state['normal_path'] = drupal_get_normal_path($form_state['values']['path']);
$path_alias = drupal_strtolower(drupal_get_path_alias($form_state['values']['path']));
if (!drupal_valid_path($form_state['normal_path'])) {
form_set_error('path', t('Please enter a correct path!'));
}
$pid = db_select('protected_pages')
->fields('protected_pages', array(
'pid',
))
->condition(db_or()
->condition('path', $form_state['normal_path'])
->condition('path', $path_alias))
->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.'));
}
}