function display($tpl = null) { JToolBarHelper::title(JText::_('OTRS_GATEWAY'), ''); JToolBarHelper::preferences('com_otrsgateway', '350'); $document =& JFactory::getDocument(); $document->setTitle(JText::_('OTRS_GATEWAY')); // Work out the current status of the module $summary = array(JText::_('OTRS_UNCONFIGURED')); $config =& JComponentHelper::getParams('com_otrsgateway'); if (class_exists('SoapClient')) { if ($config->get('otrsgateway_rpc_url') && $config->get('otrsgateway_rpc_user') && $config->get('otrsgateway_rpc_password')) { $summary = array(); $result = null; $vars = array('SystemID' => array(false, XSD_BOOLEAN)); $gateway = new OTRSGatewayRPCHelper(); if ($err = $gateway->callOTRS('TimeObject', 'CurrentTimestamp', $vars, $result)) { $summary[] = $err; } else { if ($result) { $summary[] = JText::_('OTRS_CONNECTED'); } else { $summary[] = JText::_('OTRS_GATEWAY_AUTH'); } if (!function_exists('json_encode')) { $summary[] = JText::_('OTRS_GATEWAY_NEED_JSON'); } } } } else { $summary[] = JText::_('OTRS_NO_SOAP'); } $this->assignRef('summary', $summary); parent::display($tpl); }
/** * 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; }
/** * authenticateOTRSUser * Return a email, full name for an active user account given the * user credentials */ function authenticateOTRSUser($login = '', $pwd = '') { $vars = array('User' => array($login, XSD_STRING), 'Pw' => array($pwd, XSD_STRING)); $result = null; $gateway = new OTRSGatewayRPCHelper(); if ($err = $gateway->callOTRS('JoomlaGatewayObject', 'AuthenticateOTRSUser', $vars, $result)) { // Failed to find anything return null; } else { if (is_array($result) && count($result) > 1) { return $result; } } return null; }
/** * 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; }