예제 #1
0
        ?>
		</tr>
	<?php 
    }
    ?>

	<?php 
    foreach ($this->customfields as $custfield) {
        ?>
		<tr>
			<th><?php 
        echo $custfield['description'];
        ?>
&nbsp;</th>
			<td><?php 
        echo FSTCF::FieldInput($custfield, $this->errors, 'comments');
        ?>
</td>
		</tr>
	<?php 
    }
    ?>

	<?php 
    if ($this->errors['body']) {
        ?>
<tr><td></td><td class='fst_must_have_field'><?php 
        echo $this->errors['body'];
        ?>
</td></tr><?php 
    }
예제 #2
0
 function ParserPopulateTicket(&$parser, $row)
 {
     $parser->Clear();
     if ($row) {
         $parser->SetVar('ref', $row['reference']);
         $parser->SetVar('subject', "<a href='" . FSTRoute::_('index.php?option=com_fst&view=admin&layout=support&ticketid=' . $row['id']) . "'>" . $row['title'] . "</a>");
         $parser->SetVar("status", "<span style='color:" . $row['color'] . ";'>" . $row['status'] . "</span>");
         if ($row['user_id'] == 0) {
             $name = $row['unregname'] . " (" . JText::_("UNREG") . ")";
         } else {
             $name = $row['name'];
         }
         $parser->SetVar("name", $name);
         $parser->SetVar("lastactivity", FST_Helper::Date($row['lastupdate'], FST_DATETIME_SHORT));
         $parser->SetVar("opened", FST_Helper::Date($row['opened'], FST_DATETIME_SHORT));
         $parser->SetVar("closed", FST_Helper::Date($row['closed'], FST_DATETIME_SHORT));
         $parser->SetVar("department", $row['department']);
         $parser->SetVar("category", $row['category']);
         $parser->SetVar("product", $row['product']);
         $parser->SetVar("priority", "<span style='color:" . $row['pricolor'] . ";'>" . $row['priority'] . "</span>");
         $groups = implode(", ", $row['groups']);
         $parser->SetVar('groups', $groups);
         $parser->SetVar('deletebutton', 'deletebutton');
         $parser->SetVar('archivebutton', 'archivebutton');
         if (array_key_exists("custom", $row)) {
             $allcustom = array();
             if (count($row['custom']) > 0) {
                 foreach ($row['custom'] as $id => $value) {
                     if (array_key_exists($id, $this->customfields)) {
                         $field = $this->customfields[$id];
                         if ($field['type'] == "plugin") {
                             $aparams = FSTCF::GetValues($field);
                             if (array_key_exists("plugin", $aparams) && array_key_exists("plugindata", $aparams)) {
                                 $plugin = FSTCF::get_plugin($aparams['plugin']);
                                 $value = $plugin->Display($value, $aparams['plugindata'], array('ticketid' => $row['id'], 'userid' => $row['user_id'], 'ticket' => $row), $field['id']);
                             }
                         }
                         $text = "<span class='fst_support_fieldname'>" . $this->customfields[$id]['description'] . "</span>";
                         if ($this->customfields[$id]['type'] == "checkbox") {
                             if ($value == "on") {
                                 $text .= ": " . JText::_("Yes");
                             } else {
                                 $text .= ": " . JText::_("No");
                             }
                         } else {
                             $text .= ": " . $value;
                         }
                         $parser->SetVar("custom" . $id, $text);
                         $allcustom[] = $text;
                     }
                 }
             }
             //echo "All custom : " . implode(", ",$allcustom) . "<br>";
             $parser->SetVar("custom", implode(", ", $allcustom));
         }
         if ($row['assigned'] == '') {
             $parser->SetVar('handlername', JText::_("UNASSIGNED"));
         } else {
             $parser->SetVar('handlername', $row['assigned']);
         }
         $parser->SetVar('username', $row['username']);
         $parser->SetVar('email', $row['useremail']);
         $parser->SetVar('handlerusername', $row['handlerusername']);
         $parser->SetVar('handleremail', $row['handleremail']);
         $icons = "";
         if (FST_Settings::get('support_show_msg_counts')) {
             $icons .= "<span>";
             $icons .= "<span style='font-weight:normal;top:-2px;position:relative;padding-right:2px;'>" . $row['msgcount']['total'] . "</span><span style='font-weight:normal;top:-2px;position:relative;padding-right:2px;'>x</span><img src='" . JURI::root(true) . "/components/com_fst/assets/images/messages.png'>";
             $icons .= "</span>";
         }
         $cotime = $this->db_time - strtotime($row['checked_out_time']);
         if ($cotime < FST_Settings::get('support_lock_time') && $row['checked_out'] != $this->userid && $row['checked_out'] > 0) {
             $html = "<div class='fst_user_tt'>" . $row['co_user']->name . " (" . $row['co_user']->email . ")</div>";
             $icons .= "<img class='fsj_tip' src='" . JURI::root(true) . "/components/com_fst/assets/images/lock.png' title=\"" . JText::_('TICKET_LOCKED') . "::" . $html . "\">";
         } else {
             $icons .= "<img src='" . JURI::root(true) . "/components/com_fst/assets/images/blank_16.png'>";
         }
         if (!FST_Settings::get('support_hide_tags')) {
             if (isset($row['tags'])) {
                 $html = "";
                 foreach ($row['tags'] as $tag) {
                     $html .= "<div class='fst_tag_tt'>" . $tag['tag'] . "</div>";
                 }
                 $icons .= "<img class='fsj_tip' src='" . JURI::root(true) . "/components/com_fst/assets/images/tag.png' title=\"" . JText::_('TICKET_TAGS') . "::" . $html . "\">";
             } else {
                 $icons .= "<img src='" . JURI::root(true) . "/components/com_fst/assets/images/blank_16.png'>";
             }
         }
         if (isset($row['attach'])) {
             $html = "<table class='fst_attach_tt'>";
             foreach ($row['attach'] as $attach) {
                 $html .= "<tr style='border:0px;'><td nowrap style='border:0px;'>" . $attach['filename'] . "&nbsp;</td><td nowrap style='border:0px;'>&nbsp;" . FST_Helper::display_filesize($attach['size']) . "</td></tr>";
             }
             $html .= "<table>";
             $icons .= "<img class='fsj_tip' src='" . JURI::root(true) . "/components/com_fst/assets/images/attach.png' title=\"" . JText::_('TICKET_ATTACHMENTS') . "::" . $html . "\">";
         } else {
             $icons .= "<img src='" . JURI::root(true) . "/components/com_fst/assets/images/blank_16.png'>";
         }
         $parser->SetVar('icons', $icons);
         $delete = "<a href='" . FSTRoute::x('index.php?option=com_fst&view=admin&layout=support&tickets=' . JRequest::getVar('tickets') . '&delete=' . $row['id']) . "'>";
         $delete .= "<img src='" . JURI::root(true) . "/components/com_fst/assets/images/delete_ticket.png'>";
         $delete .= JText::_("DELETE") . "</a>";
         $archive = "<a href='" . FSTRoute::x('index.php?option=com_fst&view=admin&layout=support&tickets=' . JRequest::getVar('tickets') . '&archive=' . $row['id']) . "'>";
         $archive .= "<img src='" . JURI::root(true) . "/components/com_fst/assets/images/archive_ticket.png'>";
         $archive .= JText::_("ARCHIVE") . "</a>";
         $parser->SetVar('archivebutton', $archive);
         $parser->SetVar('deletebutton', $delete);
         // TODO: trhl
         /*id='ticket_<?php echo $ticket['id'];?>'
         		onmouseover="$('ticket_<?php echo $ticket['id'];?>').style.background = '<?php echo FST_Settings::get('css_hl'); ?>';$('ticket_<?php echo $ticket['id'];?>_2').style.background = '<?php echo FST_Settings::get('css_hl'); ?>';"
         		onmouseout="$('ticket_<?php echo $ticket['id'];?>').style.background = '';$('ticket_<?php echo $ticket['id'];?>_2').style.background = '';"*/
         $this->_permissions = FST_Ticket_Helper::getAdminPermissions();
         $type = "unassigned";
         if ($row['admin_id'] == $this->_permissions['id']) {
             $type = "mine";
         } else {
             if ($row['admin_id'] > 0) {
                 $type = "other";
             }
         }
         $style = "";
         if (array_key_exists($row['ticket_pri_id'], $this->priorities)) {
             $pri = $this->priorities[$row['ticket_pri_id']];
             if ($pri['backcolor']) {
                 $style .= "background-color: {$pri['backcolor']};";
             }
         }
         $handler_highlight = "ticket_type_{$type}";
         $parser->SetVar('handler_highlight', $handler_highlight);
         $trhl = " class='ticket_{$row['id']} ' onmouseover='highlightticket({$row['id']})' onmouseout='unhighlightticket({$row['id']})' ";
         if (FST_Settings::get('support_entire_row')) {
             $style .= "cursor: pointer;";
             $trhl .= " onclick='window.location=\"" . FSTRoute::x('&limitstart=&ticketid=' . $row['id']) . "\"' ";
         }
         $trhl .= " style='{$style}' ";
         $parser->SetVar('trhl', $trhl);
     }
     $parser->SetVar("showassigned", $this->showassigned);
     $parser->SetVar("hidehandler", FST_Settings::get('support_hide_handler'));
     $parser->SetVar("candelete", FST_Settings::get('support_delete'));
     $parser->SetVar("view", $this->ticket_view);
 }
