function me_admin_settings_form_validate in me aliases 8
Same name and namespace in other branches
- 6.2 me.module \me_admin_settings_form_validate()
- 6 me.module \me_admin_settings_form_validate()
- 7 me.module \me_admin_settings_form_validate()
Validation callback for me_admin_settings_form.
1 string reference to 'me_admin_settings_form_validate'
- me_admin_settings_form in ./
me.module - Form callback for the admin settings form.
File
- ./
me.module, line 653 - Provides 'me' aliases to allow users to enter 'me' in common paths instead of their user id.
Code
function me_admin_settings_form_validate($form, &$form_state) {
// If the token module is installed, we need to also allow a list of tokens
// that are allowed to match against. We include all global tokens here, even though
// some of them don't really make sense, but that is up to the end user.
$token_list = array();
//$token_list = array_map(create_function('$n', 'return "[$n]";'), array_keys(array_pop(token_info())));
$tk_types = token_get_global_token_types();
$options = array(
'flat' => TRUE,
'restricted' => FALSE,
'depth' => 4,
);
foreach ($tk_types as $type) {
$tree = token_build_tree($type, $options);
$token_list = array_merge($token_list, array_keys($tree));
}
if (preg_match('/[^a-zA-Z\\:]/', $form_state['values']['me_alias']) && !in_array($form_state['values']['me_alias'], $token_list)) {
if (!empty($token_list)) {
$message = t('The alias can only contain characters from a-z and A-Z, or one of the tokens specified in the "Replacement patterns for me alias" section.');
}
else {
$message = t('The alias can only contain characters from a-z and A-Z.');
}
form_set_error('me_alias', $message);
}
}