function loadHandlers() { $allownoauto = false; $assign_ticket = true; if ($this->mode == 0) { $allownoauto = true; $assign_ticket = false; } $this->handlers = SupportUsers::getHandlersTicket($this->prodid, $this->deptid, $this->catid, $allownoauto, $assign_ticket, false, false); }
static function AssignHandler($prodid, $deptid, $catid, $force = false) { //echo "Assigning hander for $prodid, $deptid, $catid<br>"; $admin_id = 0; $assignuser = FSS_Settings::get('support_autoassign'); if ($assignuser == 1 || $force) { $okusers = SupportUsers::getHandlersTicket($prodid, $deptid, $catid); if (count($okusers) > 0) { $count = count($okusers); $picked = mt_rand(0, $count - 1); $admin_id = $okusers[$picked]; } else { // no users found $fallback = FSS_Settings::get('support_handler_fallback'); if ($fallback != "" && $fallback > 0) { $user = JFactory::getUser($fallback); if ($user) { $admin_id = $user->id; } } } } return $admin_id; }
function doOpenTicket() { if (!FSS_Permission::auth("fss.ticket.open", "com_fss.support_user")) { return FSS_Helper::NoPerm(); } $mainframe = JFactory::getApplication(); $user = JFactory::getUser(); $userid = $user->get('id'); $this->userid = $userid; $this->email = ''; $this->admin_create = 0; $session = JFactory::getSession(); if (FSS_Input::getInt('admincreate') > 0) { $session->Set("admin_create", FSS_Input::getInt('admincreate')); if ($session->Get("admin_create") == 1 && FSS_Input::getInt('user_id') > 0) { $session->Set('admin_create_user_id', FSS_Input::getInt('user_id')); } else { if ($session->Get("admin_create") == 2 && (FSS_Input::getString('admin_create_email') || FSS_Input::getString('admin_create_name'))) { $session->Set('ticket_email', FSS_Input::getEMail('admin_create_email')); $session->Set('ticket_name', FSS_Input::getString('admin_create_name')); } } } if ($session->Get("admin_create") == 1) { $this->admin_create = 1; $model = $this->getModel(); $this->user = $model->getUser($session->Get('admin_create_user_id')); } else { if ($session->Get("admin_create") == 2) { $this->unreg_email = $session->Get('ticket_email'); $this->unreg_name = $session->Get('ticket_name'); $this->admin_create = 2; } } if (FSS_Settings::Get('support_only_admin_open') && $this->admin_create < 1) { return $this->noPermission("Access Denied", "CREATING_NEW_TICKETS_BY_USERS_IS_CURRENTLY_DISABLED"); } // store in session and data for an unregistered ticket $type = FSS_Input::getCmd('type'); if ($type == "without") { $email = FSS_Input::getEMail('email'); $name = FSS_Input::getString('name'); if ($name == "") { $name = $email; } if ($email != "") { $session->Set('ticket_email', $email); $session->Set('ticket_name', $name); } } if (!$this->ValidateUser('open')) { return; } // defaults for blank ticket $ticket['priid'] = FSS_Input::getInt('priid', FSS_Settings::get('support_default_priority')); $ticket['body'] = FSS_Input::GetString('body'); $ticket['subject'] = FSS_Input::GetString('subject'); $ticket['handler'] = FSS_Input::getInt('handler', 0); $this->ticket = $ticket; $errors['subject'] = ''; $errors['body'] = ''; $errors['cat'] = ''; $errors['captcha'] = ''; $this->errors = $errors; $prodid = FSS_Input::getInt('prodid'); // prod id not set, should we display product list??? if ($prodid < 1) { $this->products = $this->get('Products'); if (count($this->products) > 1) { $this->search = ""; $pagination = $this->get('ProdPagination'); $this->pagination = $pagination; $this->limit = $this->get("ProdLimit"); parent::display("product"); return; } else { if (count($this->products) == 1) { $prodid = $this->products[0]['id']; JRequest::setVar('prodid', $prodid); //echo "Setting prodid to $prodid<br>"; } } } $this->assign('prodid', $prodid); $deptid = FSS_Input::getInt('deptid'); // dept id not set, should we display department list? if ($deptid < 1) { $this->search = ""; $this->depts = $this->get('Departments'); $this->limit = $this->get("ProdLimit"); if (count($this->depts) > 1) { $this->pagination = $this->get('DeptPagination'); $this->product = $this->get('Product'); parent::display("department"); return; } else { if (count($this->depts) == 1) { $deptid = $this->depts[0]['id']; JRequest::setVar('deptid', $deptid); //echo "Setting deptid to $deptid<br>"; } } } $what = FSS_Input::getCmd('what'); // done with ticket, try and save, if not, display any errors if ($what == "add") { if ($this->saveTicket()) { $message = FSS_Helper::HelpText("support_open_thanks", true); if ($message != "") { FSS_Helper::enqueueMessage($message, "success"); } //exit; if ($this->admin_create > 0) { $link = 'index.php?option=com_fss&view=admin_support&Itemid=' . FSS_Input::getInt('Itemid', '') . '&ticketid=' . $this->ticketid; $mainframe->redirect(FSSRoute::_($link, false)); } else { // need to set the session info that will display the ticket to the user here! $link = 'index.php?option=com_fss&view=ticket&layout=view&Itemid=' . FSS_Input::getInt('Itemid', '') . '&ticketid=' . $this->ticketid; $mainframe->redirect(FSSRoute::_($link, false)); } return; } else { //echo "Error saving ticket<br>"; } } // load handlers if required. This depends on what product and department have been selected if (FSS_Settings::get('support_choose_handler') != "none") { $allow_no_auto = 0; if ($this->admin_create > 0) { $allow_no_auto = 1; $this->autohandlers = SupportUsers::getHandlersTicket($prodid, $deptid, 0); } $handlers = SupportUsers::getHandlersTicket($prodid, $deptid, 0, $allow_no_auto); /** * I DONT KNOW IF THIS IS A GOOD CHANGE OR NOT, BUT IT MAKES IT CONSISTANT EVERYWHERE I THINK **/ // if the hide super users checkbox is tickets, hide them all from the dropdown if (FSS_Settings::get('support_hide_super_users')) { foreach ($handlers as $offset => $handler) { $fssuser = SupportUsers::getUser($handler); $juser = JFactory::getUser($handler); if ($juser->get('isRoot') && $userid != $juser->id) { unset($handlers[$offset]); } } } if (count($handlers) == 0) { $handlers[] = 0; } $qry = "SELECT * FROM #__users WHERE id IN (" . implode(", ", $handlers) . ")"; $db = JFactory::getDBO(); $db->setQuery($qry); $handlers = $db->loadAssocList(); $this->handlers = array(); $h = array(); $h['id'] = 0; $h['name'] = JText::_('AUTO_ASSIGN'); $this->handlers[] = $h; if (is_array($handlers)) { foreach ($handlers as $handler) { $this->handlers[] = $handler; } } } $this->assign('deptid', $deptid); $this->product = $this->get('Product'); $this->dept = $this->get('Department'); $this->cats = $this->get('Cats'); $this->pris = $this->get('Priorities'); $this->support_user_attach = FSS_Settings::get('support_user_attach'); $this->fields = FSSCF::GetCustomFields(0, $prodid, $deptid); // load in captch and display if needed $this->sortCaptchaType(); $captcha = new FSS_Captcha(); $this->captcha = $captcha->GetCaptcha('support_captcha_type'); parent::display(); }
static function Ticket_To_Admins($mailer, &$ticket) { // add the actual assigned ticket handler if ($ticket['admin_id'] > 0) { $mailer->AddUserAddress($ticket['admin_id'], null, 'addTo', 'Admin: Ticket Admin ID'); } else { // no assigned handler, so use the unassigned email list $mailer->AddMultiAddress(FSS_Settings::get('support_email_unassigned'), 'addTo', 'Admin: Unassigned ticket setting'); } // if email all admins is set if (FSS_Settings::get('support_email_all_admins') && !(FSS_Settings::get('support_email_all_admins_only_unassigned') && $ticket['admin_id'] > 0)) { // Build a list of all available ticket handlers $mailer->AddUserAddress(SupportUsers::getHandlersTicket($ticket['prod_id'], $ticket['ticket_dept_id'], $ticket['ticket_cat_id'], FSS_Settings::get('support_email_all_admins_ignore_auto'), FSS_Settings::get('support_email_all_admins_can_view'), true), null, 'addTo', 'Admin: All admins setting'); } // any cc emails need adding $mailer->AddMultiAddress(FSS_Settings::get('support_email_admincc'), 'addTo', 'Admin: CC all setting'); // any admins that are cc'd on the ticket $db = JFactory::getDBO(); $qry = "SELECT user_id FROM #__fss_ticket_cc as c LEFT JOIN #__users as u ON c.user_id = u.id WHERE ticket_id = " . $ticket['id'] . " AND isadmin = 1"; $db->setQuery($qry); $mailer->AddUserAddress($db->loadObjectList(), 'user_id', 'addTo', 'Admin: CCd on ticket'); }