Skip to content
Snippets Groups Projects
Commit b26f99e8 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #656 from greezybacon/issue/ticket-by-staff-fails


Allow new ticket without required contact fields

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 4fa5406f 4fe37bc8
No related branches found
No related tags found
No related merge requests found
...@@ -1925,18 +1925,25 @@ class Ticket { ...@@ -1925,18 +1925,25 @@ class Ticket {
global $ost, $cfg, $thisclient, $_FILES; global $ost, $cfg, $thisclient, $_FILES;
// Don't enforce form validation for email // Don't enforce form validation for email
$field_filter = function($f) use ($origin) { $field_filter = function($type) use ($origin) {
// Ultimately, only offer validation errors for web for return function($f) use ($origin, $type) {
// non-internal fields. For email, no validation can be // Ultimately, only offer validation errors for web for
// performed. For other origins, validate as usual // non-internal fields. For email, no validation can be
switch (strtolower($origin)) { // performed. For other origins, validate as usual
case 'email': switch (strtolower($origin)) {
return false; case 'email':
case 'web': return false;
return !$f->get('private'); case 'staff':
default: // Required 'Contact Information' fields aren't required
return true; // 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 //Check for 403
...@@ -1974,7 +1981,7 @@ class Ticket { ...@@ -1974,7 +1981,7 @@ class Ticket {
$field->value = $field->parse($vars[$fname]); $field->value = $field->parse($vars[$fname]);
} }
if (!$form->isValid($field_filter)) if (!$form->isValid($field_filter('ticket')))
$errors += $form->errors(); $errors += $form->errors();
// Unpack dynamic variables into $vars for filter application // Unpack dynamic variables into $vars for filter application
...@@ -2052,7 +2059,7 @@ class Ticket { ...@@ -2052,7 +2059,7 @@ class Ticket {
// account created or detected // account created or detected
if (!$user) { if (!$user) {
$user_form = UserForm::getUserForm()->getForm($vars); $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()))) || !($user=User::fromForm($user_form->getClean())))
$errors['user'] = 'Incomplete client information'; $errors['user'] = 'Incomplete client information';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment