Ejemplo n.º 1
0
 function getAPIUserID()
 {
     static $user_id;
     if (!$user_id) {
         $user_id = APIAuthentication::getInstance()->authenticate();
     }
     return $user_id;
 }
Ejemplo n.º 2
0
 /**
  * Finds and calls the requested resource
  * @param	string	$resource_name	Requested resource name
  * @return	string
  */
 public final function fetchResource($resource_name = null)
 {
     if ($resource_name == null) {
         $resource_name = $this->get('resource');
     }
     $resource_obj = ApiResource::getInstance($resource_name, $this);
     if ($resource_obj === false) {
         $this->checkInternally($resource_name);
     }
     $access = $this->getResourceAccess($resource_name, $this->request_method);
     if ($access == 'protected') {
         $auth_handler = APIAuthentication::getInstance();
         $user = $auth_handler->authenticateRequest();
         if ($user === false) {
             throw new Exception($auth_handler->getError(), 403);
         }
         $this->set('user', $user);
     }
     if (!$this->checkRequestLimit()) {
         throw new Exception(JText::_('COM_API_RATE_LIMIT_EXCEEDED'), 403);
     }
     $this->log();
     if ($resource_obj !== false) {
         $resource_obj->invoke();
     } else {
         call_user_func(array($this, $resource_name));
     }
     $output = $this->encode();
     return $output;
 }