function profile2_regpath_validate_settings in Profile2 Registration Path 7.2
Same name and namespace in other branches
- 7 profile2_regpath.admin.inc \profile2_regpath_validate_settings()
Validate profile settings form values.
1 string reference to 'profile2_regpath_validate_settings'
- _profile2_regpath_form_profile2_type_form_alter in ./
profile2_regpath.admin.inc - Implements hook_form_FORM_ID_alter() for the registration form.
File
- ./
profile2_regpath.admin.inc, line 186 - Modifications to administrative forms.
Code
function profile2_regpath_validate_settings($form, &$form_state) {
if ($form_state['values']['status'] == 1) {
$values = $form_state['values'];
// Validate URL tail via regex. This also tests that path is not null.
if ($values['path_type'] == 'separate' && profile2_regpath_url_validator(trim($values['path'])) == FALSE) {
form_set_error('path', 'Error, you did not enter a valid URL.');
}
// Ensure that URL does not contain a '/'.
// @todo move this to profile2_regpath_url_validator.
if (strpos($values['path'], '/')) {
form_set_error('path', 'Error, you cannot use a "/" in your unique path. You may specify only a single segment of the URL.');
}
// Check to see if another module is using the selected path.
// We must make exceptions for '/user' and other p2rp registered paths.
if ($values['path'] != 'user' && ($existing_item = menu_get_item($values['path']))) {
if ($existing_item['page_callback'] != '_profile2_regpath_user_login') {
form_set_error('path', 'Error, that base path is already being used by another module.');
}
}
// Check to see if selected path is being used by an alias.
if ($existing_alias = drupal_lookup_path('source', $values['path'])) {
form_set_error('path', t('Error, that base path is already being used as an alias. Please select a different base path or remove the alias.'));
}
}
}