Example #1
0
 /**
  * Update staff response time if first staff response
  * @param xhelpTicket $ticket Ticket for response
  * @param xhelpResponses $response Response
  * @return bool True on success, false on error
  * @access public
  */
 function new_response($ticket, $response)
 {
     global $xoopsUser;
     //if first response for ticket, update staff responsetime
     $hResponse =& xhelpGetHandler('responses');
     $hMembership =& xhelpGetHandler('membership');
     if ($hResponse->getStaffResponseCount($ticket->getVar('id')) == 1) {
         if ($hMembership->isStaffMember($response->getVar('uid'), $ticket->getVar('department'))) {
             $responseTime = abs($response->getVar('updateTime') - $ticket->getVar('posted'));
             $this->_hStaff->updateResponseTime($response->getVar('uid'), $responseTime);
         }
     }
 }
Example #2
0
 /**
  * Add Log information for 'new_response' event
  * @param xhelpTicket $ticket Ticket for Response
  * @param xhelpResponses $newResponse Response that was added
  * @return bool True on success, false on error
  * @access public
  */
 function new_response($ticket, $newResponse)
 {
     global $xoopsUser;
     $logMessage =& $this->_hLog->create();
     $logMessage->setVar('uid', $xoopsUser->getVar('uid'));
     $logMessage->setVar('ticketid', $ticket->getVar('id'));
     $logMessage->setVar('action', _XHELP_LOG_ADDRESPONSE);
     $logMessage->setVar('lastUpdated', $newResponse->getVar('updateTime'));
     return $this->_hLog->insert($logMessage);
 }
 /**
  * Event: batch_response
  * Triggered after a batch response addition
  * Note: the $response->getVar('ticketid') field is empty for this function
  * @param array $tickets The xhelpTicket objects that were modified
  * @param xhelpResponses $response The response added to each ticket
  */
 function batch_response($tickets, $response)
 {
     global $xoopsUser, $xoopsConfig, $xoopsModuleConfig;
     $displayName =& $xoopsModuleConfig['xhelp_displayName'];
     // Determines if username or real name is displayed
     $responseText = $this->_ts->stripslashesGPC($response->getVar('message', 'n'));
     $uname = $xoopsUser->getVar('uname');
     $uid = $xoopsUser->getVar('uid');
     $updated = formatTimestamp(time(), 'm');
     $private = $response->getVar('private');
     $hMBoxes =& xhelpGetHandler('departmentMailBox');
     $mBoxes =& $hMBoxes->getObjects(null, true);
     $hDepartments =& xhelpGetHandler('department');
     $settings =& $this->_hNotification->get(XHELP_NOTIF_NEWRESPONSE);
     $staff_setting = $settings->getVar('staff_setting');
     $user_setting = $settings->getVar('user_setting');
     $staff_options = $settings->getVar('staff_options');
     if ($staff_setting != XHELP_NOTIF_STAFF_NONE) {
         $dept_email_tpl = $this->_getEmailTpl('dept', 'new_response', $this->_module, $template_id);
     } else {
         $dept_email_tpl = false;
     }
     if ($user_setting != XHELP_NOTIF_USER_NO) {
         $user_email_tpl = $this->_getEmailTpl('ticket', 'new_this_response', $this->_module, $template_id);
     } else {
         $user_email_tpl = false;
     }
     foreach ($tickets as $ticket) {
         $bFromEmail = false;
         $tags = array();
         $tags['TICKET_ID'] = $ticket->getVar('id');
         $tags['TICKET_RESPONSE'] = $responseText;
         $tags['TICKET_SUBJECT'] = $ticket->getVar('subject');
         $tags['TICKET_TIMESPENT'] = $response->getVar('timeSpent');
         $tags['TICKET_STATUS'] = xhelpGetStatus($ticket->getVar('status'));
         $tags['TICKET_RESPONDER'] = $uname;
         $tags['TICKET_POSTED'] = $updated;
         $tags['TICKET_URL'] = XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id');
         $tags['TICKET_DEPARTMENT'] = $this->_ts->stripslashesGPC($hDepartments->getNameById($ticket->getVar('department')));
         $owner = $ticket->getVar('ownership');
         if ($owner == 0) {
             $tags['TICKET_OWNERSHIP'] = _XHELP_NO_OWNER;
         } else {
             $tags['TICKET_OWNERSHIP'] = xhelpGetUsername($owner, $displayName);
         }
         if ($ticket->getVar('serverid') > 0) {
             //Ticket was submitted via email
             $mBox =& $mBoxes[$ticket->getVar('serverid')];
             if (is_object($mBox)) {
                 $bFromEmail = true;
             }
         }
         if ($bFromEmail) {
             $from = $server->getVar('emailaddress');
             $tags['TICKET_SUPPORT_EMAIL'] = $from;
             $tags['TICKET_SUPPORT_KEY'] = '{' . $ticket->getVar('emailHash') . '}';
         } else {
             $from = '';
             $tags['TICKET_SUPPORT_EMAIL'] = $xoopsConfig['adminmail'];
             $tags['TICKET_SUPPORT_KEY'] = '';
         }
         $sendTo = array();
         if ($ticket->getVar('uid') != $uid && $response->getVar('private') == 0) {
             // If response from staff member
             if ($private == 0) {
                 if ($user_email_tpl) {
                     $sendTo = $this->_getUserEmail($ticket->getVar('uid'));
                     $success = $this->_sendEvents($user_email_tpl, $sendTo, $tags, $from);
                 }
             } else {
                 if ($dept_email_tpl) {
                     if ($ticket->getVar('ownership') != 0) {
                         $sendTo = $this->_getStaffEmail($owner, $ticket->getVar('department'), $staff_options);
                     } else {
                         $sendTo = $this->_getSubscribedStaff($ticket, $dept_email_tpl['bit_value'], $settings);
                     }
                 }
             }
         } else {
             // If response from submitter
             if ($dept_email_tpl) {
                 if ($ticket->getVar('ownership') != 0) {
                     // If ticket has owner, send to owner
                     if ($this->_isSubscribed($owner, $email_tpl['bit_value'])) {
                         // Check if the owner is subscribed
                         $sendTo = $this->_getStaffEmail($owner, $ticket->getVar('department'), $staff_options);
                     }
                 } else {
                     // If ticket has no owner, send to department
                     $sendTo =& $this->_getSubscribedStaff($ticket, $dept_email_tpl['bit_value'], $settings);
                 }
                 $success = $this->_sendEvents($dept_email_tpl, $sendTo, $tags);
             }
         }
     }
 }