示例#1
0
 static function loadUser($userid)
 {
     if (empty(self::$user_perms[$userid])) {
         $user_data = SupportUsers::getUser($userid);
         if (!$user_data) {
             $perms = new stdClass();
         } else {
             $perms = $user_data->rules;
         }
         if (!is_object($perms)) {
             $perms = new stdClass();
         }
         if (!property_exists($perms, "support_admin")) {
             $perms->support_admin = new stdClass();
         }
         self::mergeSet($perms, "support_admin", "support_admin_misc");
         self::mergeSet($perms, "support_admin", "support_admin_ticket");
         self::mergeSet($perms, "support_admin", "support_admin_ticket_cc");
         self::mergeSet($perms, "support_admin", "support_admin_ticket_other");
         self::mergeSet($perms, "support_admin", "support_admin_ticket_una");
         self::mergeSet($perms, "support_admin", "view_products");
         self::mergeSet($perms, "support_admin", "view_departments");
         self::mergeSet($perms, "support_admin", "view_categories");
         self::mergeSet($perms, "support_admin", "assign_products");
         self::mergeSet($perms, "support_admin", "assign_departments");
         self::mergeSet($perms, "support_admin", "assign_categories");
         self::$user_perms[$userid] = $perms;
     }
     return self::$user_perms[$userid];
 }
示例#2
0
 function display($tpl = NULL)
 {
     // view a ticket!
     $this->ticketid = FSS_Input::getInt('ticketid');
     $document = JFactory::getDocument();
     $document->addScript(JURI::root() . 'components/com_fss/assets/js/bootstrap/bootstrap-timepicker.min.js');
     $this->ticket = new SupportTicket();
     if (!$this->ticket->load($this->ticketid)) {
         if ($this->ticket->checkExist($this->ticketid)) {
             return $this->_display("noperm");
         } else {
             return JError::raiseWarning(404, JText::_('Ticket not found'));
         }
     }
     if ($this->ticket->merged > 0 && FSS_Input::getInt('no_redirect') != '1') {
         JFactory::getApplication()->redirect(FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $this->ticket->merged . "&Itemid=" . FSS_Input::getInt('Itemid'), false));
     }
     $reverse = JRequest::getInt('sort', null);
     if ($reverse !== null) {
         if ($reverse) {
             // we want messages in opposite order to normal
             if (SupportUsers::getSetting("reverse_order")) {
                 $reverse = true;
             } else {
                 $reverse = false;
             }
         } else {
             // we want messages in normal order
             $reverse = null;
         }
     }
     $this->ticket->loadAll($reverse);
     $this->loadMerged();
     $pathway = JFactory::getApplication()->getPathway();
     $pathway->addItem(JText::_("SUPPORT"), FSSRoute::_('index.php?option=com_fss&view=admin_support&tickets=' . $this->ticket_view));
     $pathway->addItem(JText::_("VIEW_TICKET") . " : " . $this->ticket->reference . " - " . $this->ticket->title);
     $this->assignOnOpen();
     $this->tryLock();
     if ($this->ticket->admin_id > 0) {
         $this->adminuser = SupportUsers::getUser($this->ticket->admin_id);
     }
     $this->ticket_view = $this->ticket->ticket_status_id;
     $this->HandleRefresh();
     if (FSS_Settings::get('time_tracking') == "auto") {
         $session = JFactory::getSession();
         $session->set('ticket_' . $this->ticket->id . "_opened", time());
     }
     FSS_Helper::IncludeModal();
     FSS_Helper::AddSCEditor();
     $this->HandleRefresh();
     $this->print = FSS_Input::getCmd('print');
     if ($this->print) {
         return $this->_display("print");
     }
     $this->_display();
 }
示例#3
0
 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();
 }