diff --git a/include/class.ticket.php b/include/class.ticket.php index ab4fe10aacbaf7a363a44602dbd5b08bcd6deb72..d180fc26294c0bd45413c0ea4a3a80e7eebbd4ce 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2309,16 +2309,6 @@ class Ticket { $vars['email'], $filter->getName())); } - if ($vars['topicId'] && ($topic=Topic::lookup($vars['topicId']))) { - if ($topic_form = $topic->getForm()) { - $TF = $topic_form->getForm($vars); - $topic_form = $topic_form->instanciate(); - $topic_form->setSource($vars); - if (!$TF->isValid($field_filter('topic'))) - $errors = array_merge($errors, $TF->errors()); - } - } - $id=0; $fields=array(); $fields['message'] = array('type'=>'*', 'required'=>1, 'error'=>'Message required'); @@ -2344,9 +2334,6 @@ class Ticket { if(!Validator::process($fields, $vars, $errors) && !$errors['err']) $errors['err'] ='Missing or invalid data - check the errors and try again'; - if ($vars['topicId'] && !$topic) - $errors['topicId'] = 'Invalid help topic selected'; - //Make sure the due date is valid if($vars['duedate']) { if(!$vars['time'] || strpos($vars['time'],':')===false) @@ -2389,6 +2376,21 @@ class Ticket { } } + if ($vars['topicId']) { + if ($topic=Topic::lookup($vars['topicId'])) { + if ($topic_form = $topic->getForm()) { + $TF = $topic_form->getForm($vars); + $topic_form = $topic_form->instanciate(); + $topic_form->setSource($vars); + if (!$TF->isValid($field_filter('topic'))) + $errors = array_merge($errors, $TF->errors()); + } + } + else { + $errors['topicId'] = 'Invalid help topic selected'; + } + } + // Any error above is fatal. if ($errors) return 0;