Ejemplo n.º 1
0
 function searchTickets()
 {
     FSS_Helper::IncludeModal();
     FSS_Helper::AllowCache();
     $this->ticket_count = 0;
     $this->refresh = 0;
     $this->do_refresh = 0;
     $pathway = JFactory::getApplication()->getPathway();
     $pathway->addItem(JText::_("SUPPORT"), FSSRoute::_('index.php?option=com_fss&view=admin_support&tickets=' . $this->ticket_view, false));
     $pathway->addItem(JText::_("SEARCH_RESULTS"));
     $tags = FSS_Input::getString('tags');
     $tags = trim($tags, ';');
     if ($tags) {
         $tags = explode(";", $tags);
         $this->tags = $tags;
     }
     $this->ticket_list = new SupportTickets();
     $this->ticket_list->limitstart = $this->limitstart;
     $this->ticket_list->limit = $this->limit;
     $this->ticket_list->loadTicketsBySearch();
     $this->ticket_count = $this->ticket_list->ticket_count;
     $this->pagination = new JPaginationJS($this->ticket_count, $this->limitstart, $this->limit);
     $this->displayTicketList();
 }
Ejemplo n.º 2
0
 function searchArticles()
 {
     $mainframe = JFactory::getApplication();
     $aparams = FSS_Settings::GetViewSettingsObj('kb');
     $search = FSS_Input::getString('kbsearch', '');
     $prodid = FSS_Input::getInt('prodid');
     $catid = FSS_Input::getInt('catid');
     $this->assign('cat_art_pages', $aparams->get('cat_art_pages', 0));
     $search = FSS_Input::getString('kbsearch');
     $this->assign('view_mode', $aparams->get('cat_cat_arts'));
     $document = JFactory::getDocument();
     $document->setTitle(JText::_("KNOWLEDGE_BASE") . ' - ' . JText::_("SEARCH_RESULTS"));
     $pagination = $this->get('ArtPaginationSearch');
     $this->pagination = $pagination;
     $this->assign('limit', $this->get("ArtLimit"));
     $this->product = $this->get("Product");
     $this->cat = $this->get("Cat");
     $this->results = $this->get("ArtsWhat");
     $this->search = $search;
     $pathway = $mainframe->getPathway();
     if (FSS_Helper::NeedBaseBreadcrumb($pathway, array('view' => 'kb'))) {
         $pathway->addItem(JText::_('KNOWLEDGE_BASE'), FSSRoute::_('index.php?option=com_fss&view=kb'));
     }
     $pathway->addItem(JText::_("SEARCH_RESULTS"));
     FSS_Helper::AllowCache();
     parent::display("kbsearch");
 }
