예제 #1
0
 function __construct()
 {
     parent::__construct();
     $userData = OTRSGatewayUserHelper::getOTRSUserData();
     if ($userData != null) {
         $this->_userID = $userData[0];
         $this->_customerIDs = $userData[1];
     }
     $this->_gateway = new OTRSGatewayRPCHelper();
 }
예제 #2
0
/**
* OTRS Gateway Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string matching option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function plgSearchOTRSGateway($text, $phrase = '', $ordering = '', $areas = null)
{
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchOTRSGatewayAreas()))) {
            return array();
        }
    }
    $text = trim($text);
    if (empty($text)) {
        return array();
    }
    // Look for the OTRS Gateway component
    $com_otrsgateway =& JComponentHelper::getComponent('com_otrsgateway');
    if (!$com_otrsgateway) {
        return array();
    }
    // Load the Gateway helper library
    include_once JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_otrsgateway" . DS . "helpers" . DS . "rpchelper.php";
    include_once JPATH_SITE . DS . "components" . DS . "com_otrsgateway" . DS . "helpers" . DS . "userhelper.php";
    $userData = OTRSGatewayUserHelper::getOTRSUserData();
    if ($userData == null) {
        return array();
    }
    $vars = array('StateType' => array('Open', XSD_STRING), 'CustomerUserID' => array($userData[0], XSD_STRING), 'Result' => array('ARRAY', XSD_STRING), 'ContentSearch' => array('OR', XSD_STRING), 'IncludeDescription' => array(1, XSD_INTEGER), 'FullTextIndex' => array(1, XSD_INTEGER), 'Subject' => array('%' . mysql_real_escape_string($text) . '%', XSD_STRING), 'Body' => array('%' . mysql_real_escape_string($text) . '%', XSD_STRING));
    switch ($ordering) {
        case 'oldest':
            $vars['SortBy'] = array('Age', XSD_STRING);
            $vars['OrderBy'] = array('Up', XSD_STRING);
            break;
        default:
            $vars['SortBy'] = array('Age', XSD_STRING);
            $vars['OrderBy'] = array('Down', XSD_STRING);
    }
    $rows = array();
    $result = null;
    $gateway = new OTRSGatewayRPCHelper();
    if ($err = $gateway->callOTRS('JoomlaGatewayObject', 'TicketSearch', $vars, $result)) {
        // Failed to find anything
        return array();
    }
    if ($result == null) {
        return array();
    }
    foreach ($result as $ticket) {
        $item = new OTRSGatewaySearchResObj();
        $item->title = sprintf('[%s] %s', $ticket->TicketNumber, $ticket->Title);
        $item->href = JRoute::_('index.php?option=com_otrsgateway&view=ticket&ticketID=' . $ticket->TicketID);
        $item->created = (int) $ticket->CreateTimeUnix;
        $item->text = $ticket->Description;
        $rows[] = $item;
    }
    return $rows;
}
예제 #3
0
 /**
  * getOTRSTicketQueues
  *
  * Return the OTRS queues available
  */
 function getOTRSTicketQueues()
 {
     $userData = OTRSGatewayUserHelper::getOTRSUserData();
     if (!$userData || !is_array($userData)) {
         return null;
     }
     $vars = array('CustomerUserID' => array($userData[0], XSD_STRING));
     $gateway = new OTRSGatewayRPCHelper();
     if ($err = $gateway->callOTRS('JoomlaGatewayObject', 'GetTicketQueues', $vars, $result)) {
         // Failed to find anything
         return null;
     }
     if (!is_array($result)) {
         return null;
     }
     asort($result);
     return $result;
 }