示例#1
0
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @access	public
  * @param   array 	$credentials Array holding the user credentials
  * @param 	array   $options     Array of extra options
  * @param	object	$response	Authentication response object
  * @return	boolean
  * @since 1.5
  */
 function onAuthenticate($credentials, $options, &$response)
 {
     $message = '';
     $success = false;
     // Check the gateway component is installed
     $com_otrsgw =& JComponentHelper::getComponent('com_otrsgateway');
     if ($com_otrsgw) {
         // Check that it's configured
         $gwParams = new JParameter($com_otrsgw->params);
         include_once JPATH_SITE . DS . 'components' . DS . "com_otrsgateway" . DS . "helpers" . DS . "userhelper.php";
         if (strlen($credentials['username']) && strlen($credentials['password'])) {
             $gateway = new OTRSGatewayUserHelper();
             $authData = $gateway->authenticateOTRSUser(trim($credentials['username']), $credentials['password']);
             if (is_array($authData)) {
                 $success = true;
                 $response->email = $authData[0];
                 $response->fullname = $authData[1];
             } else {
                 $message = 'Access Denied';
             }
         } else {
             $message = 'Username or password blank';
         }
     } else {
         $message = "OTRS Gateway is not installed";
     }
     if ($success) {
         $response->status = JAUTHENTICATE_STATUS_SUCCESS;
         $response->error_message = '';
     } else {
         $response->status = JAUTHENTICATE_STATUS_FAILURE;
         $response->error_message = 'Failed to authenticate: ' . $message;
     }
 }
示例#2
0
 function __construct()
 {
     parent::__construct();
     $userData = OTRSGatewayUserHelper::getOTRSUserData();
     if ($userData != null) {
         $this->_userID = $userData[0];
         $this->_customerIDs = $userData[1];
     }
     $this->_gateway = new OTRSGatewayRPCHelper();
 }
示例#3
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;
}
示例#4
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;
 }