Пример #1
0
 function __construct(JMPlugin $plugin)
 {
     parent::__construct($plugin);
     $auth_handler = JMAuthentication::getInstance('user');
     $user_id = $auth_handler->authenticate();
     if (false === $user_id) {
         throw new Exception($auth_handler->getError(), 403);
     }
     $this->plugin->setResourceAccess(array('token'), 'public');
     // $this->plugin->set('skip_request_limit', true);
     $this->plugin->set('user', $user_id);
 }
Пример #2
0
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     $this->loadLanguage();
     JMResource::addIncludePath(JPATH_PLUGINS . DS . 'jm' . DS . 'core' . DS . 'resources');
 }
Пример #3
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 = JMResource::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 = JMAuthentication::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_JM_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;
 }
Пример #4
0
 public function toArray()
 {
     return JMResource::getErrorResponse($this->code, $this->message);
 }