Пример #1
0
 protected function processBeforeAction($actionName)
 {
     if ($actionName != 'start' && $this->request->getQuery('document_action') != 'start') {
         //todo hack. SocServ set backurl!
         if (strpos($_SERVER['HTTP_REFERER'], 'tools/oauth') !== false) {
             $uri = \CHTTP::urlDeleteParams($this->request->getRequestUri(), array("sessid", "document_action"));
             $uri = \CHTTP::urlAddParams($uri, array('document_action' => 'start'));
             //restart process after authorization in social services
             LocalRedirect($uri);
         }
     }
     if ($this->isActionWithExistsFile()) {
         $this->initializeData();
         $this->checkReadPermissions();
     }
     if ($actionName != 'start') {
         if (!$this->initializeDocumentService()) {
             $this->sendJsonErrorResponse();
         }
         if (!$this->documentHandler->checkAccessibleTokenService()) {
             $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE', array('#NAME#' => $this->documentHandler->getName())), self::ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE)));
             $this->errorCollection->add($this->documentHandler->getErrors());
             $this->sendJsonErrorResponse();
         }
         if (!$this->documentHandler->queryAccessToken()->hasAccessToken() || $this->documentHandler->isRequiredAuthorization()) {
             $this->sendNeedAuth();
         }
     }
     return true;
 }