Beispiel #1
0
 private function jsCommon()
 {
     $params['url'] = PsUrl::current();
     $params['userId'] = AuthManager::getUserIdOrNull();
     $params['isAuthorized'] = AuthManager::isAuthorized();
     $params['isDOA'] = PsSettings::DEVMODE_OR_ADMIN();
     $params['isLogging'] = PsSettings::DEVMODE_OR_ADMIN();
     $params['currentSubmitTimeout'] = ActivityWatcher::getWaitTime();
     $params['tzOffset'] = PsTimeZone::inst()->getCurrentDateTimeZone()->getOffset(new DateTime());
     $params['marker'] = AuthManager::getUserSessoinMarker();
     $params['foldings'] = FoldedStorage::listEntitiesRel();
     return $params;
 }
Beispiel #2
0
 private function jsCommon(PageContext $ctxt)
 {
     $params['url'] = $ctxt->getRequestUrl();
     $params['isPopup'] = $ctxt->isPopupPage();
     $params['userId'] = AuthManager::getUserIdOrNull();
     $params['isAuthorized'] = AuthManager::isAuthorized();
     $params['isDOA'] = PsSettings::DEVMODE_OR_ADMIN();
     $params['isLogging'] = PsSettings::DEVMODE_OR_ADMIN();
     $params['currentSubmitTimeout'] = ActivityWatcher::getWaitTime();
     $params['tzOffset'] = PsTimeZone::inst()->getCurrentDateTimeZone()->getOffset(new DateTime());
     $params['marker'] = AuthManager::getUserSessoinMarker();
     /* @var $folding FoldedResources */
     foreach (Handlers::getInstance()->getFoldingsIndexed() as $unique => $folding) {
         $params['foldings'][$unique] = $folding->getResourcesDm()->relDirPath();
     }
     return $params;
 }
 /**
  * Основной метод, выполняющий выполнение Ajax действия.
  * 
  * @return AjaxSuccess
  */
 public final function execute()
 {
     $id = get_called_class();
     check_condition(!$this->processed, "Действие [{$id}] уже выполнено.");
     $this->processed = true;
     //Не будем портить глобальный массив $_REQUEST, создав копию адаптера
     $params = RequestArrayAdapter::inst()->copy();
     check_condition($params->str(AJAX_ACTION_PARAM) == $id, "Действие [{$id}] не может быть выполнено.");
     $params->remove(AJAX_ACTION_PARAM);
     $params->remove(AJAX_ACTION_GROUP_PARAM);
     //Проверка доступа
     AuthManager::checkAccess($this->getAuthType());
     //Если пользователь зарегистрирован, как администратор - подключим ресурсы админа
     //ps_admin_on();
     //Проверка обязательных параметров
     foreach (to_array($this->getRequiredParamKeys()) as $key) {
         if (!$params->has($key)) {
             return "Не передан обязательный параметр [{$key}].";
         }
     }
     //Проверка активности
     if ($this->isCheckActivity() && !ActivityWatcher::isCanMakeAction()) {
         return 'Таймаут не закончился.';
     }
     //Вызываем обработку данных
     PsProfiler::inst('AjaxProfiler')->start($id);
     $result = $this->executeImpl($params);
     PsProfiler::inst('AjaxProfiler')->stop();
     if (isEmpty($result)) {
         return "Действие [{$id}] выполнено некорректно - возвращён пустой результат.";
     }
     if (is_object($result) && $result instanceof AjaxSuccess) {
         //SUCCESS
         //Зарегистрируем активноcть пользователя (только в случае успеха, так как пользователь мог просто ошибиться в воде данных)
         if ($this->isCheckActivity()) {
             ActivityWatcher::registerActivity();
         }
     }
     return $result;
 }
Beispiel #4
0
 /**
  * Основной метод, выполняющий обработку формы.
  * 
  * @return AbstractForm
  */
 private final function process()
 {
     if ($this->processed) {
         return $this;
         //---
     }
     $this->processed = true;
     if (!$this->isTryingSubmit()) {
         return $this;
         //---
     }
     //Проверка доступа
     $this->checkAccess();
     if ($this->isAddCapture() && !PsCapture::isValid()) {
         $this->error = 'Требуется валидный код с картинки';
         return $this;
         //---
     }
     //Если пользователь зарегистрирован, как администратор - подключим ресурсы админа
     ps_admin_on();
     $button = $this->getSubmittedButton();
     if (!$button) {
         $this->error = "Не передана нажатая кнопка для формы {$this->ident}.";
         return $this;
         //---
     }
     if (!$this->hasButton($button)) {
         $this->error = "Форма {$this->ident} засабмичена незарегистрированной кнопкой {$button}.";
         return $this;
         //---
     }
     if ($this->isCheckActivity() && !ActivityWatcher::isCanMakeAction()) {
         $this->error = 'Таймаут не закончился.';
         return $this;
         //---
     }
     //Вызываем обработку данных
     $result = null;
     try {
         $result = $this->processImpl(PostArrayAdapter::inst(), $button);
     } catch (Exception $ex) {
         $this->error = $ex->getMessage();
         ExceptionHandler::dumpError($ex);
         return $this;
         //---
     }
     if (isEmpty($result)) {
         $this->error = "Форма {$this->ident} обработана некорректно - возвращён пустой объект.";
         return $this;
         //---
     }
     if (is_object($result) && $result instanceof FormSuccess) {
         //SUCCESS
         //Форсированно сбросим капчу (всё равно, работаем с ней или нет)
         PsCapture::reset();
         //Зарегистрируем активноcть пользователя (только в случае успеха, так как пользователь мог просто ошибиться в воде данных)
         if ($this->isCheckActivity()) {
             ActivityWatcher::registerActivity();
         }
         $this->result = $result;
     } else {
         //ERROR
         $this->error = $result;
     }
     return $this;
 }