function shorten_cs_edit_validate in Shorten URLs 7
Same name and namespace in other branches
- 8.2 modules/shorten_cs/shorten_cs.admin.inc \shorten_cs_edit_validate()
- 8 modules/shorten_cs/shorten_cs.admin.inc \shorten_cs_edit_validate()
- 6 shorten_cs.admin.inc \shorten_cs_edit_validate()
- 7.2 shorten_cs.admin.inc \shorten_cs_edit_validate()
Validates the form to edit a custom service.
File
- ./
shorten_cs.admin.inc, line 157 - Provides the configuration page for Shorten URLs Custom Services.
Code
function shorten_cs_edit_validate($form, $form_state) {
$v = $form_state['values'];
if (($v['type'] == 'xml' || $v['type'] == 'json') && empty($v['tag'])) {
form_set_error('type', t('An XML tag or JSON key is required for services with a response type of XML or JSON.'));
}
$exists = db_query("SELECT COUNT(sid) FROM {shorten_cs} WHERE name = :name AND sid <> :sid", array(
':name' => $v['name'],
':sid' => $v['sid'],
))
->fetchField();
if ($exists > 0) {
form_set_error('name', t('A service with that name already exists.'));
}
else {
$all_services = module_invoke_all('shorten_service');
$all_services['none'] = t('None');
foreach ($all_services as $key => $value) {
if ($key == $v['name']) {
form_set_error('name', t('A service with that name already exists.'));
break;
}
}
}
}