예제 #3
0
 static function FieldOutput(&$field, &$fieldvalues, $context)
 {
     $value = "";
     if (count($fieldvalues) > 0) {
         foreach ($fieldvalues as $fieldvalue) {
             if ($fieldvalue['field_id'] == $field['id']) {
                 $value = $fieldvalue['value'];
                 break;
             }
         }
     }
     if ($field['type'] == "plugin") {
         $aparams = FSTCF::GetValues($field);
         $plugin = FSTCF::get_plugin($aparams['plugin']);
         $value = $plugin->Display($value, $aparams['plugindata'], $context, $field['id']);
     }
     if ($field['type'] == "area") {
         $value = str_replace("\n", "<br />", $value);
     }
     if ($field['type'] == "checkbox") {
         if ($value == "on") {
             return "Yes";
         }
         return "No";
     }
     return $value;
 }
예제 #4
0
파일: admin.php 프로젝트: AxelFG/ckbran-inf
 function &getTicketSearch()
 {
     FST_Ticket_Helper::getAdminPermissions();
     $mainframe = JFactory::getApplication();
     $limit = $mainframe->getUserStateFromRequest('global.list.limit_ticket', 'limit', FST_Helper::getUserSetting('per_page'), 'int');
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $db = JFactory::getDBO();
     if (empty($this->_tickets)) {
         $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 #__fst_ticket_ticket as t ";
         $query .= " LEFT JOIN #__fst_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 #__fst_user as a ON t.admin_id = a.id ";
         $query .= " LEFT JOIN #__users as au ON a.user_id = au.id ";
         $query .= " LEFT JOIN #__fst_ticket_dept as dept ON t.ticket_dept_id = dept.id ";
         $query .= " LEFT JOIN #__fst_ticket_cat as cat ON t.ticket_cat_id = cat.id ";
         $query .= " LEFT JOIN #__fst_prod as prod ON t.prod_id = prod.id ";
         $query .= " LEFT JOIN #__fst_ticket_pri as pri ON t.ticket_pri_id = pri.id ";
         $query .= " LEFT JOIN (SELECT group_id, user_id FROM #__fst_ticket_group_members GROUP BY user_id) as mem ON t.user_id = mem.user_id ";
         $query .= " LEFT JOIN #__fst_ticket_group as grp ON grp.id = mem.group_id ";
         $searchtype = JRequest::getVar('searchtype', 'basic');
         $ticketids = array();
         $ticketids[0] = 0;
         $ticketid_matchall = 0;
         $tags = JRequest::getVar('tags', '');
         $tags = trim($tags, ';');
         if ($tags) {
             $tags_ = explode(";", $tags);
             $tags = array();
             foreach ($tags_ as $tag) {
                 if ($tag) {
                     $tags[$tag] = $tag;
                 }
             }
             if (count($tags) > 0) {
                 foreach ($tags as $tag) {
                     $ticketid_matchall++;
                     $qry = "SELECT ticket_id FROM #__fst_ticket_tags WHERE tag = '" . FSTJ3Helper::getEscaped($db, $tag) . "'";
                     $db->setQuery($qry);
                     //echo $qry."<br>";
                     $rows = $db->loadAssocList("ticket_id");
                     foreach ($rows as $row) {
                         $ticketid = $row['ticket_id'];
                         if (array_key_exists($ticketid, $ticketids)) {
                             $ticketids[$ticketid]++;
                         } else {
                             $ticketids[$ticketid] = 1;
                         }
                     }
                 }
             }
         }
         if ($searchtype == "basic") {
             $search = JRequest::getVar('search', '');
             $wherebits = array();
             // store tag match ids in separate array, as we want to AND them, not OR
             $tagids = $ticketids;
             $ticketids = array();
             $ticketids[0] = 0;
             if ($search != "") {
                 $wherebits[] = " t.title LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                 $wherebits[] = " t.reference = '" . FSTJ3Helper::getEscaped($db, $search) . "' ";
                 // search custom fields that are set to be searched
                 $fields = FSTCF::GetAllCustomFields(true);
                 /*echo "<pre>";
                 		print_r($fields);
                 		echo "</pre>";*/
                 foreach ($fields as $field) {
                     if (!$field['basicsearch']) {
                         continue;
                     }
                     $ticketid_matchall++;
                     $fieldid = $field['id'];
                     $qry = "SELECT ticket_id FROM #__fst_ticket_field WHERE field_id = '" . FSTJ3Helper::getEscaped($db, $fieldid) . "' AND value LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%'";
                     $db->setQuery($qry);
                     //echo $qry."<br>";
                     $moreids = $db->loadAssoclist();
                     //print_r($moreids);
                     foreach ($moreids as $row) {
                         if (array_key_exists($row['ticket_id'], $ticketids)) {
                             $ticketids[$row['ticket_id']]++;
                         } else {
                             $ticketids[$row['ticket_id']] = 1;
                         }
                     }
                 }
                 // basic search optional fields
                 if (FST_Settings::get('support_basic_name')) {
                     $wherebits[] = " u.name LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                     $wherebits[] = " unregname LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                 }
                 if (FST_Settings::get('support_basic_username')) {
                     $wherebits[] = " u.username LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                 }
                 if (FST_Settings::get('support_basic_email')) {
                     $wherebits[] = " u.email LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                     $wherebits[] = " t.email LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' ";
                 }
                 if (FST_Settings::get('support_basic_messages')) {
                     $ticketid_matchall++;
                     $fieldid = $field['id'];
                     $qry = "SELECT ticket_ticket_id as ticket_id FROM #__fst_ticket_messages WHERE subject LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%' OR body LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%'";
                     $db->setQuery($qry);
                     //echo $qry."<br>";
                     $moreids = $db->loadAssoclist();
                     //print_r($moreids);
                     foreach ($moreids as $row) {
                         if (array_key_exists($row['ticket_id'], $ticketids)) {
                             $ticketids[$row['ticket_id']]++;
                         } else {
                             $ticketids[$row['ticket_id']] = 1;
                         }
                     }
                 }
             }
             if (count($ticketids) > 1) {
                 $tids = array();
                 foreach ($ticketids as $id => $rec) {
                     $tids[] = $id;
                 }
                 $ticketids = $tids;
                 unset($tids);
             }
             if (count($ticketids) > 1) {
                 $wherebits[] = "t.id IN (" . implode(",", $ticketids) . ")";
             }
             if (count($wherebits) == 0) {
                 $wherebits[] = "1";
             }
             $query .= " WHERE (" . implode(" OR ", $wherebits) . ")";
             // add ticket tag ids
             if (count($tagids) > 1) {
                 $tids = array();
                 foreach ($tagids as $id => $rec) {
                     $tids[] = $id;
                 }
                 $tagids = $tids;
                 unset($tids);
                 $query .= " AND t.id IN (" . implode(",", $tagids) . ")";
             }
             //echo $query . "<br>";
         } else {
             if ($searchtype == "advanced") {
                 $search = JRequest::getVar('search', '');
                 $wherebits = array();
                 $subject = JRequest::getVar('subject', '');
                 if ($subject) {
                     $wherebits[] = " t.title LIKE '%" . FSTJ3Helper::getEscaped($db, $subject) . "%' ";
                 }
                 $reference = JRequest::getVar('reference', '');
                 if ($reference) {
                     $wherebits[] = " t.reference = '" . FSTJ3Helper::getEscaped($db, $reference) . "' ";
                 }
                 $username = JRequest::getVar('username', '');
                 if ($username) {
                     $wherebits[] = " u.username LIKE '%" . FSTJ3Helper::getEscaped($db, $username) . "%' ";
                 }
                 $useremail = JRequest::getVar('useremail', '');
                 if ($useremail) {
                     $wherebits[] = " ( u.email LIKE '%" . FSTJ3Helper::getEscaped($db, $useremail) . "%' OR t.email LIKE '%" . FSTJ3Helper::getEscaped($db, $useremail) . "%' ) ";
                 }
                 $userfullname = JRequest::getVar('userfullname', '');
                 if ($userfullname) {
                     $wherebits[] = " ( u.name LIKE '%" . FSTJ3Helper::getEscaped($db, $userfullname) . "%' OR unregname LIKE '%" . FSTJ3Helper::getEscaped($db, $userfullname) . "%' ) ";
                 }
                 $content = JRequest::getVar('content', '');
                 if ($content) {
                     $q = " t.id IN ";
                     $q .= "( SELECT ticket_ticket_id FROM #__fst_ticket_messages WHERE body LIKE '%" . FSTJ3Helper::getEscaped($db, $content) . "%' )";
                     $wherebits[] = $q;
                 }
                 $handler = JRequest::getVar('handler', '');
                 if ($handler) {
                     if ($handler == -1 || $handler == -2) {
                         // need to find my handler id
                         $user = JFactory::getUser();
                         $qry = "SELECT * FROM #__fst_user WHERE user_id = '" . FSTJ3Helper::getEscaped($db, $user->id) . "'";
                         $db->setQuery($qry);
                         $fstuser = $db->loadObject();
                         if ($handler == -1) {
                             $wherebits[] = " t.admin_id = '" . FSTJ3Helper::getEscaped($db, $fstuser->id) . "' ";
                         } else {
                             $wherebits[] = " t.admin_id != '" . FSTJ3Helper::getEscaped($db, $fstuser->id) . "' ";
                             $wherebits[] = " t.admin_id != 0 ";
                         }
                     } else {
                         if ($handler == -3) {
                             $wherebits[] = " t.admin_id = 0";
                         } else {
                             $wherebits[] = " t.admin_id = '" . FSTJ3Helper::getEscaped($db, $handler) . "' ";
                         }
                     }
                 }
                 $status = JRequest::getVar('status', '');
                 if ($status) {
                     $wherebits[] = " t.ticket_status_id = '" . FSTJ3Helper::getEscaped($db, $status) . "' ";
                 }
                 $product = JRequest::getVar('product', '');
                 if ($product) {
                     $wherebits[] = " t.prod_id = '" . FSTJ3Helper::getEscaped($db, $product) . "' ";
                 }
                 $department = JRequest::getVar('department', '');
                 if ($department) {
                     $wherebits[] = " t.ticket_dept_id = '" . FSTJ3Helper::getEscaped($db, $department) . "' ";
                 }
                 $cat = JRequest::getVar('cat', '');
                 if ($cat) {
                     $wherebits[] = " t.ticket_cat_id = '" . FSTJ3Helper::getEscaped($db, $cat) . "' ";
                 }
                 $pri = JRequest::getVar('priority', '');
                 if ($pri) {
                     $wherebits[] = " t.ticket_pri_id = '" . FSTJ3Helper::getEscaped($db, $pri) . "' ";
                 }
                 $group = JRequest::getVar('group', '');
                 if ($group > 0) {
                     $wherebits[] = " t.user_id IN (SELECT user_id FROM #__fst_ticket_group_members WHERE group_id = '" . FSTJ3Helper::getEscaped($db, $group) . "' GROUP BY user_id)";
                 }
                 $date_from = $this->DateValidate(JRequest::getVar('date_from', ''));
                 $date_to = $this->DateValidate(JRequest::getVar('date_to', ''));
                 /*if ($date_from && $date_to)
                 		{
                 			// got both date, need a ticket with 
                 		} else*/
                 if ($date_from) {
                     $wherebits[] = " t.lastupdate > DATE_SUB('" . FSTJ3Helper::getEscaped($db, $date_from) . "',INTERVAL 1 DAY) ";
                 }
                 /*else*/
                 if ($date_to) {
                     $wherebits[] = " t.opened < DATE_ADD('" . FSTJ3Helper::getEscaped($db, $date_to) . "',INTERVAL 1 DAY) ";
                 }
                 // search custom fields that are set to be searched
                 $fields = FSTCF::GetAllCustomFields(true);
                 /*echo "<pre>";
                 		print_r($fields);
                 		echo "</pre>";*/
                 foreach ($fields as $field) {
                     if (!$field['advancedsearch']) {
                         continue;
                     }
                     $search = JRequest::getVar('custom_' . $field['id'], "");
                     //echo "Field : {$field['id']} = $search<br>";
                     if ($search != "") {
                         $ticketid_matchall++;
                         $fieldid = $field['id'];
                         if ($field['type'] == "checkbox") {
                             if ($search == "1") {
                                 $qry = "SELECT ticket_id FROM #__fst_ticket_field WHERE field_id = '" . FSTJ3Helper::getEscaped($db, $fieldid) . "' AND value = 'on'";
                             } else {
                                 $qry = "SELECT ticket_id FROM #__fst_ticket_field WHERE field_id = '" . FSTJ3Helper::getEscaped($db, $fieldid) . "' AND value = ''";
                             }
                         } elseif ($field['type'] == "radio" || $field['type'] == "combo") {
                             $qry = "SELECT ticket_id FROM #__fst_ticket_field WHERE field_id = '" . FSTJ3Helper::getEscaped($db, $fieldid) . "' AND value = '" . FSTJ3Helper::getEscaped($db, $search) . "'";
                         } else {
                             $qry = "SELECT ticket_id FROM #__fst_ticket_field WHERE field_id = '" . FSTJ3Helper::getEscaped($db, $fieldid) . "' AND value LIKE '%" . FSTJ3Helper::getEscaped($db, $search) . "%'";
                         }
                         $db->setQuery($qry);
                         //echo $qry."<br>";
                         $moreids = $db->loadAssoclist();
                         //print_r($moreids);
                         foreach ($moreids as $row) {
                             if (array_key_exists($row['ticket_id'], $ticketids)) {
                                 $ticketids[$row['ticket_id']]++;
                             } else {
                                 $ticketids[$row['ticket_id']] = 1;
                             }
                         }
                     }
                 }
                 if ($ticketid_matchall > 0) {
                     unset($ticketids[0]);
                     $tids = array();
                     if (count($ticketids) > 0) {
                         foreach ($ticketids as $id => $rec) {
                             if ($id == 0) {
                                 continue;
                             }
                             if ($rec == $ticketid_matchall) {
                                 $tids[] = $id;
                             }
                         }
                         $ticketids = $tids;
                         unset($tids);
                     }
                     if (count($ticketids) > 0) {
                         $wherebits[] = "t.id IN (" . implode(",", $ticketids) . ")";
                     } else {
                         $wherebits[] = "0";
                     }
                 }
                 if (count($wherebits) == 0) {
                     $wherebits[] = "1";
                 }
                 $query .= " WHERE " . implode(" AND ", $wherebits);
             } else {
                 $query .= " WHERE 1 ";
             }
         }
         $query .= FST_Ticket_Helper::$_perm_where;
         $order = array();
         if (FST_Helper::getUserSetting("group_products")) {
             $order[] = "prod.ordering";
         }
         if (FST_Helper::getUserSetting("group_departments")) {
             $order[] = "dept.title";
         }
         if (FST_Helper::getUserSetting("group_cats")) {
             $order[] = "cat.title";
         }
         if (FST_Helper::getUserSetting("group_pri")) {
             $order[] = "pri.ordering DESC";
         }
         if (FST_Helper::getUserSetting("group_group")) {
             $order[] = "case when grp.groupname is null then 1 else 0 end";
             $order[] = "grp.groupname";
         }
         $order[] = "lastupdate DESC";
         $query .= " ORDER BY " . implode(", ", $order);
         //echo "<br>$query<br>";
         $db->setQuery($query);
         $db->query();
         $this->_ticketcount = $db->getNumRows();
         $db->setQuery($query, $limitstart, $limit);
         $this->_tickets = $db->loadAssocList('id');
     }
     /*echo "<pre>";
     		print_r($result['tickets']);
     		echo "</pre>";*/
     $result['pagination'] = new JPaginationJs($this->_ticketcount, $limitstart, $limit);
     $result['count'] =& $this->_ticketcount;
     $result['tickets'] =& $this->_tickets;
     return $result;
 }
예제 #5
0
파일: email.php 프로젝트: AxelFG/ckbran-inf
 static function &ParseTemplate($template, &$ticket, $subject, $body, $ishtml)
 {
     $handler = FST_EMail::GetHandler($ticket['admin_id']);
     $custrec = FST_EMail::GetUser($ticket['user_id']);
     $subject = trim(str_ireplace("re:", "", $subject));
     $vars[] = FST_EMail::BuildVar('subject', $subject);
     /*if ($ishtml)
     		{
     			$body = str_replace("\n","<br />\n",$body);	
     		}*/
     $body = FST_Helper::ParseBBCode($body);
     $vars[] = FST_EMail::BuildVar('body', $body);
     $vars[] = FST_EMail::BuildVar('reference', $ticket['reference']);
     $vars[] = FST_EMail::BuildVar('password', $ticket['password']);
     if ($ticket['user_id'] == 0) {
         $vars[] = FST_EMail::BuildVar('user_name', $ticket['unregname']);
         $vars[] = FST_EMail::BuildVar('user_username', JText::_("UNREGISTERED"));
         $vars[] = FST_EMail::BuildVar('user_email', $ticket['email']);
     } else {
         $vars[] = FST_EMail::BuildVar('user_name', $custrec['name']);
         $vars[] = FST_EMail::BuildVar('user_username', $custrec['username']);
         $vars[] = FST_EMail::BuildVar('user_email', $custrec['email']);
     }
     $vars[] = FST_EMail::BuildVar('handler_name', $handler['name']);
     $vars[] = FST_EMail::BuildVar('handler_username', $handler['username']);
     $vars[] = FST_EMail::BuildVar('handler_email', $handler['email']);
     $vars[] = FST_EMail::BuildVar('ticket_id', $ticket['id']);
     $vars[] = FST_EMail::BuildVar('status', FST_EMail::GetStatus($ticket['ticket_status_id']));
     $vars[] = FST_EMail::BuildVar('priority', FST_EMail::GetPriority($ticket['ticket_pri_id']));
     $vars[] = FST_EMail::BuildVar('category', FST_EMail::GetCategory($ticket['ticket_cat_id']));
     $vars[] = FST_EMail::BuildVar('department', FST_EMail::GetDepartment($ticket['ticket_dept_id']));
     $vars[] = FST_EMail::BuildVar('product', FST_EMail::GetProduct($ticket['prod_id']));
     if (strpos($template['body'], "{messagehistory}") > 0) {
         //echo "Get message history<br>";
         $messages = FST_EMail::GetMessageHist($ticket['id']);
         // need to load in the messagerow template and parse it
         $text = FST_EMail::ParseMessageRows($messages, $ishtml);
         $vars[] = FST_EMail::BuildVar('messagehistory', $text);
         //print_p($messages);
     }
     $uri = JURI::getInstance();
     $baseUrl = $uri->toString(array('scheme', 'host', 'port'));
     $vars[] = FST_EMail::BuildVar('ticket_link', $baseUrl . FSTRoute::_('index.php?option=com_fst&view=ticket&ticketid=' . $ticket['id'], false));
     $vars[] = FST_EMail::BuildVar('admin_link', $baseUrl . FSTRoute::_('index.php?option=com_fst&view=admin&layout=support&ticketid=' . $ticket['id'], false));
     $config = JFactory::getConfig();
     if (FSTJ3Helper::IsJ3()) {
         $sitename = $config->get('sitename');
     } else {
         $sitename = $config->getValue('sitename');
     }
     if (FST_Settings::get('support_email_site_name') != "") {
         $sitename = FST_Settings::get('support_email_site_name');
     }
     $vars[] = FST_EMail::BuildVar('websitetitle', $sitename);
     // need to add the tickets custom fields to the output here
     $fields = FSTCF::GetAllCustomFields(true);
     $values = FSTCF::GetTicketValues($ticket['id'], $ticket);
     foreach ($fields as $fid => &$field) {
         $name = "custom_" . $fid;
         $value = "";
         if (array_key_exists($fid, $values)) {
             $value = $values[$fid]['value'];
         }
         //echo "$name -> $value<br>";
         $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) {
             $value = FSTCF::FieldOutput($field, $fieldvalues, '');
         }
         $vars[] = FST_EMail::BuildVar($name, $value);
     }
     $email['subject'] = FST_EMail::ParseText($template['subject'], $vars);
     $email['body'] = FST_EMail::ParseText($template['body'], $vars);
     //print_p($vars);
     //print_p($email);
     if ($template['ishtml']) {
         //$email['subject'] = str_replace("\n","<br />\n",$email['subject']);
         $email['body'] = FST_EMail::MaxLineLength($email['body']);
     } else {
         // strip bbcode out of subject or parse it to html depending on template type
         $email['body'] = str_replace("<br />", "\n", $email['body']);
         $email['body'] = html_entity_decode($email['body']);
         $email['body'] = preg_replace_callback("/(&#[0-9]+;)/", array($this, "email_decode_utf8"), $email['body']);
         $email['body'] = strip_tags($email['body']);
     }
     return $email;
 }
