Ejemplo n.º 1
0
 protected function doSearch(PostArrayAdapter $params)
 {
     /*
      * Параметры
      */
     $process = $params->int('process');
     $action = $params->int('action');
     $actionParent = $params->int('parent_action');
     $dateFrom = $params->int('date_from');
     $dateTo = $params->int('date_to');
     /*
      * Запрос
      */
     $what[] = 'id_rec';
     $what[] = 'concat(ifnull(id_user, ""), concat("/", id_user_authed)) as user_authed';
     $what[] = 'dt_event';
     $what[] = 'n_action';
     $what[] = 'v_data';
     $what[] = 'b_encoded';
     $where['id_process'] = $process;
     if ($actionParent) {
         $where['id_rec_parent'] = $actionParent;
     }
     if ($action) {
         $where['n_action'] = $action;
     }
     if ($dateFrom) {
         $where[] = Query::assocParam('dt_event', $dateFrom, true, '>=');
     }
     if ($dateTo) {
         $where[] = Query::assocParam('dt_event', $dateTo, true, '<=');
     }
     $order = 'dt_event asc, id_rec asc';
     $limit = 500;
     /*
      * Работа с данными
      */
     $query = Query::select($what, 'ps_audit', $where, null, $order, $limit);
     $result = PSDB::getArray($query);
     foreach ($result as &$row) {
         //Декодируем действие
         $row['n_action'] = BaseAudit::getByCode($process)->decodeAction($row['n_action'], false);
         //Декодируем данные
         $encoded = 1 * $row['b_encoded'];
         if ($encoded) {
             $row['v_data'] = print_r(BaseAudit::decodeData($row['v_data']), true);
         }
         unset($row['b_encoded']);
     }
     $results = new SearchResults($result, $query);
     $results->addSetting('v_data', SearchResults::COL_PRE);
     $results->addSetting('n_action', SearchResults::COL_NOWRAP);
     return $results;
 }
Ejemplo n.º 2
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     PsDefines::assertProductionOff(__CLASS__);
     $text = $adapter->str('text');
     if (!$text) {
         return array('text', 'required');
     }
     $mtime = $adapter->int('mtime');
     ToDoFile::inst()->save($text, $mtime);
     return new AjaxSuccess();
 }
Ejemplo n.º 3
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $data = new RegFormData();
     /*
      * Имя пользователя
      */
     $name = $adapter->str(FORM_PARAM_REG_NAME);
     $error = UserInputValidator::validateShortText($name);
     if ($error) {
         return array(FORM_PARAM_REG_NAME => $error);
     }
     $name = UserInputTools::safeShortText($name);
     $data->setUserName($name);
     /*
      * e-mail
      */
     $mail = $adapter->str(FORM_PARAM_REG_MAIL);
     $error = UserInputValidator::validateEmail($mail);
     if ($error) {
         return array(FORM_PARAM_REG_MAIL => $error);
     }
     $data->setUserMail($mail);
     /*
      * Пол
      */
     $sex = $adapter->int(FORM_PARAM_REG_SEX);
     $error = UserInputValidator::validateSex($sex);
     if ($error) {
         return array(FORM_PARAM_REG_SEX => $error);
     }
     $data->setSex($sex);
     /*
      * Пароль
      */
     $pass = $adapter->str(FORM_PARAM_REG_PASS);
     $passConfirm = $adapter->str(FORM_PARAM_REG_PASS_CONF);
     $error = UserInputValidator::validatePass($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS => $error);
     }
     $error = UserInputValidator::validatePassConfirm($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS_CONF => $error);
     }
     $data->setPassword($pass);
     AuthManager::createUser($data);
     return new AjaxSuccess();
 }
Ejemplo n.º 4
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $data = new RegFormData();
     /*
      * Имя пользователя
      */
     $name = $adapter->str(FORM_PARAM_REG_NAME);
     $error = UserInputValidator::validateShortText($name);
     if ($error) {
         return array(FORM_PARAM_REG_NAME => $error);
     }
     $name = UserInputTools::safeShortText($name);
     $data->setUserName($name);
     /*
      * Пол
      */
     $sex = $adapter->int(FORM_PARAM_REG_SEX);
     $error = UserInputValidator::validateSex($sex);
     if ($error) {
         return array(FORM_PARAM_REG_SEX => $error);
     }
     $data->setSex($sex);
     /*
      * Обо мне
      */
     $about = $adapter->str(FORM_PARAM_REG_ABOUT);
     if ($about) {
         $error = UserInputValidator::validateLongText($about, false);
         if ($error) {
             return array(FORM_PARAM_REG_ABOUT => $error);
         }
         $data->setAboutSrc($about);
         $data->setAbout(UserInputTools::safeLongText($about));
     }
     /*
      * Контакты
      */
     $contacts = $adapter->str(FORM_PARAM_REG_CONTACTS);
     if ($contacts) {
         $error = UserInputValidator::validateLongText($contacts, false);
         if ($error) {
             return array(FORM_PARAM_REG_CONTACTS => $error);
         }
         $data->setContactsSrc($contacts);
         $data->setContacts(UserInputTools::safeLongText($contacts));
     }
     /*
      * Цитата
      */
     $msg = $adapter->str(FORM_PARAM_REG_MSG);
     if ($msg) {
         $error = UserInputValidator::validateLongText($msg, false);
         if ($error) {
             return array(FORM_PARAM_REG_MSG => $error);
         }
         $data->setMsgSrc($msg);
         $data->setMsg(UserInputTools::safeLongText($msg));
     }
     PsUser::inst()->updateInfo($data);
     return new AjaxSuccess();
 }