$role) {
$options[$rid] = check_plain($role);
}
$form['validate_argument_role'] = array(
'#type' => 'checkboxes',
'#prefix' => '
',
'#suffix' => '
',
'#title' => t('Roles'),
'#options' => $options,
'#default_value' => isset($this->argument->options['validate_argument_role']) ? $this->argument->options['validate_argument_role'] : array(),
'#description' => t('If you wish to validate for specific roles, check them; if none are checked, all titles will pass.'),
);
$form['validate_argument_transform'] = array(
'#type' => 'checkbox',
'#title' => t('Transform dashes in URL to spaces in title arguments'),
'#default_value' => isset($this->argument->options['validate_argument_transform']) ? $this->argument->options['validate_argument_transform'] : FALSE,
);
}
function validate_argument($argument) {
$rids = isset($this->argument->options['validate_argument_role']) ? array_filter($this->argument->options['validate_argument_role']) : array();
$transform = isset($this->argument->options['validate_argument_transform']) ? $this->argument->options['validate_argument_transform'] : FALSE;
$and = '';
if (!empty($rids)) {
$and = " AND rid IN(" . implode(', ', $rids) . ')';
}
if ($transform) {
$result = db_fetch_object(db_query("SELECT * FROM {user_titles} WHERE replace(title, ' ', '-') = '%s'$and", $argument));
}
else {
$result = db_fetch_object(db_query("SELECT * FROM {user_titles} WHERE title = '%s'$and", $argument));
}
if (!$result) {
return FALSE;
}
return TRUE;
}
}