function support_comment_validate in Support Ticketing System 7
Implementation of hook_comment_validate().
File
- ./
support.module, line 1216 - support.module
Code
function support_comment_validate($comment) {
if (is_array($comment)) {
$node = node_load($comment['nid']);
}
else {
$node = node_load($comment->nid);
}
if ($node->type == 'support_ticket') {
if (isset($comment->assigned) && !is_numeric($comment->assigned)) {
$assigned = db_query("SELECT uid FROM {users} WHERE name = :name", array(
':name' => $comment->assigned,
))
->fetchField();
if ($node->assigned && !$assigned) {
form_set_error('assigned', t('You must specify a valid user.'));
}
else {
if ($assigned) {
$client = db_query('SELECT name FROM {support_client} WHERE clid = :clid', array(
':clid' => $node->client,
))
->fetchField();
$valid = _support_validate_assigned_user($assigned, $client);
if (!$valid) {
form_set_error('assigned', t('You must specify a user that has permission to view this ticket.'));
}
}
}
}
}
}