Exemple #1
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $testingId = $params->int('id');
     $tasks = $params->arr('tasks');
     $time = $params->int('time');
     TestingManager::getInstance()->updateTestingResults($testingId, $time, $tasks);
     $pointsGiven = PL_testing::inst()->givePoints(PsUser::inst(), $testingId);
     return new AjaxSuccess($pointsGiven);
 }
Exemple #2
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $id = $params->int('id');
     $uts = $params->int('date');
     $show = $params->bool('show');
     $type = $params->str('type');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
     AdminPostsBean::inst()->updateState($pp->dbBean(), $id, $uts, $show);
     return new AjaxSuccess();
 }
Exemple #3
0
 public function doProcess(ArrayAdapter $params)
 {
     $postId = $params->int('postId');
     $postType = $params->str('postType');
     $this->postCP = Handlers::getInstance()->getPostsProcessorByPostType($postType)->getPostContentProvider($postId);
     check_condition(!!$this->postCP, "Not found post with id='{$postId}' for post type='{$postType}'");
 }
Exemple #4
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $unique = $params->str(DiscussionController::JS_DATA_UNIQUE);
     $upDown = $params->bool(DiscussionController::JS_DATA_UPDOWN);
     $entity = $params->str(DiscussionController::JS_DATA_THREAD);
     $theme = $params->str(self::JS_PARAM_THEME);
     $comment = $params->str(self::JS_PARAM_COMMENT);
     $parentId = $params->int(self::JS_PARAM_PARENT_ID);
     $controller = Handlers::getInstance()->getDiscussionController($unique);
     //Валидируем тему
     if (!$parentId && $controller->getDiscussionSettings()->isThemed()) {
         if (!$theme) {
             return 'Введите тему';
         }
         $error = UserInputValidator::validateShortText($theme);
         if ($error) {
             return $error;
         }
         $theme = UserInputTools::safeShortText($theme);
     }
     //Валидируем комментарий
     if (!$comment) {
         return 'Введите комментарий';
     }
     $error = UserInputValidator::validateLongText($comment);
     if ($error) {
         return $error;
     }
     $comment = UserInputTools::safeLongText($comment);
     $msgObj = $controller->saveMessage($entity, $parentId, $comment, $theme, PsUser::inst());
     if (!$msgObj instanceof DiscussionMsg) {
         return 'Ошибка добавления сообщения';
     }
     return new AjaxSuccess($controller->buildLeaf($msgObj));
 }
Exemple #5
0
 public function doProcess(ArrayAdapter $params)
 {
     $postId = $params->int('postId');
     $postType = $params->str('postType');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($postType);
     $this->postCP = $pp->getPostContentProvider($postId);
 }
Exemple #6
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $unique = $params->str(DiscussionController::JS_DATA_UNIQUE);
     $upDown = $params->bool(DiscussionController::JS_DATA_UPDOWN);
     $entity = $params->int(DiscussionController::JS_DATA_THREAD);
     $action = $params->str(self::JS_PARAM_ACTION);
     $msgId = $params->int(self::JS_PARAM_MSG_ID);
     $rootId = $params->int(self::JS_PARAM_ROOT_ID);
     $controller = Handlers::getInstance()->getDiscussionController($unique);
     if (in_array($action, DiscussionController::getCommentActions())) {
         return new AjaxSuccess($controller->executeCommentAction($msgId, $action));
     }
     if ($action == DiscussionController::TREE_ACTION_LOAD_COMMENTS) {
         return new AjaxSuccess($controller->loadTree($rootId, $upDown, $entity));
     }
     return "Неизвестное действие: [{$action}]";
 }
Exemple #7
0
 public function __construct($mandatory = true, $fileFormParam = FORM_PARAM_FILE)
 {
     if (!array_key_exists($fileFormParam, $_FILES)) {
         check_condition(!$mandatory, "Ключ [{$fileFormParam}] не найден в массиве файлов");
         return;
         //---
     }
     $this->params = ArrayAdapter::inst($_FILES[$fileFormParam]);
     $code = $this->params->int('error');
     if (!$mandatory && $code == UPLOAD_ERR_NO_FILE) {
         return;
         //---
     }
     check_condition($code == UPLOAD_ERR_OK, $this->getErrorDescription($code));
     $tmpName = $this->params->str('tmp_name');
     check_condition(is_uploaded_file($tmpName), 'Файл не является загруженным');
     $size = $this->params->int('size');
     check_condition($size > 0 && $size <= UPLOAD_MAX_FILE_SIZE, "Недопустимый размер загружаемого файла: {$size} байт.");
     $this->valid = true;
 }
