diff --git a/include/ajax.forms.php b/include/ajax.forms.php index be185fc29f4d47cde1df6dafadb596aaeed564bb..cdd643a1b44f77d4e30c51bf3cd67fc5886acd77 100644 --- a/include/ajax.forms.php +++ b/include/ajax.forms.php @@ -37,73 +37,6 @@ class DynamicFormsAjaxAPI extends AjaxController { $field->save(); } - function getUserInfo($user_id) { - $user = User::lookup($user_id); - - $data = $user->ht; - $data['email'] = $user->default_email->address; - - $custom = array(); - foreach ($user->getDynamicData() as $cd) { - $cd->addMissingFields(); - foreach ($cd->getFields() as $f) { - if ($f->get('name') == 'name') - $f->value = $user->getFullName(); - elseif ($f->get('name') == 'email') - $f->value = $user->getEmail(); - } - $custom[] = $cd->getForm(); - } - - include(STAFFINC_DIR . 'templates/user-info.tmpl.php'); - } - - function saveUserInfo($user_id) { - $user = User::lookup($user_id); - - $custom_data = $user->getDynamicData(); - $custom = array(); - $valid = true; - foreach ($custom_data as $cd) { - $cd->addMissingFields(); - $cf = $custom[] = $cd->getForm(); - $valid &= $cd->isValid(); - } - - if ($valid) { - foreach ($custom_data as $cd) - foreach ($cd->getFields() as $f) - if ($f->get('name') == 'email') - $email = $f; - $u = User::lookup(array('emails__address'=>$email->getClean())); - if ($u && $u->id != $user_id) { - $valid = false; - $email->addError('Email is assigned to another user'); - } - } - - if (!$valid) { - include(STAFFINC_DIR . 'templates/user-info.tmpl.php'); - return; - } - - // Save custom data - foreach ($custom_data as $cd) { - foreach ($cd->getFields() as $f) { - if ($f->get('name') == 'name') { - $user->name = $f->getClean(); - $user->save(); - } - elseif ($f->get('name') == 'email') { - $user->default_email->address = $f->getClean(); - $user->default_email->save(); - } - } - $cd->save(); - } - - return Http::response(201, $user->to_json()); - } } ?> diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index a142fc1056deab841b3cbf5f590a19295313ac80..aa4d99129a6f7d41e2dfc762384c3bf3bd60fa3c 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -448,5 +448,82 @@ class TicketsAjaxAPI extends AjaxController { return $resp; } + + function viewUser($tid) { + global $thisstaff; + + if(!$thisstaff + || !($ticket=Ticket::lookup($tid)) + || !$ticket->checkStaffAccess($thisstaff)) + Http::response(404, 'No such ticket'); + + + if(!($user = $ticket->getOwner())) + Http::response(404, 'Unknown user'); + + + $info = array( + 'title' => sprintf('Ticket #%s: %s', $ticket->getNumber(), $user->getName()) + ); + + ob_start(); + include(STAFFINC_DIR . 'templates/user.tmpl.php'); + $resp = ob_get_contents(); + ob_end_clean(); + return $resp; + + } + + function updateUser($tid) { + + global $thisstaff; + + if(!$thisstaff + || !($ticket=Ticket::lookup($tid)) + || !$ticket->checkStaffAccess($thisstaff) + || ! ($user = $ticket->getOwner())) + Http::response(404, 'No such ticket/user'); + + $errors = array(); + if($user->updateInfo($_POST, $errors)) + Http::response(201, $user->to_json()); + + $forms = $user->getForms(); + + $info = array( + 'title' => sprintf('Ticket #%s: %s', $ticket->getNumber(), $user->getName()) + ); + + ob_start(); + include(STAFFINC_DIR . 'templates/user.tmpl.php'); + $resp = ob_get_contents(); + ob_end_clean(); + return $resp; + } + + function changeUserForm($tid) { + global $thisstaff; + + if(!$thisstaff + || !($ticket=Ticket::lookup($tid)) + || !$ticket->checkStaffAccess($thisstaff)) + Http::response(404, 'No such ticket'); + + + $user = $ticket->getOwner(); + + $info = array( + 'title' => sprintf('Change user for ticket #%s', $ticket->getNumber()) + ); + + ob_start(); + include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php'); + $resp = ob_get_contents(); + ob_end_clean(); + return $resp; + + } + + } ?> diff --git a/include/ajax.users.php b/include/ajax.users.php index 6291fd3627c44b8938b0e0688ca5fdf637939aaa..bbc19fc72a3a7169841d6addc3d47262853fbe2c 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -20,7 +20,7 @@ if(!defined('INCLUDE_DIR')) die('403'); include_once(INCLUDE_DIR.'class.ticket.php'); class UsersAjaxAPI extends AjaxController { - + /* Assumes search by emal for now */ function search() { @@ -54,14 +54,69 @@ class UsersAjaxAPI extends AjaxController { } - function getLookupForm() { - $user_info = array(); - if ($_REQUEST['id']) { - $user = User::lookup($_REQUEST['id']); - $user_info += array( - 'name'=>$user->getName(), 'email'=>$user->getEmail()); + function getUser() { + + if(($user=User::lookup($_REQUEST['id']))) + Http::response(201, $user->to_json()); + + $info = array('error' =>'Unknown or invalid user'); + + return self::_lookupform(null, $info); + } + + function addUser() { + + $valid = true; + $form = UserForm::getUserForm()->getForm($_POST); + if (!$form->isValid()) + $valid = false; + + if (($field=$form->getField('email')) + && $field->getClean() + && User::lookup(array('emails__address'=>$field->getClean()))) { + $field->addError('Email is assigned to another user'); + $valid = false; } + + if ($valid && ($user = User::fromForm($form->getClean()))) + Http::response(201, $user->to_json()); + + + $info = array('error' =>'Error adding user - try again!'); + + return self::_lookupform($form, $info); + } + + function getLookupForm() { + return self::_lookupform(); + } + + function selectUser($id) { + + if ($id) + $user = User::lookup($id); + + $info = array('title' => 'Select User'); + + ob_start(); include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php'); + $resp = ob_get_contents(); + ob_end_clean(); + return $resp; + } + + static function _lookupform($form=null, $info=array()) { + + if (!$info or !$info['title']) + $info += array('title' => 'User Lookup'); + + ob_start(); + include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php'); + $resp = ob_get_contents(); + ob_end_clean(); + return $resp; + } + } ?> diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index f49d819ba8cb4768dbbc0a8589142feec2842af8..081ceabc7d342a110791065e8f48c13296c3b045 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -67,12 +67,17 @@ class DynamicForm extends VerySimpleModel { return call_user_func_array($delegate, $args); } - function hasField($name) { + function getField($name) { foreach ($this->getDynamicFields() as $f) - if ($f->get('name') == $name) - return true; + if (!strcasecmp($f->get('name'), $name)) + return $f->getImpl(); } + function hasField($name) { + return ($this->getField($name)); + } + + function getTitle() { return $this->get('title'); } function getInstructions() { return $this->get('instructions'); } @@ -404,6 +409,15 @@ class DynamicFormEntry extends VerySimpleModel { return $this->_fields; } + function getField($name) { + + foreach ($this->getFields() as $field) + if (!strcasecmp($field->get('name'), $name)) + return $field; + + return null; + } + /** * Validate the form and indicate if there no errors. * @@ -453,8 +467,8 @@ class DynamicFormEntry extends VerySimpleModel { $this->object_id = $user_id; } - function render($staff=true) { - return $this->getForm()->render($staff); + function render($staff=true, $title=false) { + return $this->getForm()->render($staff, $title); } /** diff --git a/include/class.forms.php b/include/class.forms.php index e94adcfdb80b0c3a6847bf3b8f16912b441a8564..0654a2648c9d1cb2438e35c0357927dc7d2588b7 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -49,6 +49,13 @@ class Form { function getFields() { return $this->fields; } + + function getField($name) { + foreach($this->getFields() as $f) + if(!strcasecmp($f->get('name'), $name)) + return $f; + } + function getTitle() { return $this->title; } function getInstructions() { return $this->instructions; } function getSource() { return $this->_source; } diff --git a/include/class.nav.php b/include/class.nav.php index 8cb8e5bb83e68bab152d75c287537b35c8d17ded..5a391ff553967c1338828ab6796ea079a615a6dd 100644 --- a/include/class.nav.php +++ b/include/class.nav.php @@ -122,8 +122,10 @@ class StaffNav { if($staff->canCreateTickets()) $subnav[]=array('desc'=>'New Ticket', + 'title' => 'Open New Ticket', 'href'=>'tickets.php?a=open', 'iconclass'=>'newTicket', + 'id' => 'new-ticket', 'droponly'=>true); } break; diff --git a/include/class.ticket.php b/include/class.ticket.php index 0c1fe0b3ccb1765579c816af0523f6afdb733bd6..b8dbe21871cd18db35c9df11f7baa26e6722136b 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -195,18 +195,13 @@ class Ticket { function getEmail(){ if ($o = $this->getOwner()) return $o->getEmail(); + return null; } function getReplyToEmail() { - if ($this->ht['user_email_id']) { - if (!isset($this->reply_email)) - $this->reply_email = UserEmail::lookup($this->ht['user_email_id']); - return $this->reply_email->address; - } - else { - return $this->getEmail(); - } + //TODO: Determine the email to use (once we enable multi-email support) + return $this->getEmail(); } function getAuthToken() { @@ -1332,6 +1327,33 @@ class Ticket { return $this->unassign(); } + //Change ownership + function changeOwner($user) { + global $thisstaff; + + if (!$user + || ($user->getId() == $this->getOwnerId()) + || !$thisstaff->canEditTickets()) + return false; + + $sql ='UPDATE '.TICKET_TABLE.' SET updated = NOW() ' + .', user_id = '.db_input($user->getId()) + .' WHERE ticket_id = '.db_input($this->getId()); + + if (!db_query($sql) || !db_affected_rows()) + return false; + + $this->ht['user_id'] = $user->getId(); + $this->user = null; + + $this->logNote('Ticket ownership changed', + Format::htmlchars( sprintf('%s changed ticket ownership to %s', + $thisstaff->getName(), $user->getName())) + ); + + return true; + } + //Insert message from client function postMessage($vars, $origin='', $alerts=true) { global $cfg; @@ -1902,18 +1924,6 @@ class Ticket { return true; } }; - // Identify the user creating the ticket and unpack user information - // fields into local scope for filtering and banning purposes - if (strtolower($origin) == 'api') - $user_form = UserForm::getUserForm()->getForm($vars); - else - $user_form = UserForm::getUserForm()->getForm($_POST); - - $user_info = $user_form->getClean(); - if ($user_form->isValid($field_filter)) - $vars += $user_info; - else - $errors['user'] = 'Incomplete client information'; //Check for 403 if ($vars['email'] && Validator::is_email($vars['email'])) { @@ -2006,23 +2016,29 @@ class Ticket { $errors['duedate']='Due date must be in the future'; } - // Data is slightly different between HTTP posts and emails - if ((isset($vars['emailId']) && $vars['emailId']) - || !isset($user_info['email']) || !$user_info['email']) { - $user_info = $vars; + if (!$errors) { + + if ($vars['uid'] && ($user = User::lookup($vars['uid']))) { + $vars['email'] = $user->getEmail(); + $vars['name'] = $user->getName(); + } + + # Perform ticket filter actions on the new ticket arguments + if ($ticket_filter) $ticket_filter->apply($vars); + + // Allow vars to be changed in ticket filter and applied to the user + // account created or detected + if (!$user) { + $user_form = UserForm::getUserForm()->getForm($vars); + if (!$user_form->isValid($field_filter) + || !($user=User::fromForm($user_form->getClean()))) + $errors['user'] = 'Incomplete client information'; + } } //Any error above is fatal. if($errors) return 0; - # Perform ticket filter actions on the new ticket arguments - if ($ticket_filter) $ticket_filter->apply($vars); - - // Allow vars to be changed in ticket filter and applied to the user - // account created or detected - $user = User::fromForm($vars); - $user_email = UserEmail::ensure($vars['email']); - # Some things will need to be unpacked back into the scope of this # function if (isset($vars['autorespond'])) $autorespond=$vars['autorespond']; @@ -2074,7 +2090,6 @@ class Ticket { $sql='INSERT INTO '.TICKET_TABLE.' SET created=NOW() ' .' ,lastmessage= NOW()' .' ,user_id='.db_input($user->id) - .' ,user_email_id='.db_input($user_email->id) .' ,ticketID='.db_input($extId) .' ,dept_id='.db_input($deptId) .' ,topic_id='.db_input($topicId) @@ -2174,6 +2189,15 @@ class Ticket { if($vars['source'] && !in_array(strtolower($vars['source']),array('email','phone','other'))) $errors['source']='Invalid source - '.Format::htmlchars($vars['source']); + if (!$vars['uid']) { + //Special validation required here + if (!$vars['email'] || !Validator::is_email($vars['email'])) + $errors['email'] = 'Valid email required'; + + if (!$vars['name']) + $errors['name'] = 'Name required'; + } + if(!($ticket=Ticket::create($vars, $errors, 'staff', false, (!$vars['assignId'])))) return false; diff --git a/include/class.user.php b/include/class.user.php index 269e202cad3d479a9c47a0e04844fece79955ce2..15f35223c7aac2404230d793230d997fe911f618 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -67,6 +67,7 @@ class UserModel extends VerySimpleModel { class User extends UserModel { var $_entries; + var $_forms; function __construct($ht) { parent::__construct($ht); @@ -119,11 +120,16 @@ class User extends UserModel { return new PersonsName($this->name); } + function getUpdateDate() { + return $this->updated; + } + function to_json() { $info = array( 'id' => $this->getId(), - 'name' => (string) $this->getName()); + 'name' => (string) $this->getName(), + 'email' => (string) $this->getEmail()); return JsonDataEncoder::encode($info); } @@ -154,6 +160,69 @@ class User extends UserModel { return $this->_entries; } + function getForms($data=null) { + + if (!isset($this->_forms)) { + $this->_forms = array(); + foreach ($this->getDynamicData() as $cd) { + $cd->addMissingFields(); + if(!$data + && ($form = $cd->getForm()) + && $form->get('type') == 'U' ) { + foreach ($cd->getFields() as $f) { + if ($f->get('name') == 'name') + $f->value = $this->getFullName(); + elseif ($f->get('name') == 'email') + $f->value = $this->getEmail(); + } + } + + $this->_forms[] = $cd->getForm(); + } + } + + return $this->_forms; + } + + function updateInfo($vars, &$errors) { + + $valid = true; + $forms = $this->getForms($vars); + foreach ($forms as $cd) { + if (!$cd->isValid()) + $valid = false; + if ($cd->get('type') == 'U' + && ($form= $cd->getForm($data)) + && ($f=$form->getField('email')) + && $f->getClean() + && ($u=User::lookup(array('emails__address'=>$f->getClean()))) + && $u->id != $this->getId()) { + $valid = false; + $f->addError('Email is assigned to another user'); + } + } + + if (!$valid) + return false; + + foreach ($this->getDynamicData() as $cd) { + if (($f=$cd->getForm()) && $f->get('type') == 'U') { + if (($name = $f->getField('name'))) { + $this->name = $name->getClean(); + $this->save(); + } + + if (($email = $f->getField('email'))) { + $this->default_email->address = $email->getClean(); + $this->default_email->save(); + } + } + $cd->save(); + } + + return true; + } + function save($refetch=false) { // Drop commas and reorganize the name without them $parts = array_map('trim', explode(',', $this->name)); diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php index 90373479f3b1270bc0375826953a92c6657db403..aa4e2f1130aae8899778d30ff16f92bb1ce27dad 100644 --- a/include/staff/footer.inc.php +++ b/include/staff/footer.inc.php @@ -17,5 +17,8 @@ if(is_object($thisstaff) && $thisstaff->isStaff()) { ?> <h4>Please Wait!</h4> <p>Please wait... it will take a second!</p> </div> +<div class="dialog" style="display:none;width:650px;" id="popup"> + <div class="body"></div> +</div> </body> </html> diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index 0e8924ea94aa983e47cf4b4e580e1f23b5772e67..ded810d8996c70fed985b75c690abdb5f9e8974b 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -67,9 +67,12 @@ echo sprintf('<li class="%s"><a href="%s">%s</a>',$tab['active']?'active':'inactive',$tab['href'],$tab['desc']); if(!$tab['active'] && ($subnav=$nav->getSubMenu($name))){ echo "<ul>\n"; - foreach($subnav as $item) { - echo sprintf('<li><a class="%s" href="%s" title="%s" >%s</a></li>', - $item['iconclass'],$item['href'],$item['title'],$item['desc']); + foreach($subnav as $k => $item) { + if (!($id=$item['id'])) + $id="nav$k"; + + echo sprintf('<li><a class="%s" href="%s" title="%s" id="%s">%s</a></li>', + $item['iconclass'], $item['href'], $item['title'], $id, $item['desc']); } echo "\n</ul>\n"; } @@ -94,8 +97,11 @@ ) ))) $class="$class active"; + if (!($id=$item['id'])) + $id="subnav$k"; - echo sprintf('<li><a class="%s" href="%s" title="%s" >%s</a></li>',$class,$item['href'],$item['title'],$item['desc']); + echo sprintf('<li><a class="%s" href="%s" title="%s" id="%s">%s</a></li>', + $class, $item['href'], $item['title'], $id, $item['desc']); } } ?> diff --git a/include/staff/templates/user-info.tmpl.php b/include/staff/templates/user-info.tmpl.php deleted file mode 100644 index 09b99b72743f6e7f5b4a27277c50ce5a49cf7ac1..0000000000000000000000000000000000000000 --- a/include/staff/templates/user-info.tmpl.php +++ /dev/null @@ -1,41 +0,0 @@ -<h3><?php echo $user->getFullName() ?></h3> -<a class="close" href=""><i class="icon-remove-circle"></i></a> -<br> -<div><p id="msg_info"><i class="icon-info-sign"></i> Please note that updates will be reflected system-wide.</p></div> -<hr/> -<form method="post" action="ajax.php/form/user-info/<?php - echo $user->get('id'); ?>" onsubmit="javascript: - var form = $(this); - var dialog = form.closest('.dialog'); - $.post(this.action, form.serialize(), function(data, status, xhr) { - if(xhr && xhr.status == 201) { - var user = $.parseJSON(xhr.responseText); - $('#user-'+user.id+'-name').html(user.name); - $('div.body', dialog).empty(); - dialog.hide(); - $('#overlay').hide(); - } else { - $('div.body', dialog).html(data); - } - }); - return false; - "> - <table width="100%"> - <?php - echo csrf_token(); - foreach ($custom as $form) - $form->render(); - ?> - </table> - <hr> - <p class="full-width"> - <span class="buttons" style="float:left"> - <input type="reset" value="Reset"> - <input type="button" value="Cancel" class="close"> - </span> - <span class="buttons" style="float:right"> - <input type="submit" value="Save"> - </span> - </p> -</form> -<div class="clear"></div> diff --git a/include/staff/templates/user-lookup.tmpl.php b/include/staff/templates/user-lookup.tmpl.php index ad9b5ae01e033cda8d70d83b4c0f1f4809c32a92..3e56def471dce072d56aea51546e006c45886f7d 100644 --- a/include/staff/templates/user-lookup.tmpl.php +++ b/include/staff/templates/user-lookup.tmpl.php @@ -1,40 +1,57 @@ -<h3>User Lookup</h3> -<a class="close" href=""><i class="icon-remove-circle"></i></a> +<h3><?php echo $info['title']; ?></h3> +<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b> <hr/> -<form method="post" action="" onsubmit="javascript: - var form=$(this), target=$('#client-info'), target_id=$('#user_id'), - user_id=$(this.user_id).val(); - if (user_id) { - target_id.val(user_id); - target.text($('#user-lookup-name').text() - + ' <' + $('#user-lookup-email').text() + '>'); - } - $('#user-lookup').hide(); - $('#overlay').hide(); - return false;"> -<div id="dialog-body"> -<input type="text" style="width:100%" placeholder="Search" id="client-search"/> -<br/><br/> -<i class="icon-user icon-4x pull-left icon-border"></i> -<div><strong id="user-lookup-name"><?php echo $user_info['name']; ?></strong></div> -<div><<span id="user-lookup-email"><?php echo $user_info['email']; ?></span>></div> -<input type="hidden" id="user-lookup-id" name="user_id" value=""/> -<div class="clear"></div> +<div><p id="msg_info"><i class="icon-info-sign"></i> Search existing users or add a new user.</p></div> +<div style="margin-bottom:10px;"><input type="text" class="search-input" style="width:100%;" placeholder="Search by email, phone or name" id="user-search"/></div> +<?php +if ($info['error']) { + echo sprintf('<p id="msg_error">%s</p>', $info['error']); +} elseif ($info['msg']) { + echo sprintf('<p id="msg_notice">%s</p>', $info['msg']); +} ?> +<div id="selected-user-info" style="display:<?php echo $user ? 'block' :'none'; ?>;margin:5px;"> +<form method="get" class="user" action="#users/lookup"> + <input type="hidden" id="user-id" name="id" value="<?php echo $user ? $user->getId() : 0; ?>"/> + <i class="icon-user icon-4x pull-left icon-border"></i> + <a class="action-button pull-right" style="overflow:inherit" + id="unselect-user" href="#"><i class="icon-remove"></i> Add New User</a> + <div><strong id="user-name"><?php echo $user ? $user->getName() : ''; ?></strong></div> + <div><<span id="user-email"><?php echo $user ? $user->getEmail() : ''; ?></span>></div> + <div class="clear"></div> + <hr> + <p class="full-width"> + <span class="buttons" style="float:left"> + <input type="button" name="cancel" class="close" value="Cancel"> + </span> + <span class="buttons" style="float:right"> + <input type="submit" value="Continue"> + </span> + </p> +</form> </div> +<div id="new-user-form" style="display:<?php echo $user ? 'none' :'block'; ?>;"> +<form method="post" class="user" action="#users/lookup/form"> + <table width="100%"> + <?php + if(!$form) $form = UserForm::getInstance(); + $form->render(true, 'New User Information'); ?> + </table> <hr> <p class="full-width"> <span class="buttons" style="float:left"> - <input type="button" value="Cancel" class="close"> + <input type="reset" value="Reset"> + <input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="Cancel"> </span> <span class="buttons" style="float:right"> - <input type="submit" value="Update"> + <input type="submit" value="Add User"> </span> </p> </form> +</div> <div class="clear"></div> <script type="text/javascript"> $(function() { - $('#client-search').typeahead({ + $('#user-search').typeahead({ source: function (typeahead, query) { $.ajax({ url: "ajax.php/users?q="+query, @@ -45,11 +62,28 @@ $(function() { }); }, onselect: function (obj) { - $('#user-lookup-name').text(obj.name); - $('#user-lookup-email').text(obj.email); - $('#user-lookup-id').val(obj.id); + $('#user-name').text(obj.name); + $('#user-email').text(obj.email); + $('#user-id').val(obj.id); + $('div#selected-user-info').show(); + $('div#new-user-form').hide(); + $('#user-search').val(''); }, property: "/bin/true" }); + + $('a#unselect-user').click( function(e) { + e.preventDefault(); + $('div#selected-user-info').hide(); + $('div#new-user-form').fadeIn(); + return false; + }); + + $(document).on('click', 'form.user input.cancel', function (e) { + e.preventDefault(); + $('div#new-user-form').hide(); + $('div#selected-user-info').fadeIn(); + return false; + }); }); </script> diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php new file mode 100644 index 0000000000000000000000000000000000000000..92bbe3754effd5161a51e2f3a1ebca4d9e65c910 --- /dev/null +++ b/include/staff/templates/user.tmpl.php @@ -0,0 +1,75 @@ +<?php +if (!$info['title']) + $info['title'] = $user->getName(); +?> +<h3><?php echo $info['title']; ?></h3> +<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b> +<hr/> +<?php +if ($info['error']) { + echo sprintf('<p id="msg_error">%s</p>', $info['error']); +} elseif ($info['msg']) { + echo sprintf('<p id="msg_notice">%s</p>', $info['msg']); +} ?> +<div id="user-profile" style="display:<?php echo $forms ? 'none' : 'block'; ?>;margin:5px;"> + <i class="icon-user icon-4x pull-left icon-border"></i> + <?php + if ($ticket) { ?> + <a class="action-button pull-right change-user" style="overflow:inherit" + href="#tickets/<?php echo $ticket->getId(); ?>/change-user" ><i class="icon-user"></i> Change User</a> + <?php + } ?> + <div><b><a href="#" id="edituser"><i class="icon-edit"></i> <?php + echo $user->getName(); ?></a></b></div> + <div><<?php echo $user->getEmail(); ?>></div> + <div><?php echo $user->getPhoneNumber(); ?></div> + <div class="clear"></div> + <hr> + <div class="faded">Last updated <b><?php echo Format::db_datetime($user->getUpdateDate()); ?> </b></div> +</div> +<div id="user-form" style="display:<?php echo $forms ? 'block' : 'none'; ?>;"> +<div><p id="msg_info"><i class="icon-info-sign"></i> Please note that updates will be reflected system-wide.</p></div> +<?php +$action = '#users/'.$user->getId(); +if ($ticket && $ticket->getOwnerId() == $user->getId()) + $action = '#tickets/'.$ticket->getId().'/user'; +?> +<form method="post" class="user" action="<?php echo $action; ?>"> + <input type="hidden" name="uid" value="<?php echo $user->getId(); ?>" /> + <table width="100%"> + <?php + if (!$forms) $forms = $user->getForms(); + foreach ($forms as $form) + $form->render(); + ?> + </table> + <hr> + <p class="full-width"> + <span class="buttons" style="float:left"> + <input type="reset" value="Reset"> + <input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="Cancel"> + </span> + <span class="buttons" style="float:right"> + <input type="submit" value="Update User"> + </span> + </p> +</form> +</div> +<div class="clear"></div> +<script type="text/javascript"> +$(function() { + $('a#edituser').click( function(e) { + e.preventDefault(); + $('div#user-profile').hide(); + $('div#user-form').fadeIn(); + return false; + }); + + $(document).on('click', 'form.user input.cancel', function (e) { + e.preventDefault(); + $('div#user-form').hide(); + $('div#user-profile').fadeIn(); + return false; + }); +}); +</script> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 668cd523484926831642b9626a2c2816877d562d..fa4b4069022d5453689d03820ba8479e4efa8b29 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -20,21 +20,26 @@ if ($_POST) </th> </tr> <?php - $client = User::lookup($info['user_id']); + if(!$info['user_id'] || !($user = User::lookup($info['user_id']))) + $user = $ticket->getUser(); ?> <tr><td>Client:</td><td> - <span id="client-info"><?php echo $client->getName(); ?> - <<?php echo $client->getEmail(); ?>></span> - <a class="action-button" style="float:none;overflow:inherit" - href="ajax.php/users/lookup?id=<?php echo $client->getId(); ?>" - onclick="javascript: - $('#overlay').show(); - $('#user-lookup .body').load(this.href); - $('#user-lookup').show(); - return false; - "><i class="icon-edit"></i> Change</a> - <input type="hidden" name="user_id" id="user_id" - value="<?php echo $info['user_id']; ?>" /> + <div id="client-info"> + <span id="client-name"><?php echo $user->getName(); ?></span> + <span id="client-email"><<?php echo $user->getEmail(); ?>></span> + <a class="action-button" style="float:none;overflow:inherit" href="#" + onclick="javascript: + $.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/change-user', + function(user) { + $('input#user_id').val(user.id); + $('#user_name').html(user.name); + $('#user_email').html('<'+user.email+'>'); + }); + return false; + "><i class="icon-edit"></i> Change</a> + <input type="hidden" name="user_id" id="user_id" + value="<?php echo $info['user_id']; ?>" /> + </div> </td></tr> <tbody> <tr> diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 0bbaa769197bbffb147fe301ad50f41938026d99..6e7a76a96e75c282c7905c9efa704897de0ac91a 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -17,17 +17,64 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> </thead> <tbody> + <tr> + <th colspan="2"> + <em><strong>Client Information</strong>: </em> + </th> + </tr> + <?php + if ($user) { ?> + <tr><td>Client:</td><td> + <div id="client-info"> + <span id="client-name"><?php echo $user->getName(); ?></span> + <span id="client-email"><<?php echo $user->getEmail(); ?>></span> + <a class="action-button" style="float:none;overflow:inherit" href="#" + onclick="javascript: + $.userLookup('ajax.php/users/select/<?php echo $user->getId(); ?>', + function(user) { + $('input#uid').val(user.id); + $('#client-name').html(user.name); + $('#client-email').text('<'+user.email+'>'); + }); + return false; + "><i class="icon-edit"></i> Change</a> + <input type="hidden" name="uid" id="uid" value="<?php echo $user->getId(); ?>" /> + </div> + </td></tr> + <?php + } else { //Fallback: Just ask for email and name + ?> + <tr> + <td width="160" class="required"> Email Address: </td> + <td> + <span style="display:inline-block;"> + <input type="text" size=45 name="email" id="user-email" value="<?php echo $info['email']; ?>" /> </span> + <font class="error">* <?php echo $errors['email']; ?></font> + </td> + </td> + <tr> + <td width="160" class="required"> Full Name: </td> + <td> + <span style="display:inline-block;"> + <input type="text" size=45 name="name" id="user-name" value="<?php echo $info['name']; ?>" /> </span> + <font class="error">* <?php echo $errors['name']; ?></font> + </td> + </td> + <?php + } ?> + <?php - $uf = UserForm::getUserForm(); - $uf->render(); if($cfg->notifyONNewStaffTicket()) { ?> <tr> - <td width="160">Alert:</td> + <td width="160">Ticket Notice:</td> <td> <input type="checkbox" name="alertuser" <?php echo (!$errors || $info['alertuser'])? 'checked="checked"': ''; ?>>Send alert to user. </td> </tr> - <?php } ?> + <?php + } ?> + </tbody> + <tbody> <tr> <th colspan="2"> <em><strong>Ticket Information & Options</strong>:</em> @@ -289,3 +336,26 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <input type="button" name="cancel" value="Cancel" onclick='window.location.href="tickets.php"'> </p> </form> +<script type="text/javascript"> +$(function() { + $('input#user-email').typeahead({ + source: function (typeahead, query) { + $.ajax({ + url: "ajax.php/users?q="+query, + dataType: 'json', + success: function (data) { + typeahead.process(data); + } + }); + }, + onselect: function (obj) { + $('#uid').val(obj.id); + $('#user-name').val(obj.name); + $('#user-email').val(obj.email); + }, + property: "/bin/true" + }); + +}); +</script> + diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index d60bd2c73100cdc259a7f85d94b7a9b1c523e678..de1fb3a0f217ac7d788e1ff92315118f3f0828d9 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -70,7 +70,6 @@ if($ticket->isOverdue()) <a class="action-button" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i> Edit</a> <?php } ?> - <?php if($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?> <a id="ticket-claim" class="action-button" href="#claim"><i class="icon-user"></i> Claim</a> @@ -83,6 +82,10 @@ if($ticket->isOverdue()) <div id="action-dropdown-more" class="action-dropdown anchor-right"> <ul> <?php + if($thisstaff->canEditTickets()) { ?> + <li><a class="change-user" href="#tickets/<?php echo $ticket->getId(); ?>/change-user"><i class="icon-user"></i> Change Ticket Owner</a></li> + <?php + } if($ticket->isOpen() && ($dept && $dept->isManager($thisstaff))) { if($ticket->isAssigned()) { ?> @@ -144,12 +147,15 @@ if($ticket->isOverdue()) <table border="0" cellspacing="" cellpadding="4" width="100%"> <tr> <th width="100">Client:</th> - <td><a href="ajax.php/form/user-info/<?php - echo $ticket->getOwnerId(); ?>" + <td><a href="#tickets/<?php echo $ticket->getId(); ?>/user" onclick="javascript: - $('#overlay').show(); - $('#user-info .body').load(this.href); - $('#user-info').show(); + $.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/user', + function (user) { + $('#user-'+user.id+'-name').text(user.name); + $('#user-'+user.id+'-email').text(user.email); + $('#user-to-name').text(user.name); + $('#user-to-email').text(user.email); + }); return false; "><i class="icon-user"></i> <span id="user-<?php echo $ticket->getOwnerId(); ?>-name" ><?php echo Format::htmlchars($ticket->getName()); @@ -180,7 +186,7 @@ if($ticket->isOverdue()) <tr> <th>Email:</th> <td> - <?php echo $ticket->getEmail(); ?> + <span id="user-<?php echo $ticket->getOwnerId(); ?>-email"><?php echo $ticket->getEmail(); ?></span> </td> </tr> <tr> @@ -405,10 +411,8 @@ $tcount+= $ticket->getNumNotes(); </td> <td> <?php - $to = $ticket->getReplyToEmail(); - if(($name=$ticket->getName()) && !strpos($name,'@')) - $to =sprintf('%s <em><%s></em>', $name, $to); - echo $to; + echo sprintf('<span id="user-to-name">%s</span> <em><<span id="user-to-email">%s</span>></em>', + $ticket->getName(), $ticket->getReplyToEmail()); ?> <label><input type='checkbox' value='1' name="emailreply" id="remailreply" @@ -782,9 +786,6 @@ $tcount+= $ticket->getNumNotes(); <?php } ?> </div> -<div style="display:none;" class="dialog draggable" id="user-info"> - <div class="body"></div> -</div> <div style="display:none;" class="dialog" id="print-options"> <h3>Ticket Print Options</h3> <a class="close" href=""><i class="icon-remove-circle"></i></a> @@ -881,6 +882,10 @@ $tcount+= $ticket->getNumNotes(); <p class="confirm-action" style="display:none;" id="release-confirm"> Are you sure want to <b>unassign</b> ticket from <b><?php echo $ticket->getAssigned(); ?></b>? </p> + <p class="confirm-action" style="display:none;" id="changeuser-confirm"> + Are you sure want to <b>change</b> ticket owner to <b><span id="newuser">this guy</span></b>? + <br><br><b><?php echo $ticket->getName(); ?></b> <<?php echo $ticket->getEmail(); ?>> will no longer have access to the ticket. + </p> <p class="confirm-action" style="display:none;" id="delete-confirm"> <font color="red"><strong>Are you sure you want to DELETE this ticket?</strong></font> <br><br>Deleted tickets CANNOT be recovered, including any associated attachments. @@ -904,3 +909,26 @@ $tcount+= $ticket->getNumNotes(); <div class="clear"></div> </div> <script type="text/javascript" src="js/ticket.js"></script> +<script type="text/javascript"> +$(function() { + $(document).on('click', 'a.change-user', function(e) { + e.preventDefault(); + var tid = <?php echo $ticket->getOwnerId(); ?>; + var cid = <?php echo $ticket->getOwnerId(); ?>; + var url = 'ajax.php/'+$(this).attr('href').substr(1); + $.userLookup(url, function(user) { + if(cid!=user.id + && $('.dialog#confirm-action #changeuser-confirm').length) { + $('#newuser').html(user.name +' <'+user.email+'>'); + $('.dialog#confirm-action #action').val('changeuser'); + $('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />'); + $('#overlay').show(); + $('.dialog#confirm-action .confirm-action').hide(); + $('.dialog#confirm-action p#changeuser-confirm') + .show() + .parent('div').show().trigger('click'); + } + }); + }); +}); +</script> diff --git a/scp/ajax.php b/scp/ajax.php index 26d4e21a1cc58cd8da129dcd683cfc01916e19aa..106f3366a723a6e25a815796209c1dc5fed07f71 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -48,9 +48,7 @@ $dispatcher = patterns('', url('^/form/', patterns('ajax.forms.php:DynamicFormsAjaxAPI', url_get('^help-topic/(?P<id>\d+)$', 'getFormsForHelpTopic'), url_get('^field-config/(?P<id>\d+)$', 'getFieldConfiguration'), - url_post('^field-config/(?P<id>\d+)$', 'saveFieldConfiguration'), - url_get('^user-info/(?P<id>\d+)$', 'getUserInfo'), - url_post('^user-info/(?P<id>\d+)$', 'saveUserInfo') + url_post('^field-config/(?P<id>\d+)$', 'saveFieldConfiguration') )), url('^/report/overview/', patterns('ajax.reports.php:OverviewReportAjaxAPI', # Send @@ -61,9 +59,18 @@ $dispatcher = patterns('', )), url('^/users', patterns('ajax.users.php:UsersAjaxAPI', url_get('^$', 'search'), - url_get('^/lookup$', 'getLookupForm') + url_get('^/(?P<id>\d+)$', 'getUser'), + url_get('^/lookup$', 'getUser'), + url_get('^/lookup/form$', 'getLookupForm'), + url_post('^/lookup/form$', 'addUser'), + url_get('^/select$', 'selectUser'), + url_get('^/select/(?P<id>\d+)$', 'selectUser') )), url('^/tickets/', patterns('ajax.tickets.php:TicketsAjaxAPI', + url_get('^(?P<tid>\d+)/change-user$', 'changeUserForm'), + url_post('^(?P<tid>\d+)/change-user$', 'changeUser'), + url_get('^(?P<tid>\d+)/user$', 'viewUser'), + url_post('^(?P<tid>\d+)/user$', 'updateUser'), url_get('^(?P<tid>\d+)/preview', 'previewTicket'), url_post('^(?P<tid>\d+)/lock', 'acquireLock'), url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/renew', 'renewLock'), diff --git a/scp/css/scp.css b/scp/css/scp.css index 684f2c98191fa3918fd200429688d2d3ff057409..140b488d10d1d0f3696a655a16a258cf9ce66610 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -20,6 +20,10 @@ a { width: 100%; } +.search-input { + height: 20px; +} + .clear { clear:both; } @@ -45,11 +49,11 @@ a { #msg_info { margin: 0; padding: 5px; margin-bottom: 10px; color: #3a87ad; border: 1px solid #bce8f1; background-color: #d9edf7; } -#msg_notice { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #0a0; background: url('../images/icons/ok.png') 10px 50% no-repeat #e0ffe0; } +#msg_notice { margin: 0; padding: 5px 10px 5px 36px; margin-bottom: 10px; border: 1px solid #0a0; background: url('../images/icons/ok.png') 10px 50% no-repeat #e0ffe0; } -#msg_warning { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #f26522; background: url('../images/icons/alert.png') 10px 50% no-repeat #ffffdd; } +#msg_warning { margin: 0; padding: 5px 10px 5px 36px; margin-bottom: 10px; border: 1px solid #f26522; background: url('../images/icons/alert.png') 10px 50% no-repeat #ffffdd; } -#msg_error { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #a00; background: url('../images/icons/error.png') 10px 50% no-repeat #fff0f0; } +#msg_error { margin: 0; padding: 5px 10px 5px 36px; margin-bottom: 10px; border: 1px solid #a00; background: url('../images/icons/error.png') 10px 50% no-repeat #fff0f0; } #notice_bar { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; border: 1px solid #0a0; background: url('../images/icons/ok.png') 10px 50% no-repeat #e0ffe0; } @@ -1277,6 +1281,11 @@ time { padding-right: 3em; } +.dialog a { + color:#184E81; +} + + .dialog a.close { position: absolute; display:inline-block; diff --git a/scp/js/scp.js b/scp/js/scp.js index a6a4786e47800e33f4d007d8873b29a49eb35111..b61e62057084e164bf1aac9e146f13f292ba9b3b 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -390,6 +390,50 @@ $(document).ready(function(){ $('#advanced-search').show(); }); + + $(document).on('click', 'a#new-ticket', function(e) { + e.preventDefault(); + var $elem = $(this); + $.userLookup('ajax.php/users/lookup/form', function (user) { + window.location.href = $elem.attr('href')+'&uid='+user.id; + }); + }); + + $.userLookup = function (url, callback) { + + $('.dialog#popup .body').load(url, function () { + $('#overlay').show(); + $('.dialog#popup').show(); + $(document).off('.user'); + $(document).on('submit.user', '.dialog#popup form.user',function(e) { + e.preventDefault(); + var $form = $(this); + var $dialog = $form.closest('.dialog'); + $.ajax({ + type: $form.attr('method'), + url: 'ajax.php/'+$form.attr('action').substr(1), + data: $form.serialize(), + cache: false, + success: function(resp, status, xhr) { + if (xhr && xhr.status == 201) { + var user = $.parseJSON(xhr.responseText); + $('div.body', $dialog).empty(); + $dialog.hide(); + $('#overlay').hide(); + if(callback) callback(user); + } else { + $('div.body', $dialog).html(resp); + $('#msg_notice, #msg_error', $dialog).delay(5000).slideUp(); + } + } + }) + .done(function() { }) + .fail(function() { }); + return false; + }); + }); + }; + $('#advanced-search').delegate('#status', 'change', function() { switch($(this).val()) { case 'closed': diff --git a/scp/js/ticket.js b/scp/js/ticket.js index 619becddfc5f5029ebeeb3d64f2a489336432814..c2110121a8f2e202a6749b6f56fb741cd09d1a7b 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -345,7 +345,7 @@ jQuery(function($) { }); //ticket actions confirmation - Delete + more - $('a#ticket-delete, a#ticket-claim, #action-dropdown-more li a').click(function(e) { + $('a#ticket-delete, a#ticket-claim, #action-dropdown-more li a:not(.change-user)').click(function(e) { e.preventDefault(); if($('.dialog#confirm-action '+$(this).attr('href')+'-confirm').length) { var action = $(this).attr('href').substr(1, $(this).attr('href').length); diff --git a/scp/tickets.php b/scp/tickets.php index c55c4f27f8fe97709b61997277a5a65de7e5d5d8..32b82768e5dc5b8af09de23b9afa9e4ac689e880 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -24,7 +24,7 @@ require_once(INCLUDE_DIR.'class.dynamic_forms.php'); $page=''; -$ticket=null; //clean start. +$ticket = $user = null; //clean start. //LOCKDOWN...See if the id provided is actually valid and if the user has access. if($_REQUEST['id']) { if(!($ticket=Ticket::lookup($_REQUEST['id']))) @@ -34,6 +34,11 @@ if($_REQUEST['id']) { $ticket=null; //Clear ticket obj. } } + +//Lookup user if id is available. +if ($_REQUEST['uid']) + $user = User::lookup($_REQUEST['uid']); + //At this stage we know the access status. we can process the post. if($_POST && !$errors): @@ -197,7 +202,7 @@ if($_POST && !$errors): if (!$form->isValid()) $errors = array_merge($errors, $form->errors()); if(!$ticket || !$thisstaff->canEditTickets()) - $errors['err']='Perm. Denied. You are not allowed to edit tickets'; + $errors['err']='Permission Denied. You are not allowed to edit tickets'; elseif($ticket->update($_POST,$errors)) { $msg='Ticket updated successfully'; $_REQUEST['a'] = null; //Clear edit action - going back to view. @@ -213,7 +218,7 @@ if($_POST && !$errors): switch(strtolower($_POST['do'])): case 'close': if(!$thisstaff->canCloseTickets()) { - $errors['err'] = 'Perm. Denied. You are not allowed to close tickets.'; + $errors['err'] = 'Permission Denied. You are not allowed to close tickets.'; } elseif($ticket->isClosed()) { $errors['err'] = 'Ticket is already closed!'; } elseif($ticket->close()) { @@ -237,7 +242,7 @@ if($_POST && !$errors): case 'reopen': //if staff can close or create tickets ...then assume they can reopen. if(!$thisstaff->canCloseTickets() && !$thisstaff->canCreateTickets()) { - $errors['err']='Perm. Denied. You are not allowed to reopen tickets.'; + $errors['err']='Permission Denied. You are not allowed to reopen tickets.'; } elseif($ticket->isOpen()) { $errors['err'] = 'Ticket is already open!'; } elseif($ticket->reopen()) { @@ -266,7 +271,7 @@ if($_POST && !$errors): break; case 'claim': if(!$thisstaff->canAssignTickets()) { - $errors['err'] = 'Perm. Denied. You are not allowed to assign/claim tickets.'; + $errors['err'] = 'Permission Denied. You are not allowed to assign/claim tickets.'; } elseif(!$ticket->isOpen()) { $errors['err'] = 'Only open tickets can be assigned'; } elseif($ticket->isAssigned()) { @@ -280,7 +285,7 @@ if($_POST && !$errors): case 'overdue': $dept = $ticket->getDept(); if(!$dept || !$dept->isManager($thisstaff)) { - $errors['err']='Perm. Denied. You are not allowed to flag tickets overdue'; + $errors['err']='Permission Denied. You are not allowed to flag tickets overdue'; } elseif($ticket->markOverdue()) { $msg='Ticket flagged as overdue'; $ticket->logActivity('Ticket Marked Overdue',($msg.' by '.$thisstaff->getName())); @@ -291,7 +296,7 @@ if($_POST && !$errors): case 'answered': $dept = $ticket->getDept(); if(!$dept || !$dept->isManager($thisstaff)) { - $errors['err']='Perm. Denied. You are not allowed to flag tickets'; + $errors['err']='Permission Denied. You are not allowed to flag tickets'; } elseif($ticket->markAnswered()) { $msg='Ticket flagged as answered'; $ticket->logActivity('Ticket Marked Answered',($msg.' by '.$thisstaff->getName())); @@ -302,7 +307,7 @@ if($_POST && !$errors): case 'unanswered': $dept = $ticket->getDept(); if(!$dept || !$dept->isManager($thisstaff)) { - $errors['err']='Perm. Denied. You are not allowed to flag tickets'; + $errors['err']='Permission Denied. You are not allowed to flag tickets'; } elseif($ticket->markUnAnswered()) { $msg='Ticket flagged as unanswered'; $ticket->logActivity('Ticket Marked Unanswered',($msg.' by '.$thisstaff->getName())); @@ -312,7 +317,7 @@ if($_POST && !$errors): break; case 'banemail': if(!$thisstaff->canBanEmails()) { - $errors['err']='Perm. Denied. You are not allowed to ban emails'; + $errors['err']='Permission Denied. You are not allowed to ban emails'; } elseif(BanList::includes($ticket->getEmail())) { $errors['err']='Email already in banlist'; } elseif(Banlist::add($ticket->getEmail(),$thisstaff->getName())) { @@ -323,7 +328,7 @@ if($_POST && !$errors): break; case 'unbanemail': if(!$thisstaff->canBanEmails()) { - $errors['err'] = 'Perm. Denied. You are not allowed to remove emails from banlist.'; + $errors['err'] = 'Permission Denied. You are not allowed to remove emails from banlist.'; } elseif(Banlist::remove($ticket->getEmail())) { $msg = 'Email removed from banlist'; } elseif(!BanList::includes($ticket->getEmail())) { @@ -332,9 +337,20 @@ if($_POST && !$errors): $errors['err']='Unable to remove the email from banlist. Try again.'; } break; + case 'changeuser': + if (!$thisstaff->canEditTickets()) { + $errors['err'] = 'Permission Denied. You are not allowed to EDIT tickets!!'; + } elseif (!$_POST['user_id'] || !($user=User::lookup($_POST['user_id']))) { + $errors['err'] = 'Unknown user selected!'; + } elseif ($ticket->changeOwner($user)) { + $msg = 'Ticket ownership changed to '.$user->getName(); + } else { + $errors['err'] = 'Unable to change tiket ownership. Try again'; + } + break; case 'delete': // Dude what are you trying to hide? bad customer support?? if(!$thisstaff->canDeleteTickets()) { - $errors['err']='Perm. Denied. You are not allowed to DELETE tickets!!'; + $errors['err']='Permission Denied. You are not allowed to DELETE tickets!!'; } elseif($ticket->delete()) { $msg='Ticket #'.$ticket->getNumber().' deleted successfully'; //Log a debug note @@ -475,6 +491,8 @@ if($_POST && !$errors): $errors['err']='You do not have permission to create tickets. Contact admin for such access'; } else { $vars = $_POST; + $vars['uid'] = $user? $user->getId() : 0; + if($_FILES['attachments']) $vars['files'] = AttachmentFile::format($_FILES['attachments']); @@ -569,8 +587,10 @@ if($thisstaff->showAssignedOnly() && $stats['closed']) { if($thisstaff->canCreateTickets()) { $nav->addSubMenu(array('desc'=>'New Ticket', + 'title' => 'Open New Ticket', 'href'=>'tickets.php?a=open', - 'iconclass'=>'newTicket'), + 'iconclass'=>'newTicket', + 'id' => 'new-ticket'), ($_REQUEST['a']=='open')); }