function domain_alias_form_validate in Domain Access 6.2
Same name and namespace in other branches
- 7.3 domain_alias/domain_alias.admin.inc \domain_alias_form_validate()
- 7.2 domain_alias/domain_alias.admin.inc \domain_alias_form_validate()
FAPI for domain_alias_form()
File
- domain_alias/
domain_alias.admin.inc, line 107 - Administration functions for the domain_alias module.
Code
function domain_alias_form_validate($form, &$form_state) {
// Validate aliases
$aliases = array();
// Validate updates -- this array might not have data.
if (isset($form_state['values']['domain_alias'])) {
foreach ($form_state['values']['domain_alias'] as $count => $alias) {
$validate = TRUE;
// Delete requests and unchanged aliases do not need the validation step.
$original_alias = domain_alias_lookup(NULL, $count);
if ($original_alias['pattern'] == $alias['pattern']) {
// In this case, no change and no error set, unless no changes made.
$validate = FALSE;
}
if ($original_alias['redirect'] != $alias['redirect']) {
// In this case, we updated the redirect settings only.
$validate = FALSE;
$aliases[] = 'update placeholder';
}
if ($form_state['values']['domain_alias'][$count]['delete']) {
// Set a value so we do not return an error on empty array.
$aliases[] = 'delete placeholder';
$validate = FALSE;
}
if ($validate) {
// Run the validation routine.
$aliases[] = _domain_alias_validate($form, $alias, $count, $aliases, 'domain_alias');
}
}
}
// Validate new domain aliases -- this array should always have data.
foreach ($form_state['values']['domain_alias_new'] as $count => $alias) {
if (empty($alias['pattern'])) {
continue;
}
$aliases[] = _domain_alias_validate($form, $alias, $count, $aliases, 'domain_alias_new');
}
if (empty($aliases)) {
form_error($form['domain'], t('No changes were made.'));
}
}