Skip to content
Snippets Groups Projects
Commit 4fe37bc8 authored by Jared Hancock's avatar Jared Hancock
Browse files

Allow new ticket without required contact fields

If a staff member creates a new ticket and cancels the user-lookup /
create-new-user dialog, and the contact information form has a required field
other than the name and email address fields, the ticket cannot be created
because the required fields for new clients are not shown and can therefore
not have a required value.

This patch allows new clients to be created without the required fields when
the ticket is created by staff members.
parent 12da45f9
No related branches found
No related tags found
No related merge requests found
...@@ -1918,18 +1918,25 @@ class Ticket { ...@@ -1918,18 +1918,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
...@@ -1967,7 +1974,7 @@ class Ticket { ...@@ -1967,7 +1974,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
...@@ -2045,7 +2052,7 @@ class Ticket { ...@@ -2045,7 +2052,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