Exemple #8
0
 public function getPluginContent($content, ArrayAdapter $params, PluginFetchingContext $ctxt)
 {
     $id = $params->int('id');
     $name = $params->str('test_name');
     $minutes = $params->int('time');
     $tasksCnt = $ctxt->getTasksCount();
     $result = null;
     $testing = null;
     if ($id) {
         $testing = TestingBean::inst()->updateTestingState($id, $name, $tasksCnt, $minutes);
         $result = TestingManager::getInstance()->getTestingResults($testing->getTestingId());
     }
     $tplData = $params->getData();
     $tplData['testing'] = $testing;
     $tplData['tasks'] = $content;
     $tplData['results'] = $result;
     $tplData['tasks_cnt'] = $tasksCnt;
     $content = $this->getFoldedEntity()->fetchTpl($tplData);
     $data = $testing ? $testing->getTestingId() : null;
     return new PluginContent($content, $data);
 }
Exemple #9
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $name = $params->str('name');
     $type = $params->str('type');
     $ident = $params->str('ident');
     $rubId = $params->int('rubId');
     check_condition($name, 'Name is empty');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
     $pp->getFolding()->assertExistsEntity($ident);
     AdminPostsBean::inst()->registerPost($pp->dbBean(), $ident, $name, $rubId);
     return new AjaxSuccess();
 }
Exemple #10
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $id = $params->int('id');
     //feedId or userId - в зависимости от action
     $action = $params->str('action');
     $res = 'OK';
     switch ($action) {
         case 'delete':
             AdminFeedbackBean::inst()->deleteAnonimMsg($id);
             break;
         case 'load':
             //id = userId
             $res = FeedbackManager::inst()->buildDiscussion(false, $id, false);
             break;
         default:
             raise_error("Unknown action: {$action}");
     }
     return new AjaxSuccess($res);
 }
Exemple #11
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $avatarId = $params->int('id');
     //Может быть передан и PsConstJs::AVATAR_NO_SUFFIX, а значит - null
     $action = $params->str('action');
     $USER = PsUser::inst();
     switch ($action) {
         case 'set':
             check_condition($USER->setAvatar($avatarId), 'Ошибка установки текущего аватара.');
             break;
         case 'del':
             check_condition($USER->deteleAvatar($avatarId), 'Ошибка удаления аватара.');
             break;
         default:
             raise_error("Неизвестное действие [{$action}].");
     }
     $result['id'] = $USER->hasAvatar() ? $USER->getAvatarId() : PsConstJs::AVATAR_NO_SUFFIX;
     $result['src_big'] = $USER->getAvatarRelPath(PsUser::ID_CARD_AVATAR_DIM);
     return new AjaxSuccess($result);
 }
 protected function executeImpl(ArrayAdapter $params)
 {
     $action = $params->str('action');
     $date = $params->int('date');
     $res = array();
     switch ($action) {
         case 'search':
             $res = AdminAuditTools::getAuditStatistic($date);
             break;
         case 'dump':
             $where[] = Query::assocParam('dt_event', $date, true, '<=');
             $order[] = 'dt_event asc';
             $zipDi = AdminTableDump::dumpTable('id_rec', 'ps_audit', $where, $order);
             check_condition($zipDi instanceof DirItem, 'Ошибка снятия дампа. Смотрите лог для деталей.');
             $res['path'] = $zipDi->getAbsPath();
             break;
         case 'load-dumps':
             $res['dumps'] = AP_APAudit::getInstance()->getAuditDumpsInfo();
             break;
         default:
             raise_error("Unknown action: {$action}");
     }
     return new AjaxSuccess($res);
 }
Exemple #13
0
 protected function executeImpl(ArrayAdapter $params)
 {
     UtilsBean::inst()->removeMissprint($params->int('id'));
     return new AjaxSuccess();
 }
Exemple #14
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $post_id = $params->int('id');
     TrainManager::inst()->toggleLessonState($post_id);
     return new AjaxSuccess();
 }
Exemple #15
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $testingResId = $params->int('id');
     TestingManager::getInstance()->dropTestingResults($testingResId);
     return new AjaxSuccess();
 }
Exemple #16
0
 protected function executeImpl(ArrayAdapter $params)
 {
     return new AjaxSuccess(PsUser::inst($params->int('id'))->getIdCardContent());
 }
Exemple #17
0
 /**
  * Действия
  */
 public function ajaxDeleteAnswer(ArrayAdapter $params)
 {
     MosaicImage::inst($this->imgId)->delUserAnswer($params->int('id'));
     return new AjaxSuccess();
 }