function redirect_validate in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.module \redirect_validate()
Validate a redirect.
1 call to redirect_validate()
- redirect_edit_form_validate in ./
redirect.admin.inc - Form validate handler; validate an URL redirect.
1 string reference to 'redirect_validate'
- redirect_hook_info in ./
redirect.module - Implements hook_hook_info().
File
- ./
redirect.module, line 753
Code
function redirect_validate($redirect, $form, &$form_state) {
$redirect = (object) $redirect;
// check that there there are no redirect loops
if (url($redirect->source) == url($redirect->redirect)) {
form_set_error('redirect', t('You are attempting to redirect the page to itself. This will result in an infinite loop.'));
}
redirect_hash($redirect);
if ($existing = redirect_load_by_hash($redirect->hash)) {
if ($redirect->rid != $existing->rid) {
form_set_error('source', t('A redirect already exists for the source path %source. Do you want to <a href="@edit-page">edit the existing redirect</a>?', array(
'%source' => redirect_url($redirect->source, $redirect->source_options),
'@edit-page' => url('admin/config/search/redirect/edit/' . $existing->rid),
)));
}
}
// Allow other modules to validate the redirect.
foreach (module_implements('redirect_validate') as $module) {
$function = $module . '_redirect_validate';
$function($redirect, $form, $form_state);
}
}