/** * Call Backback function for 'delete_ticket' * @param xhelpTicket $ticket Ticket being deleted * @return bool True on success, false on error * @access public */ function delete_ticket($ticket) { $hStatus = xhelpGetHandler('status'); $status =& $hStatus->get($ticket->getVar('status')); if ($status->getVar('state') == XHELP_STATE_UNRESOLVED) { return $this->_clearPerfImages(); } }
/** * Event: new_faq * Triggered after FAQ addition * @param xhelpTicket $ticket Ticket used as base for FAQ * @param xhelpFaq $faq FAQ that was added */ function new_faq($ticket, $faq) { global $xoopsUser; //Create a new solution from the supplied ticket / faq $hTicketSol =& xhelpGetHandler('ticketSolution'); $sol =& $hTicketSol->create(); $sol->setVar('ticketid', $ticket->getVar('id')); $sol->setVar('url', $faq->getVar('url')); $sol->setVar('title', $faq->getVar('subject')); $sol->setVar('uid', $xoopsUser->getVar('uid')); return $hTicketSol->addSolution($ticket, $sol); }
/** * Event: new_faq * Triggered after FAQ addition * @param xhelpTicket $ticket Ticket used as base for FAQ * @param xhelpFaq $faq FAQ that was added */ function new_faq($ticket, $faq) { global $xoopsUser; $logMessage =& $this->_hLog->create(); $logMessage->setVar('uid', $xoopsUser->getVar('uid')); $logMessage->setVar('ticketid', $ticket->getVar('id')); $logMessage->setVar('action', sprintf(_XHELP_LOG_NEWFAQ, $faq->getVar('subject'))); return $this->_hLog->insert($logMessage, true); }
/** * Event Handler for 'view_ticket' * @param xhelpTicket $ticket Ticket being viewd * @return bool True on success, false on error * @access public */ function view_ticket($ticket) { $value = array(); //Store a list of recent tickets in the xhelp_recent_tickets cookie if (isset($_COOKIE['xhelp_recent_tickets'])) { $oldvalue = explode(',', $_COOKIE['xhelp_recent_tickets']); } else { $oldvalue = array(); } $value[] = $ticket->getVar('id'); $value = array_merge($value, $oldvalue); $value = $this->_array_unique($value); $value = array_slice($value, 0, 5); //Keep this value for 15 days setcookie('xhelp_recent_tickets', implode(',', $value), time() + 15 * 24 * 60 * 60, '/'); }
/** * Event: edit_response * Triggered after a response has been modified * Also See: new_response * @param xhelpTicket $nticket Ticket after modifications * @param xhelpResponses $response Modified response * @param xhelpTicket $oldticket Ticket before modifications * @param xhelpResponses $oldresponse Response modifications */ function edit_response($ticket, $response, $oldticket, $oldresponse) { //if not modified by response submitter, notify response submitter //notify ticket submitter global $xoopsUser, $xoopsModuleConfig; $hDepartments =& xhelpGetHandler('department'); $displayName =& $xoopsModuleCofnig['xhelp_displayName']; // Determines if username or real name is displayed $tags = array(); $tags['TICKET_URL'] = XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'); $tags['TICKET_OLD_RESPONSE'] = $this->_ts->stripslashesGPC($oldresponse->getVar('message', 'n')); $tags['TICKET_OLD_TIMESPENT'] = $oldresponse->getVar('timeSpent'); $tags['TICKET_OLD_STATUS'] = xhelpGetStatus($oldticket->getVar('status')); $tags['TICKET_OLD_RESPONDER'] = xhelpGetUsername($oldresponse->getVar('uid'), $displayName); $owner = $oldticket->getVar('ownership'); $tags['TICKET_OLD_OWNERSHIP'] = $owner = 0 ? _XHELP_NO_OWNER : xhelpGetUsername($owner, $displayName); $tags['TICKET_ID'] = $ticket->getVar('id'); $tags['RESPONSE_ID'] = $response->getVar('id'); $tags['TICKET_RESPONSE'] = $this->_ts->stripslashesGPC($response->getVar('message', 'n')); $tags['TICKET_TIMESPENT'] = $response->getVar('timeSpent'); $tags['TICKET_STATUS'] = xhelpGetStatus($ticket->getVar('status')); $tags['TICKET_RESPONDER'] = $xoopsUser->getVar('uname'); $tags['TICKET_POSTED'] = $response->posted(); $owner = $ticket->getVar('ownership'); $tags['TICKET_OWNERSHIP'] = $owner = 0 ? _XHELP_NO_OWNER : xhelpGetUsername($owner, $displayName); $tags['TICKET_DEPARTMENT'] = $this->_ts->stripslashesGPC($hDepartments->getNameById($ticket->getVar('department'))); // Added by marcan to get the ticket's subject available in the mail template $tags['TICKET_SUBJECT'] = $this->_ts->stripslashesGPC($ticket->getVar('subject', 'n')); // End of addition by marcan $settings =& $this->_hNotification->get(XHELP_NOTIF_EDITRESPONSE); $staff_setting = $settings->getVar('staff_setting'); $user_setting = $settings->getVar('user_setting'); if ($staff_setting != XHELP_NOTIF_STAFF_NONE) { if ($email_tpl = $this->_getEmailTpl('dept', 'modified_response', $this->_module, $template_id)) { // Notify dept staff $sendTo =& $this->_getSubscribedStaff($ticket, $email_tpl['bit_value'], $settings, $response->getVar('uid')); $success = $this->_sendEvents($email_tpl, $sendTo, $tags); } } if ($user_setting != XHELP_NOTIF_USER_NO) { if ($response->getVar('private') == 0) { // Make sure if response is private, don't sent to user if ($email_tpl = $this->_getEmailTpl('ticket', 'modified_this_response', $this->_module, $template_id)) { // Notify ticket submitter $sendTo = $this->_getSubscribedUsers($ticket->getVar('id')); $success = $this->_sendEvents($email_tpl, $sendTo, $tags); } } } }
/** * Recommend solutions to a ticket based on similarity * to previous tickets and their solutions * @param xhelpTicket $ticket ticket to search for solutions * @return array Value 1 = bayesian likeness probability, Value 2 = xhelpTicketSolution object * @access public */ function &recommendSolutions($ticket) { $ret = array(); //1. Get list of bayesian categories(tickets) similar to current ticket $bayes = new xhelpNaiveBayesian(new xhelpNaiveBayesianStorage()); $document = $ticket->getVar('subject') . "\r\n" . $ticket->getVar('description'); $cats = $bayes->categorize($document); //2. Get solutions to those tickets $crit = new Criteria('ticketid', "(" . implode(array_keys($cats), ',') . ")", 'IN'); $solutions =& $this->getObjects($crit); //3. Sort solutions based on likeness probability foreach ($solutions as $solution) { $ret[] = array('probability' => $cats[$solution->getVar('ticketid')], 'solution' => $solution); } unset($solutions); return $this->multi_sort($ret, 'probability'); }