function fe_nodequeue_machine_name_validate in Features Extra 6
Validate machine name.
1 string reference to 'fe_nodequeue_machine_name_validate'
- fe_nodequeue_form_alter in ./
fe_nodequeue.module - Implementation of hook_form_alter().
File
- ./
fe_nodequeue.module, line 231
Code
function fe_nodequeue_machine_name_validate($form, &$form_state) {
if (empty($form_state['values']['machine_name'])) {
return;
}
$table = 'fe_nodequeue_queue';
if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['machine_name'])) {
form_set_error('machine_name', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
elseif (db_result(db_query("SELECT COUNT(*) FROM {{$table}} WHERE qid <> %d AND machine_name = '%s'", $form_state['values']['qid'], $form_state['values']['machine_name']))) {
form_set_error('machine_name', t('The machine-readable name has been taken. Please pick another one.'));
}
}