예제 #6
0
 function DoSaveComment()
 {
     $this->post['name'] = JRequest::getVar('name', '', '', 'string');
     $this->post['commentid'] = JRequest::getVar('commentid', '', '', 'string');
     $this->post['email'] = JRequest::getVar('email', '', '', 'string');
     $this->post['website'] = JRequest::getVar('website', '', '', 'string');
     $this->post['body'] = JRequest::getVar('body', '', '', 'string');
     $db = JFactory::getDBO();
     $custom = FSTCF::Comm_StoreFields($this->customfields);
     $custom = serialize($custom);
     $qry = "UPDATE {$this->table} SET name = '" . FSTJ3Helper::getEscaped($db, $this->post['name']) . "', email = '" . FSTJ3Helper::getEscaped($db, $this->post['email']) . "', ";
     $qry .= "website = '" . FSTJ3Helper::getEscaped($db, $this->post['website']) . "', body = '" . FSTJ3Helper::getEscaped($db, $this->post['body']) . "', ";
     $qry .= "custom = '" . FSTJ3Helper::getEscaped($db, $custom) . "' WHERE id = " . FSTJ3Helper::getEscaped($db, $this->post['commentid']);
     $db->SetQuery($qry);
     $db->Query();
     $this->DoShowComment();
     exit;
 }