diff --git a/include/class.ticket.php b/include/class.ticket.php index 3ea61d6f33c8d7024d474cce917195f180563b2a..a704c416117cb5b297db91f78ec13e658101ab2e 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1918,18 +1918,25 @@ class Ticket { global $ost, $cfg, $thisclient, $_FILES; // Don't enforce form validation for email - $field_filter = function($f) use ($origin) { - // Ultimately, only offer validation errors for web for - // non-internal fields. For email, no validation can be - // performed. For other origins, validate as usual - switch (strtolower($origin)) { - case 'email': - return false; - case 'web': - return !$f->get('private'); - default: - return true; - } + $field_filter = function($type) use ($origin) { + return function($f) use ($origin, $type) { + // Ultimately, only offer validation errors for web for + // non-internal fields. For email, no validation can be + // performed. For other origins, validate as usual + switch (strtolower($origin)) { + case 'email': + return false; + case 'staff': + // Required 'Contact Information' fields aren't required + // when staff open tickets + return $type != 'user' + || in_array($f->get('name'), array('name','email')); + case 'web': + return !$f->get('private'); + default: + return true; + } + }; }; //Check for 403 @@ -1967,7 +1974,7 @@ class Ticket { $field->value = $field->parse($vars[$fname]); } - if (!$form->isValid($field_filter)) + if (!$form->isValid($field_filter('ticket'))) $errors += $form->errors(); // Unpack dynamic variables into $vars for filter application @@ -2045,7 +2052,7 @@ class Ticket { // account created or detected if (!$user) { $user_form = UserForm::getUserForm()->getForm($vars); - if (!$user_form->isValid($field_filter) + if (!$user_form->isValid($field_filter('user')) || !($user=User::fromForm($user_form->getClean()))) $errors['user'] = 'Incomplete client information'; }