Ejemplo n.º 3
0
 function &getTickets()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $userid = $user->get('id');
     $uidlist = $this->getUIDS($userid);
     $tidlist = $this->getTIDS($userid);
     $query = "SELECT t.*, s.title as status, s.color, u.name, au.name as assigned, u.email as useremail, u.username as username, au.email as handleremail, au.username as handlerusername, ";
     $query .= " dept.title as department, cat.title as category, prod.title as product, pri.title as priority, pri.color as pricolor, ";
     $query .= " grp.groupname as groupname, grp.id as group_id ";
     $query .= " , pri.translation as ptl, dept.translation as dtr, s.translation as str, cat.translation as ctr, prod.translation as prtr";
     $query .= " FROM #__fss_ticket_ticket as t ";
     $query .= " LEFT JOIN #__fss_ticket_status as s ON t.ticket_status_id = s.id ";
     $query .= " LEFT JOIN #__users as u ON t.user_id = u.id ";
     $query .= " LEFT JOIN #__users as au ON t.admin_id = au.id ";
     $query .= " LEFT JOIN #__fss_ticket_dept as dept ON t.ticket_dept_id = dept.id ";
     $query .= " LEFT JOIN #__fss_ticket_cat as cat ON t.ticket_cat_id = cat.id ";
     $query .= " LEFT JOIN #__fss_prod as prod ON t.prod_id = prod.id ";
     $query .= " LEFT JOIN #__fss_ticket_pri as pri ON t.ticket_pri_id = pri.id ";
     $query .= " LEFT JOIN (SELECT group_id, user_id FROM #__fss_ticket_group_members GROUP BY user_id) as mem ON t.user_id = mem.user_id ";
     $query .= " LEFT JOIN #__fss_ticket_group as grp ON grp.id = mem.group_id ";
     // add product, department and category
     $query .= " WHERE ( t.user_id IN (" . implode(", ", $uidlist) . ") OR t.id IN (" . implode(", ", $tidlist) . ") ) ";
     $query .= " AND " . SupportSource::user_list_sql();
     $tickets = FSS_Input::getCmd('tickets', 'open');
     if (FSS_Settings::get('support_simple_userlist_tabs')) {
         $tickets = "all";
     }
     if (FSS_Input::getCmd('search_all')) {
         $tickets = "";
     }
     if ($tickets == 'open') {
         $allopen = FSS_Ticket_Helper::GetStatusIDs("is_closed", true);
         // tickets that arent closed
         $query .= " AND ticket_status_id IN ( " . implode(", ", $allopen) . ") ";
     }
     if ($tickets == 'closed') {
         $allopen = FSS_Ticket_Helper::GetStatusIDs("is_closed");
         // remove the archived tickets from the list to deal with
         $def_archive = FSS_Ticket_Helper::GetStatusID('def_archive');
         foreach ($allopen as $offset => $value) {
             if ($value == $def_archive) {
                 unset($allopen[$offset]);
             }
         }
         // tickets that are closed
         $query .= " AND ticket_status_id IN ( " . implode(", ", $allopen) . ") ";
     } else {
         if ($tickets > 0) {
             $statuss = SupportHelper::getStatuss(false);
             $status_list = array();
             $status_list[] = (int) $tickets;
             foreach ($statuss as $status) {
                 if ($status->combine_with == (int) $tickets) {
                     $status_list[] = $status->id;
                 }
             }
             $query .= " AND ticket_status_id IN (" . implode(", ", $status_list) . ")";
         }
     }
     $search = FSS_Input::getString('search');
     if ($search != "") {
         FSS_Helper::AllowCache();
         // We have the nearly full query here, so use it to get a list of ticket ids
         $db->setQuery($query);
         $recs = $db->loadObjectList();
         $ids = array();
         $ids[] = 0;
         foreach ($recs as $rec) {
             $ids[] = $rec->id;
         }
         $mode = "";
         if (FSS_Helper::contains($search, array('*', '+', '-', '<', '>', '(', ')', '~', '"'))) {
             $mode = "IN BOOLEAN MODE";
         }
         $msgsrch = "SELECT ticket_ticket_id FROM #__fss_ticket_messages WHERE ticket_ticket_id IN (" . implode(", ", $ids) . ") AND admin < 3 AND ";
         $msgsrch .= " MATCH (body) AGAINST ('" . $db->escape($search) . "' {$mode}) ";
         $db->setQuery($msgsrch);
         $results = $db->loadObjectList();
         $ids = array();
         $ids[] = 0;
         foreach ($results as $rec) {
             $ids[] = $rec->ticket_ticket_id;
         }
         // search custom fields that are set to be searched
         $fields = FSSCF::GetAllCustomFields(true);
         foreach ($fields as $field) {
             if (!$field["basicsearch"]) {
                 continue;
             }
             if ($field['permissions'] > 1 && $field['permissions'] < 5) {
                 continue;
             }
             $fieldid = $field['id'];
             if ($field['type'] == "checkbox") {
                 if ($search == "1") {
                     $search = "on";
                 } else {
                     $search = "";
                 }
             }
             if ($field['peruser']) {
                 continue;
             }
             if ($field['type'] == "plugin") {
                 // try to do a plugin based search
                 $data = array();
                 foreach ($field['values'] as $item) {
                     list($key, $value) = explode("=", $item, 2);
                     $data[$key] = $value;
                 }
                 if (array_key_exists("plugin", $data)) {
                     $plugins = FSSCF::get_plugins();
                     if (array_key_exists($data['plugin'], $plugins)) {
                         $po = $plugins[$data['plugin']];
                         if (method_exists($po, "Search")) {
                             $res = $po->Search($data['plugindata'], $search, false, false);
                             if ($res !== false) {
                                 foreach ($res as $item) {
                                     $ids[] = (int) $item->ticket_id;
                                 }
                                 continue;
                             }
                         }
                     }
                 }
             }
             $qry = "SELECT ticket_id FROM #__fss_ticket_field WHERE field_id = '" . FSSJ3Helper::getEscaped($db, $fieldid) . "' AND value LIKE '%" . FSSJ3Helper::getEscaped($db, $search) . "%'";
             $db->setQuery($qry);
             $data = $db->loadObjectList();
             foreach ($data as $item) {
                 $id = (int) $item->ticket_id;
                 if ($id > 0) {
                     $ids[] = $id;
                 }
             }
         }
         //"MATCH (question, answer) AGAINST ('" . $db->escape($search) . "')"
         $query .= " AND ( t.id IN (" . implode(", ", $ids) . ") OR MATCH (t.title) AGAINST ('" . $db->escape($search) . "' {$mode}) OR t.reference LIKE '%" . $db->escape($search) . "%' ) ";
     }
     $order = FSS_Input::getCmd('order');
     $order_dir = FSS_Input::getCmd('order_dir', 'asc');
     $order_dir_allowed = array('asc', 'desc');
     if (!in_array($order_dir, $order_dir_allowed)) {
         $order_dir = 'asc';
     }
     $order_allowed = array('t.title', 'lastupdate', 'status', 'assigned', 'lastupdate', 'u.name');
     if (!in_array($order, $order_allowed)) {
         $order = '';
     }
     if ($order != "") {
         $query .= " ORDER BY {$order} {$order_dir}";
     } else {
         $query .= " ORDER BY lastupdate DESC ";
     }
     $mainframe = JFactory::getApplication();
     $limit = $mainframe->getUserStateFromRequest('global.list.limit_ticket', 'limit', FSS_Settings::Get('ticket_per_page'), 'int');
     $limitstart = FSS_Input::getInt('limitstart');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $db->setQuery($query);
     $db->query();
     //echo $query . "<br>";
     $count = $db->getNumRows();
     $result['pagination'] = new JPaginationJs($count, $limitstart, $limit);
     $db->setQuery($query, $limitstart, $limit);
     $result['tickets'] = $db->loadObjectList();
     foreach ($result['tickets'] as &$ticket) {
         $fields = FSSCF::GetCustomFields($ticket->id, $ticket->prod_id, $ticket->ticket_dept_id);
         $values = FSSCF::GetTicketValues($ticket->id, $ticket);
         $ticket->fields = array();
         foreach ($fields as &$field) {
             $ticket->fields[$field['id']] = array();
             $ticket->fields[$field['id']]['name'] = $field['description'];
             $ticket->fields[$field['id']]['value'] = '';
             if (isset($values[$field['id']])) {
                 $ticket->fields[$field['id']]['value'] = $values[$field['id']]['value'];
             }
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 function display($tpl = null)
 {
     if (!FSS_Permission::auth("fss.view", "com_fss.faq")) {
         return FSS_Helper::NoPerm();
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'content' . DS . 'faqs.php';
     $this->content = new FSS_ContentEdit_FAQs();
     $this->content->Init();
     $model = $this->getModel();
     $model->content = $this->content;
     $mainframe = JFactory::getApplication();
     $faqid = FSS_Input::getInt('faqid');
     $aparams = FSS_Settings::GetViewSettingsObj('faqs');
     if ($faqid > 0) {
         $tmpl = FSS_Input::getCmd('tmpl');
         $this->tmpl = $tmpl;
         $this->setLayout("faq");
         $faq = $this->get("Faq");
         $this->faq = $faq;
         if (!$this->faq) {
             return JError::raiseWarning(404, JText::_('FAQ NOT FOUND'));
         }
         $pathway = $mainframe->getPathway();
         if (FSS_Helper::NeedBaseBreadcrumb($pathway, array('view' => 'faq'))) {
             $pathway->addItem(JText::_('FREQUENTLY_ASKED_QUESTIONS'), FSSRoute::_('index.php?option=com_fss&view=faq'));
         }
         $pathway->addItem($faq['title'], FSSRoute::_('&limitstart=&layout=&faqid=&catid=' . $faq['faq_cat_id']));
         // FIX LINK
         $pathway->addItem($faq['question']);
         if (FSS_Settings::get('faq_use_content_plugins')) {
             // apply plugins to article body
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $art = new stdClass();
             $art->text = $faq['answer'];
             $art->noglossary = 1;
             $this->params = $mainframe->getParams('com_fss');
             $results = $dispatcher->trigger('onContentPrepare', array('com_fss.faq', &$art, &$this->params, 0));
             $faq['answer'] = $art->text;
         }
         // load tags
         $db = JFactory::getDBO();
         $qry = "SELECT * FROM #__fss_faq_tags WHERE faq_id IN (" . FSSJ3Helper::getEscaped($db, $faqid) . ") GROUP BY tag ORDER BY tag";
         $db->setQuery($qry);
         $rows = $db->loadObjectList();
         $this->tags = array();
         foreach ($rows as &$row) {
             $id = $row->faq_id;
             $this->tags[] = "<a href='" . FSSRoute::_('index.php?option=com_fss&view=faq&tag=' . urlencode($row->tag) . '&Itemid=' . FSS_Input::getInt('Itemid')) . "'>{$row->tag}</a>";
         }
         //$document = JFactory::getDocument();
         //$document->setTitle(JText::_("FAQS") . ' - ' . $faq['title']);
         if (FSS_Input::getCmd('tmpl') == "component") {
             return parent::display("popup");
         }
         parent::display();
         return;
     }
     $pathway = $mainframe->getPathway();
     if (FSS_Helper::NeedBaseBreadcrumb($pathway, array('view' => 'faq'))) {
         $pathway->addItem(JText::_('FREQUENTLY_ASKED_QUESTIONS'), FSSRoute::_('index.php?option=com_fss&view=faq'));
     }
     $hide_allfaqs = $aparams->get('hide_allfaqs', 0);
     $show_featured = $aparams->get('show_featured', 0);
     $hide_tags = $aparams->get('hide_tags', 0);
     $hide_search = $aparams->get('hide_search', 0);
     $view_mode = $aparams->get('view_mode', 'questionwithpopup');
     $view_mode_cat = $aparams->get('view_mode_cat', 'list');
     $view_mode_incat = $aparams->get('view_mode_incat', 'list');
     $enable_pages = $aparams->get('enable_pages', 1);
     $num_cat_colums = $aparams->get('num_cat_colums', 1);
     if ($num_cat_colums < 1 && !$num_cat_colums) {
         $num_cat_colums = 1;
     }
     if ($view_mode_cat != "list") {
         $num_cat_colums = 1;
     }
     $catlist = $this->get("CatList");
     $search = $this->get("Search");
     $curcatdesc = $this->get("CurCatDesc");
     $curcatimage = $this->get("CurCatImage");
     $curcattitle = $this->get("CurCatTitle");
     $curcatid = $this->get("CurCatID");
     // Get data from the model
     if ($curcatid == -4) {
         return $this->listTags();
     }
     if ($curcatid == -5) {
         $curcattitle = "Featured FAQs";
         $curcatimage = "/components/com_fss/assets/images/featured.png";
     }
     $pagination = $this->get('Pagination');
     $model = $this->getModel();
     $search = $model->_search;
     if ($search || $curcatid > 0 || FSS_Input::getInt('catid') != "" || FSS_Input::getString('tag') != "") {
         $view_mode_cat = "";
     }
     if ($search) {
         FSS_Helper::AllowCache();
     }
     $items = array();
     if ($view_mode_cat == "inline" || $view_mode_cat == "accordian") {
         //echo "Getting all data!<br>";
         $alldata = $this->get("AllData");
         if (FSS_Settings::get('faq_use_content_plugins_list')) {
             // apply plugins to article body
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $art = new stdClass();
             foreach ($alldata as &$item) {
                 $art->text = $item['answer'];
                 $art->noglossary = 1;
                 $this->params = $mainframe->getParams('com_fss');
                 $results = $dispatcher->trigger('onContentPrepare', array('com_fss.faq', &$art, &$this->params, 0));
                 $item['answer'] = $art->text;
             }
         }
         foreach ($catlist as &$cat) {
             $catid = $cat['id'];
             foreach ($alldata as $faq) {
                 if ($faq['faq_cat_id'] == $catid) {
                     $cat['faqs'][] = $faq;
                 }
             }
         }
         // inline mode, so if we have featured faqs listed, load the data for those
         $this->featured_faqs = $this->get('FeaturedFaqs');
     } else {
         $items = $this->get('Data');
         if (FSS_Settings::get('faq_use_content_plugins_list')) {
             // apply plugins to article body
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $art = new stdClass();
             foreach ($items as &$item) {
                 $art->text = $item['answer'];
                 $art->noglossary = 1;
                 $this->params =& $mainframe->getParams('com_fss');
                 $results = $dispatcher->trigger('onContentPrepare', array('com_fss.faq', &$art, &$this->params, 0));
                 $item['answer'] = $art->text;
             }
         }
     }
     $showfaqs = true;
     $showcats = true;
     if (FSS_Input::getString('tag') != "") {
         // got tag selected
         $showfaqs = true;
         $showcats = false;
         $curcatid = -2;
         $pathway = $mainframe->getPathway();
         $pathway->addItem(JText::_("TAGS"), FSSRoute::_('index.php?option=com_fss&view=faq&catid=-4&Itemid=' . FSS_Input::getInt('Itemid')));
         $pathway->addItem(FSS_Input::getString('tag'));
         $curcattitle = FSS_Input::getString('tag');
         // do we have a category specified???
     } else {
         if (FSS_Input::getInt('catid', '') == '' && FSS_Input::getInt('search', '') == '') {
             // no cat specified
             $showfaqs = false;
             $curcatid = -2;
         } else {
             // got a cat specced
             $pathway = $mainframe->getPathway();
             $pathway->addItem($curcattitle);
             $showcats = false;
         }
     }
     // load tags
     $faqids = array();
     if ($items && is_array($items)) {
         foreach ($items as &$item) {
             $faqids[] = FSSJ3Helper::getEscaped($db, $item['id']);
         }
     }
     $db = JFactory::getDBO();
     $this->tags = array();
     if (count($faqids) > 0) {
         $qry = "SELECT * FROM #__fss_faq_tags WHERE faq_id IN (" . implode(", ", $faqids) . ") GROUP BY tag ORDER BY tag";
         $db->setQuery($qry);
         $rows = $db->loadObjectList();
         foreach ($rows as $row) {
             $id = $row->faq_id;
             if (!array_key_exists($id, $this->tags)) {
                 $this->tags[$id] = array();
             }
             $this->tags[$id][] = "<a href='" . FSSRoute::_('index.php?option=com_fss&view=faq&tag=' . urlencode($row->tag) . '&Itemid=' . FSS_Input::getInt('Itemid')) . "'>{$row->tag}</a>";
         }
     }
     // hide tags if none have been set
     $qry = "SELECT count(*) as cnt FROM #__fss_faq_tags";
     $db->setQuery($qry);
     $row = $db->loadObject();
     if ($row->cnt == 0) {
         $hide_tags = true;
     }
     $this->catlist = $catlist;
     $this->search = $search;
     $this->curcattitle = $curcattitle;
     $this->curcatimage = $curcatimage;
     $this->curcatdesc = $curcatdesc;
     // push data into the template
     $this->pagination = $pagination;
     $this->items = $items;
     $this->assign('curcatid', $curcatid);
     $this->assign('showcats', $showcats);
     $this->assign('showfaqs', $showfaqs);
     $this->assign('hide_allfaqs', $hide_allfaqs);
     $this->assign('show_featured', $show_featured);
     $this->assign('hide_tags', $hide_tags);
     $this->assign('hide_search', $hide_search);
     $this->assign('view_mode', $view_mode);
     $this->assign('num_cat_colums', $num_cat_colums);
     $this->assign('view_mode_cat', $view_mode_cat);
     $this->assign('view_mode_incat', $view_mode_incat);
     $this->assign('enable_pages', $enable_pages);
     $db = JFactory::getDBO();
     $qry = "SELECT tag FROM #__fss_faq_tags ";
     $qry .= ' WHERE language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')';
     $qry .= "GROUP BY tag ORDER BY tag";
     $db->setQuery($qry);
     $this->all_tags = $db->loadObjectList();
     FSS_Helper::IncludeModal();
     parent::display($tpl);
 }