function getReturnViewOptions($current) { $statuss = SupportHelper::getStatuss(); $temp = new stdClass(); $temp->id = "closed"; $temp->title = JText::_("Closed"); $statuss[] = $temp; $temp = new stdClass(); $temp->id = "allopen"; $temp->title = JText::_("ALL_OPEN"); $statuss[] = $temp; $temp = new stdClass(); $temp->id = "all"; $temp->title = JText::_("All"); $statuss[] = $temp; $output[] = "<option value=''>" . JText::_('SHOW_CURRENT_TICKET') . "</option>"; $output[] = "<optgroup label='" . JText::_('SHOW_TICKET_LIST') . ":'>"; $selected = ""; if ($current == "list_current") { $selected = "selected"; } $output[] = "<option value='list_current' {$selected}>" . JText::_('LIST') . ": " . JText::_('CURRENT_TICKETS_STATUS') . "</option>"; foreach ($statuss as $status) { $selected = ""; if ($current == "list_" . $status->id) { $selected = "selected"; } $output[] = "<option value='list_" . $status->id . "' {$selected}>" . JText::_('LIST') . ": " . $status->title . "</option>"; } $output[] = "</optgroup>"; $output[] = "<optgroup label='" . JText::_('SHOW_NEWEST_TICKET') . ":'>"; $selected = ""; if ($current == "new_current") { $selected = "selected"; } $output[] = "<option value='new_current' {$selected}>" . JText::_('NEWEST') . ": " . JText::_('CURRENT_TICKETS_STATUS') . "</option>"; foreach ($statuss as $status) { $selected = ""; if ($current == "new_" . $status->id) { $selected = "selected"; } $output[] = "<option value='new_" . $status->id . "' {$selected}>" . JText::_('NEWEST') . ": " . $status->title . "</option>"; } $output[] = "</optgroup>"; $output[] = "<optgroup label='" . JText::_('SHOW_OLDEST_TICKET') . ":'>"; $selected = ""; if ($current == "old_current") { $selected = "selected"; } $output[] = "<option value='old_current' {$selected}>" . JText::_('OLDEST') . ": " . JText::_('CURRENT_TICKETS_STATUS') . "</option>"; foreach ($statuss as $status) { $selected = ""; if ($current == "old_" . $status->id) { $selected = "selected"; } $output[] = "<option value='old_" . $status->id . "' {$selected}>" . JText::_('OLDEST') . ": " . $status->title . "</option>"; } $output[] = "</optgroup>"; return implode($output); }
function download() { // load in tickets to do $ticketid = FSS_Input::getInt('ticketid'); $fileid = FSS_Input::getInt('fileid'); SupportHelper::attachDownload($ticketid, $fileid); }
function adminSupportTabs_End() { $output = ""; $departments = SupportHelper::getDepartments(); $class = ""; foreach ($departments as $dept) { $class = ""; if (JRequest::getVar('department') == $dept->id) { $class = "active"; } $output[] = '<li class="' . $class . '">'; $output[] = '<a href="' . JRoute::_('index.php?option=com_fss&view=admin_support&what=search&searchtype=advanced&showbasic=1&department=' . $dept->id) . '">'; $output[] = $dept->title; $output[] = ' </a>'; $output[] = '</li> '; } return implode("\n", $output); }
function display($tpl = null) { if (FSS_Settings::Get('support_only_admin_open')) { return $this->noPermission("Access Denied", "CREATING_NEW_TICKETS_BY_USERS_IS_CURRENTLY_DISABLED"); } 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->assign('userid', $userid); $this->assign('email', ''); // defaults for blank ticket $this->ticket = new stdClass(); $this->ticket->prodid = FSS_Input::getInt('prodid'); $this->ticket->deptid = FSS_Input::getInt('deptid'); $this->ticket->catid = FSS_Input::getInt('catid'); $this->ticket->priid = FSS_Input::getInt('priid'); $this->ticket->subject = FSS_Input::getString('subject'); $this->ticket->body = FSS_Input::getBBCode('body'); $this->errors['subject'] = ''; $this->errors['body'] = ''; $this->errors['cat'] = ''; $what = FSS_Input::getCmd('what'); // done with ticket, try and save, if not, display any errors if ($what == "add") { if ($this->saveTicket()) { echo "Saved OK!"; exit; $link = 'index.php?option=com_fss&view=ticket&layout=view&Itemid=' . FSS_Input::getInt('Itemid') . '&ticketid=' . $this->ticketid; $mainframe->redirect($link); return; } } $this->product = $this->get('Product'); $this->dept = $this->get('Department'); $this->cats = SupportHelper::getCategories(); $this->pris = SupportHelper::getPriorities(); $this->support_user_attach = FSS_Settings::get('support_user_attach'); $this->fields = FSSCF::GetCustomFields(0, $prodid, $deptid); parent::display(); }
function ticket_status_id() { // update status in ticket // redirect if the config is set to $ticketid = FSS_Input::getInt('ticketid'); $ticket_status_id = FSS_Input::getInt('ticket_status_id'); if ($ticketid < 1) { exit; } if ($ticket_status_id < 1) { exit; } $link = FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticketid, false); // check permission for new status $statuss = SupportHelper::getStatuss(); $new_status = $statuss[$ticket_status_id]; if ($new_status->is_closed && !$this->view->can_Close()) { JFactory::getApplication()->redirect($link); exit; } $ticket = new SupportTicket(); if ($ticket->Load($ticketid)) { $old_st = $ticket->getStatus(); $ticket->updateStatus($ticket_status_id); $new_st = $ticket->getStatus(); // if we have closed the ticket, and return on close is set, then we should do a redirect dependant on the setting if ($new_st->is_closed && SupportUsers::getSetting("return_on_close")) { $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_close")); } if ($new_st->is_closed && !$old_st->is_closed) { // SEND CLOSED EMAIL HERE! if (!FSS_Settings::get('support_email_on_close_no_dropdown')) { FSS_EMail::Admin_Close($ticket, $ticket->title, '', array()); } } } JFactory::getApplication()->redirect($link); exit; }
static function prep_custom_rules($form, $field_id, $type, $key, $label) { $xml = '<field name="' . $field_id . '" type="fssrules" label="" translate_label="false" class="inputbox" filter="rules" component="com_fss" section="" validate="rules" tab_id="' . $label . '">'; switch ($type) { case 'products': $items = SupportHelper::getProducts(); break; case 'departments': $items = SupportHelper::getDepartments(); break; case 'categories': $items = SupportHelper::getCategories(); break; case 'reports': $xml .= '<action name="fss.reports" title="VIEW_REPORTS" description="" />'; $xml .= '<action name="fss.reports.all" title="VIEW_ALL_REPORTS" description="" />'; $items = self::getReports(); break; } $first = true; foreach ($items as $item) { if ($type == "reports" && $first) { $xml .= '<action name="' . $key . '.' . htmlspecialchars($item->id) . '" title="' . htmlspecialchars($item->title) . '" description="" heading="Reports" />'; $first = false; } else { $xml .= '<action name="' . $key . '.' . htmlspecialchars($item->id) . '" title="' . htmlspecialchars($item->title) . '" description="" />'; } } $xml .= '</field>'; $field = new JFormFieldRules(); $field = $form->getField("{$field_id}"); $field->setup(simplexml_load_string($xml), $form->getValue($field_id)); return $field; }
function loadPDC() { $this->products = SupportHelper::getProducts(); $this->departments = SupportHelper::getDepartments(); $this->categories = SupportHelper::getCategories(); $prods = array(); $prods[] = JHTML::_('select.option', '0', JText::_("SELECT_PRODUCT"), 'id', 'title'); $prods = array_merge($prods, $this->products); $this->products_select = JHTML::_('select.genericlist', $prods, 'prodid', 'class="input-medium" size="1" onchange="document.mainform.submit( );"', 'id', 'title', $this->prodid); $depts = array(); $depts[] = JHTML::_('select.option', '0', JText::_("SELECT_DEPARTMENT"), 'id', 'title'); $depts = array_merge($depts, $this->departments); $this->departments_select = JHTML::_('select.genericlist', $depts, 'deptid', 'class="input-medium" size="1" onchange="document.mainform.submit( );"', 'id', 'title', $this->deptid); $cats = array(); $cats[] = JHTML::_('select.option', '0', JText::_("SELECT_CATEGORY"), 'id', 'title'); $cats = array_merge($cats, $this->categories); $this->categories_select = JHTML::_('select.genericlist', $cats, 'catid', 'class="input-medium" size="1" onchange="document.mainform.submit( );"', 'id', 'title', $this->catid); $modes = array(); $modes[] = JHTML::_('select.option', '0', JText::_("VIEW_TICKETS"), 'id', 'title'); $modes[] = JHTML::_('select.option', '1', JText::_("ASSIGN_TICKETS"), 'id', 'title'); $this->mode_select = JHTML::_('select.genericlist', $modes, 'mode', 'class="input-medium" size="1" onchange="document.mainform.submit( );"', 'id', 'title', $this->mode); $this->statuss = SupportHelper::getStatuss(); FSS_Translate_Helper::Tr($this->statuss); $this->status_select = JHTML::_('select.genericlist', $this->statuss, 'status', 'class="input-medium hide" size="1" onchange="document.mainform.submit( );" id="cur_status"', 'id', 'title', $this->status); $this->status_obj = FSS_Ticket_Helper::GetStatusByID($this->status); FSS_Translate_Helper::TrSingle($this->status_obj); }
static function getDepartment($ticket) { $depts = SupportHelper::getDepartments(false); if (array_key_exists($ticket->ticket_dept_id, $depts)) { return $depts[$ticket->ticket_dept_id]; } return null; }
static function getAdminWhere() { $user = self::getUser(); if (!FSS_Permission::auth("fss.handler", "com_fss.support_admin")) { return "0"; } // can always view own tickets $where = " (t.admin_id = {$user->id} OR "; $where .= " t.id IN (SELECT ticket_id FROM #__fss_ticket_cc WHERE user_id = {$user->id} AND isadmin = 1) OR "; $where .= " ("; // now need to filter by handler. we have several and sections here $inner = array(); // users $can_see_unassigned = FSS_Permission::auth("fss.handler.seeunassigned", "com_fss.support_admin"); $can_see_others = FSS_Permission::auth("fss.handler.seeothers", "com_fss.support_admin"); if (!$can_see_unassigned && !$can_see_others) { $inner[] = "0"; } elseif (!$can_see_unassigned && $can_see_others) { // only others, not unassigned $inner[] = "t.admin_id > 0"; } elseif ($can_see_unassigned && !$can_see_others) { $inner[] = "t.admin_id = 0"; } // products if (!FSS_Permission::auth("fss.handler.view.products", "com_fss.support_admin")) { $prod_ids = array(); $prod_ids[0] = "0"; $products = SupportHelper::getProducts(); foreach ($products as $product) { if (FSS_Permission::auth("fss.handler.view.product." . $product->id, "com_fss.support_admin")) { $prod_ids[$product->id] = $product->id; } } $inner[] = " t.prod_id IN (" . implode(", ", $prod_ids) . ")"; } // departments if (!FSS_Permission::auth("fss.handler.view.departments", "com_fss.support_admin")) { $dept_ids = array(); $dept_ids[0] = "0"; $depts = SupportHelper::getDepartments(); foreach ($depts as $dept) { if (FSS_Permission::auth("fss.handler.view.department." . $dept->id, "com_fss.support_admin")) { $dept_ids[$dept->id] = $dept->id; } } $inner[] = " t.ticket_dept_id IN (" . implode(", ", $dept_ids) . ")"; } // categories if (!FSS_Permission::auth("fss.handler.view.categories", "com_fss.support_admin")) { $cat_ids = array(); $cat_ids[0] = "0"; $cats = SupportHelper::getCategories(); foreach ($cats as $cat) { if (FSS_Permission::auth("fss.handler.view.category." . $cat->id, "com_fss.support_admin")) { $cat_ids[$cat->id] = $cat->id; } } $inner[] = " t.ticket_cat_id IN (" . implode(", ", $cat_ids) . ")"; } if (count($inner) == 0) { $inner[] = "1"; } $where .= implode(" AND ", $inner); $where .= " ))"; return $where; }
<label class="control-label"><?php echo JText::_("PRIORITY"); ?> </label> <div class="controls"> <select name="batch_priority"> <option value=""><?php echo JText::_('UNCHANGED'); ?> </option> <optgroup label="<?php echo JText::_('NEW_PRIORITY_'); ?> "> <?php $pri_list = SupportHelper::getPriorities(); foreach ($pri_list as $pri) { echo "<option value='{$pri->id}' style='color: {$pri->color};'>{$pri->title}</option>"; } ?> </optgroup> </select> </div> </div> <div class="control-group batch_print_hide"> <label class="control-label"><?php echo JText::_("HANDLER"); ?> </label>
function FixTicketStatus() { $statuss = SupportHelper::getStatuss(false); $cur_status = $statuss[$this->ticket['ticket_status_id']]; if ($cur_status->combine_with > 0) { $new_status = $statuss[$cur_status->combine_with]; $this->ticket['scolor'] = $new_status->color; $this->ticket['status'] = $new_status->title; if ($new_status->userdisp) { $this->ticket['status'] = $new_status->userdisp; } $this->ticket['ticket_status_id'] = $new_status->id; } else { if ($cur_status->userdisp) { $this->ticket['status'] = $cur_status->userdisp; } } }
static function &ParseTemplate($template, &$ticket, $subject, $body, $ishtml, $foruser = false) { $handler = self::GetHandler($ticket['admin_id'], $template['tmpl']); $custrec = self::GetUser($ticket['user_id']); $subject = trim(str_ireplace("re:", "", $subject)); $vars[] = self::BuildVar('subject', $subject); $body = FSS_Helper::ParseBBCode($body, null, false, false, $foruser); $body = str_replace("<", "XXXLTXXX", $body); $body = str_replace(">", "XXXGTXXX", $body); $vars[] = self::BuildVar('body', $body); $vars[] = self::BuildVar('reference', $ticket['reference']); $vars[] = self::BuildVar('password', $ticket['password']); foreach (self::$extra_vars as $key => $value) { $vars[] = self::BuildVar($key, $value); } if ($ticket['user_id'] == 0) { $vars[] = self::BuildVar('user_name', $ticket['unregname']); $vars[] = self::BuildVar('user_username', JText::_("UNREGISTERED")); $vars[] = self::BuildVar('user_email', $ticket['email']); } else { $vars[] = self::BuildVar('user_name', $custrec['name']); $vars[] = self::BuildVar('user_username', $custrec['username']); $vars[] = self::BuildVar('user_email', $custrec['email']); } $vars[] = self::BuildVar('handler_name', $handler['name']); $vars[] = self::BuildVar('handler_username', $handler['username']); $vars[] = self::BuildVar('handler_email', $handler['email']); $vars[] = self::BuildVar('ticket_id', $ticket['id']); if ($foruser) { $statuss = SupportHelper::getStatuss(false); $status = $statuss[$ticket['ticket_status_id']]; if ($status->combine_with > 0) { $status = $statuss[$status->combine_with]; } FSS_Translate_Helper::TrO($status); $text = $status->title; if ($status->userdisp) { $text = $status->userdisp; } $vars[] = self::BuildVar('status', $text); } else { $vars[] = self::BuildVar('status', self::GetStatus($ticket['ticket_status_id'])); } $vars[] = self::BuildVar('priority', self::GetPriority($ticket['ticket_pri_id'])); $vars[] = self::BuildVar('category', self::GetCategory($ticket['ticket_cat_id'])); $vars[] = self::BuildVar('department', self::GetDepartment($ticket['ticket_dept_id'])); $vars[] = self::BuildVar('department_desc', strip_tags(self::GetDepartment($ticket['ticket_dept_id'], 'description'))); $vars[] = self::BuildVar('department_desc_html', self::GetDepartment($ticket['ticket_dept_id'], 'description')); $vars[] = self::BuildVar('product', self::GetProduct($ticket['prod_id'])); $vars[] = self::BuildVar('product_desc', strip_tags(self::GetProduct($ticket['prod_id'], 'description'))); $vars[] = self::BuildVar('product_desc_html', self::GetProduct($ticket['prod_id'], 'description')); if (strpos($template['body'], "{messagehistory}") > 0) { $messages = self::GetMessageHist($ticket['id']); $text = self::ParseMessageRows($messages, $ishtml, $foruser); $vars[] = self::BuildVar('messagehistory', $text); } $uri = JURI::getInstance(); $baseUrl = FSS_Settings::get('support_email_no_domain') ? "" : $uri->toString(array('scheme', 'host', 'port')); if (in_array(FSS_Settings::get('support_unreg_type'), array(0, 1))) { $vars[] = self::BuildVar('haspassword', 1); } else { $vars[] = self::BuildVar('haspassword', 0); } // choose which user link to generate if ($ticket['user_id'] < 1) { // unregistered user $url = 'index.php?option=com_fss&t=' . $ticket['id'] . "&p=" . $ticket['password']; if (FSS_Settings::get('support_email_link_unreg') > 0) { // add fixed item id if needed $url .= "&Itemid=" . FSS_Settings::get('support_email_link_unreg'); } $vars[] = self::BuildVar('ticket_link', $baseUrl . JRoute::_($url, false)); } else { // registered user $url = 'index.php?option=com_fss&view=ticket&layout=view&ticketid=' . $ticket['id']; if (FSS_Settings::get('support_email_include_autologin')) { $url .= "&login={login_code}"; } if (FSS_Settings::get('support_email_link_reg') > 0) { // add fixed item id if needed $url .= "&Itemid=" . FSS_Settings::get('support_email_link_reg'); } $vars[] = self::BuildVar('ticket_link', $baseUrl . JRoute::_($url, false)); } // ticket admin link $url = 'index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket['id']; if (FSS_Settings::get('support_email_link_admin') > 0) { // add fixed item id if needed $url .= "&Itemid=" . FSS_Settings::get('support_email_link_admin'); } $vars[] = self::BuildVar('admin_link', $baseUrl . JRoute::_($url, false)); // email pending link $url = 'index.php?option=com_fss&view=admin_support&layout=emails'; if (FSS_Settings::get('support_email_link_pending') > 0) { // add fixed item id if needed $url .= "&Itemid=" . FSS_Settings::get('support_email_link_pending'); } $vars[] = self::BuildVar('email_pending_link', $baseUrl . JRoute::_($url, false)); $vars[] = self::BuildVar('websitetitle', FSS_Helper::getSiteName()); // need to add the tickets custom fields to the output here $fields = FSSCF::GetAllCustomFields(true); $values = FSSCF::GetTicketValues($ticket['id'], $ticket); foreach ($fields as $fid => &$field) { $name = "custom_" . $fid; $value = ""; if (array_key_exists($fid, $values)) { $value = (string) $values[$fid]['value']; } $fieldvalues = array(); $fieldvalues[0]['field_id'] = $fid; $fieldvalues[0]['value'] = $value; // only do area output processing if we are in html mode if ($field['type'] != "area" || $ishtml) { $newvalue = FSSCF::FieldOutput($field, $fieldvalues, ''); if ($newvalue) { $value = $newvalue; } } $vars[] = self::BuildVar($name, $value); $vars[] = self::BuildVar("custom_" . $field['alias'], $value); } $email['subject'] = self::ParseText($template['subject'], $vars); $email['body'] = self::ParseText($template['body'], $vars); self::$last_vars = $vars; if ($template['ishtml']) { $email['body'] = FSS_Helper::MaxLineLength($email['body']); } else { $email['body'] = str_replace("<br />", "\n", $email['body']); $email['body'] = html_entity_decode($email['body']); $email['body'] = preg_replace_callback("/(&#[0-9]+;)/", array("FSS_Helper", "email_decode_utf8"), $email['body']); $email['body'] = strip_tags($email['body']); } $email['body'] = str_replace("XXXLTXXX", "<", $email['body']); $email['body'] = str_replace("XXXGTXXX", ">", $email['body']); return $email; }
<?php /** * @package Freestyle Joomla * @author Freestyle Joomla * @copyright (C) 2013 Freestyle Joomla * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html **/ defined('_JEXEC') or die; $alltags = SupportHelper::getTags(); ?> <?php foreach ($alltags as $tag) { ?> <li> <a href='#' onclick="tag_add(jQuery(this).text());return false;"><?php echo $tag->tag; ?> </a> </li> <?php } ?> <?php if (count($alltags) > 0) { ?> <li class="divider"></li> <?php }
function getStatus() { $statuss = SupportHelper::getStatuss(false); return $statuss[$this->ticket_status_id]; }
<label class="control-label"><?php echo JText::_("NEW_PRODUCT"); ?> </label> <div class="controls"> <?php echo JHTML::_('select.genericlist', $products, 'new_product_id', 'class="inputbox" size="1" ', 'id', 'title', $this->ticket->prod_id); ?> </div> </div> <?php } ?> <?php $departments = SupportHelper::getDepartments(); ?> <?php if (count($departments) > 0) { ?> <div class="control-group"> <label class="control-label"><?php echo JText::_("NEW_DEPARTMENT"); ?> </label> <div class="controls"> <?php echo JHTML::_('select.genericlist', $departments, 'new_department_id', 'class="inputbox" size="1" ', 'id', 'title', $this->ticket->ticket_dept_id); ?> </div>
</a> <?php } ?> <div class="pull-right ticket_message_poster"> <?php if ($message->source == "email") { ?> <i class="icon-mail"></i> <?php } ?> <?php SupportHelper::TimeTaken($message); ?> <?php if ($message->admin == TICKET_MESSAGE_ADMIN) { ?> <?php FSS_Helper::$message_labels[$message->id] = "success"; ?> <span class="label label-success"> <?php } elseif ($message->admin == TICKET_MESSAGE_PRIVATE) { ?> <?php FSS_Helper::$message_labels[$message->id] = "info"; ?>
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; }
function displayTicketList() { $this->getDBTime(); // load in data for search forms $this->handlers = SupportUsers::getHandlers(false, false); $this->products = SupportHelper::getProducts(); $this->statuss = SupportHelper::getStatuss(); $this->departments = SupportHelper::getDepartments(); $this->categories = SupportHelper::getCategories(); $this->priorities = SupportHelper::getPriorities(); $this->ticketgroups = SupportHelper::getTicketGroups(); $this->taglist = SupportHelper::getTags(); // load extra data for the list of tickets we have $this->ticket_list->loadTags(); $this->ticket_list->loadAttachments(); $this->ticket_list->loadGroups(); $this->ticket_list->loadLockedUsers(); $this->ticket_list->loadCustomFields(); if (FSS_Settings::get('support_show_msg_counts')) { $this->ticket_list->loadMessageCounts(); } // load in custom fields $this->customfields = FSSCF::GetAllCustomFields(true); // set the list of tickets to this->tickets $this->tickets = $this->ticket_list->tickets; $session = JFactory::getSession(); $preview = FSS_Input::getInt('preview'); if ($preview == -1) { $preview = ""; $session->clear('preview'); } if ($preview == 1 || $session->Get('preview') == 1) { $this->enablePreview(); } if ($this->refresh == 2) { include $this->snippet(JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'views' . DS . 'admin_support' . DS . 'snippet' . DS . '_ticket_list.php'); return; } elseif ($this->refresh) { ob_start(); include $this->snippet(JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'views' . DS . 'admin_support' . DS . 'snippet' . DS . '_ticket_list.php'); $contents = ob_get_clean(); $output = array(); $output['count'] = $this->count; $output['tickets'] = $contents; header("Content-Type: application/json"); echo json_encode($output); return; } return $this->_display(); }
</td> </tr> <tr> <td width="135" align="right" class="key"> <label for="section"> <?php echo JText::_("Combine for users with"); ?> : </label> </td> <td> <select name="combine_with"> <option value="0">Dont Combine</option> <?php foreach (SupportHelper::getStatuss() as $status) { ?> <?php if ($status->id == $this->ticketstatus->id) { continue; } ?> <option value="<?php echo $status->id; ?> " <?php if ($this->ticketstatus->combine_with == $status->id) { echo "selected"; } ?> ><?php
FSS_Table::ColStart("tr_pri"); ?> <th style="vertical-align: middle"><?php echo JText::_("PRIORITY"); ?> </th> <td> <?php if ($this->can_ChangeTicket()) { ?> <select id='ticket_pri_id' name='ticket_pri_id' class="input-medium select-color" style="margin: 0px; color:<?php echo FSS_Helper::escape($this->ticket->pcolor); ?> " onchange="priority_update();"> <?php $priorities = SupportHelper::getPriorities(); ?> <?php foreach ($priorities as $pri) { ?> <option value='<?php echo $pri->id; ?> ' style='color: <?php echo FSS_Helper::escape($pri->color); ?> ' <?php if ($pri->id == $this->ticket->ticket_pri_id) { echo "selected='selected'"; } ?>
function saveReply() { $this->removeDraft(FSS_Input::getInt('draft')); // get posted data $ticketid = FSS_Input::getInt('ticketid'); $reply_type = FSS_Input::getCmd('reply_type'); $user_message = FSS_Input::getBBCode('body'); $handler_message = FSS_Input::getBBCode('body2'); $subject = FSS_Input::getString('subject'); // load ticket $ticket = new SupportTicket(); if (!$ticket->load($ticketid)) { exit; } // set up some variables $user_id = JFactory::getUser()->id; $handler_id = $user_id; $old_st = $ticket->getStatus(); $action_name = ""; $action_params = array(); $message_id = 0; $files_private = 0; // add signatures to messages if (FSS_Input::getInt('signature')) { if ($user_message) { $user_message .= SupportCanned::AppendSig(FSS_Input::getInt('signature'), $ticket); } if ($handler_message) { $handler_message .= SupportCanned::AppendSig(FSS_Input::getInt('signature'), $ticket); } } $extra_time = 0; $timestart = 0; $timeend = 0; if (FSS_Settings::Get('time_tracking') != "") { if (FSS_Settings::get('time_tracking_type') == 'se') { $timestart = strtotime("1970-01-01 " . FSS_Input::getString('timetaken_start')); $timeend = strtotime("1970-01-01 " . FSS_Input::getString('timetaken_end')); $extra_time = (int) (($timeend - $timestart) / 60); } elseif (FSS_Settings::get('time_tracking_type') == 'tm') { $timestart = strtotime(FSS_Input::getString('timetaken_start')); $timeend = strtotime(FSS_Input::getString('timetaken_end')); $extra_time = (int) (($timeend - $timestart) / 60); } else { $extra_time = (int) (FSS_Input::getInt('timetaken_hours') * 60 + FSS_Input::getInt('timetaken_mins')); } } // different reply types switch ($reply_type) { case 'reply': // post reply to user if ($user_message) { $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); } elseif ($extra_time > 0) { // no message, add time if needed $ticket->addTime($extra_time, "", true, $timestart, $timeend); } // update status $new_status = FSS_Input::getInt('reply_status'); $ticket->updateStatus($new_status); // reassign ticket if needed if (FSS_Settings::get('support_assign_reply') == 1 && FSS_Input::getInt('dontassign') == 0) { $ticket->assignHandler($handler_id, TICKET_ASSIGN_TOOK_OWNER); } elseif (FSS_Settings::get('support_autoassign') == 3 && $ticket->admin_id == 0 && FSS_Input::getInt('dontassign') == 0) { $ticket->assignHandler($handler_id, TICKET_ASSIGN_ASSIGNED); } // call SupportActions handler for admin reply $action_name = "Admin_Reply"; $action_params = array('subject' => $subject, 'user_message' => $user_message, 'status' => $new_status); break; case 'private': // add message to ticket if ($handler_message) { $message_id = $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); } else { if ($extra_time > 0) { $ticket->addTime($extra_time, "", true, $timestart, $timeend); } } $files_private = 1; // call support actions for private comment $action_name = "Admin_Private"; $action_params = array('subject' => $subject, 'handler_message' => $handler_message); break; case 'user': // update user on ticket $new_user_id = FSS_Input::getInt("user_id"); $ticket->updateUser($new_user_id); if ($user_message) { $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); } else { if ($extra_time > 0) { $ticket->addTime($extra_time, "", true, $timestart, $timeend); $extra_time = 0; } } $action_name = "Admin_ForwardUser"; $action_params = array('subject' => $subject, 'user_message' => $user_message, 'user_id' => $new_user_id); // break; case 'product': $new_handler_id = FSS_Input::getInt('new_handler'); // update product and department $new_product_id = FSS_Input::getInt("new_product_id"); $new_department_id = FSS_Input::getInt("new_department_id"); $ticket->updateProduct($new_product_id); $ticket->updateDepartment($new_department_id); /** * -2 - Auto Assign * -1 - Unchanged * 0 - Unassigned * X - Hander **/ if ($new_handler_id == -1) { //$ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD); } else { if ($new_handler_id == 0) { $ticket->assignHandler(0, -1); } else { if ($new_handler_id > 0) { $ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD); } else { if ($new_handler_id == -2) { // auto assign new handler $admin_id = FSS_Ticket_Helper::AssignHandler($new_product_id, $new_department_id, $ticket->ticket_cat_id, true); $ticket->assignHandler($admin_id, TICKET_ASSIGN_FORWARD); } } } } if ($user_message) { $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); $extra_time = 0; } if ($handler_message) { $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); $extra_time = 0; } if ($extra_time > 0) { $ticket->addTime($extra_time, "", true, $timestart, $timeend); } $action_name = "Admin_ForwardProduct"; $action_params = array('subject' => $subject, 'user_message' => $user_message, 'handler_message' => $handler_message, 'product_id' => $new_product_id, 'department_id' => $new_department_id); break; case 'handler': $new_handler_id = FSS_Input::getInt('new_handler'); if ($new_handler_id == -2) { // auto assign new handler $admin_id = FSS_Ticket_Helper::AssignHandler($ticket->prod_id, $ticket->ticket_dept_id, $ticket->ticket_cat_id, true); $ticket->assignHandler($admin_id, TICKET_ASSIGN_FORWARD); } else { if ($new_handler_id != -1) { $ticket->assignHandler($new_handler_id, TICKET_ASSIGN_FORWARD); } } // update status $new_status = FSS_Input::getCmd('reply_status'); $ticket->updateStatus($new_status); if ($user_message) { $message_id = $ticket->addMessage($user_message, $subject, $user_id, TICKET_MESSAGE_ADMIN, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); $extra_time = 0; } if ($handler_message) { $ticket->addMessage($handler_message, $subject, $user_id, TICKET_MESSAGE_PRIVATE, $extra_time, $timestart, $timeend); $ticket->addTime($extra_time); $extra_time = 0; } if ($extra_time > 0) { $ticket->addTime($extra_time, "", true, $timestart, $timeend); } $action_name = "Admin_ForwardHandler"; $action_params = array('subject' => $subject, 'user_message' => $user_message, 'handler_message' => $handler_message, 'handler_id' => $new_handler_id); break; } // add posted files $files = $ticket->addFilesFromPost($message_id, -1, $files_private); $ticket->stripImagesFromMessage($message_id); $action_params['files'] = $files; // call action handler SupportActions::DoAction($action_name, $ticket, $action_params); // Redirect to new page $link = FSSRoute::_('index.php?option=com_fss&view=admin_support&layout=ticket&ticketid=' . $ticket->id, false); $new_st = $ticket->getStatus(); if ($reply_type == "reply") { if ($new_st->is_closed && SupportUsers::getSetting("return_on_close")) { $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_close")); } else { if (SupportUsers::getSetting("return_on_reply")) { $link = SupportHelper::parseRedirectType($old_st->id, SupportUsers::getSetting("return_on_reply")); } } } JFactory::getApplication()->redirect($link); }