function unpublished_nodes_redirect_admin_settings_form_validate in Unpublished Nodes Redirect 7
Validate the admin settings form.
File
- ./
unpublished_nodes_redirect.admin.inc, line 57 - Admin page callbacks for the Unpublished Nodes Redirect module.
Code
function unpublished_nodes_redirect_admin_settings_form_validate($form, &$form_state) {
foreach (_unpublished_nodes_redirect_get_node_types() as $key => $type) {
// Validate whether the provided redirect paths are all internal.
$element_name = $key . '_unpublished_redirect_path';
$submitted_redirect_path = $form_state['values'][$element_name];
if (!empty($submitted_redirect_path) && url_is_external($submitted_redirect_path)) {
form_set_error($element_name, t('The path provided needs to be an internal path.'));
}
// If a path is provided, make sure a response code is selected.
$element_name = $key . '_unpublished_redirect_response_code';
$submitted_response_code = $form_state['values'][$element_name];
if (!empty($submitted_redirect_path) && $submitted_response_code == 0) {
form_set_error($element_name, t('Please select a response code for the @type content type.', array(
'@type' => $type->name,
)));
}
}
}