protected function loadApiOperations() { \EventController::callEvent(ApiOperation::EventName); $this->add(new TestApiOperation()); $this->add(new TestApiOperationWithParams()); $this->add(new TestApiWithACLOperation()); }
public function prepareRequest() { parent::prepareRequest(); if (!defined('CMS')) { define('CMS', 1); } // Activate CMS auth \CMS_Strings::getInstance()->setActiveLang('RUSSIAN'); \EventController::callEvent('dashboardInit'); }
protected function action() { $this->searchPhrase = $this->getParam('request'); $this->searchUsers(); $this->searchSitemap(); $results = \EventController::callEvent(self::EventName, [$this->searchPhrase, $this->results]); foreach ($results as $row) { $this->results = array_merge($this->results, $row); } return ['items' => $this->results]; }
/** * Метод выводит форму редактирования существующего аккаунта * @return */ public function showAdminUpdate($id) { try { $oAccount = $this->getUser($id); // Готовим данные для вывода $szTitle = 'Просмотр и редактирование профиля "' . htmlspecialchars($oAccount->login) . '"'; $aBegin = array('Пользователи' => 'index.php', $szTitle => '#'); $tabSheets = array(array('id' => 'tab_main', 'title' => 'Авторизация'), array('id' => 'tab_additional', 'title' => 'Доп. данные')); // Начало вывода $design = \CMSDesign::getInstance(); $this->outputHeader($aBegin, $szTitle); $design->formBegin(); $design->submit('submit', 'Сохранить'); $design->tabs->sheetsBegin($tabSheets); $design->tabs->contentBegin($tabSheets[0]['id']); $design->tableBegin(); // Обязательные поля $design->row2cell('Логин пользователя', $oAccount->login->getAdminFormValue()); $design->row2cell('Зарегистрирован', $oAccount->registered->getCyrilicViewValue()); $design->row2cell('Последняя активность', \DateHelper::getCyrilicViewValue($oAccount->last_activity_date->getValue())); $design->row2cell('Пароль', $oAccount->password->getAdminFormValue()); $design->row2cell('Код подтверждения авторизации', $oAccount->confirmation_code->getAdminFormValue()); $design->row2cell('E-mail', $oAccount->email->getAdminFormValue()); $design->row2cell('Права пользователя', $oAccount->rights->getAdminFormValue()); $design->row2cell('Время доступа', $oAccount->time_access->getAdminFormValue()); $design->tableEnd(); $design->tabs->contentEnd(); $design->tabs->contentBegin($tabSheets[1]['id']); $design->tableBegin(); \EventController::callEvent('users_admin_update_form', $oAccount, $design); $design->tableEnd(); $design->tabs->contentEnd(); $design->tabs->sheetsEnd(); // Завершаем вывод $design->hidden('id', $oAccount->id->getValue()); $design->hidden('typeName', UserAccount::ModelName); $design->submit('submit', 'Сохранить'); $design->formEnd(); $design->documentEnd(); $design->end(); $this->output(); } catch (\Exception $e) { $this->addError('Профайл не был найден'); $this->jumpBack(); } }
public function __construct(Dispatcher $dispatcher, $environment = null) { if (empty(self::$instance)) { self::$instance = $this; } \Trace::addMessage('CMS', 'CMS::load'); $this->loadEnvironment($environment); \Faid\DB::checkConnection(); SystemRegisterSample::startup(); $this->dispatcher = $dispatcher; self::autoloadConfig(); $this->initializeRoutes(); $this->initializeApis(); \Trace::addMessage('CMS', '`init` event'); \EventController::callEvent(self::SystemInitEvent, $this); $this->processSecurity(); \Trace::addMessage('CMS', 'Стартовало'); }
public static function signup($login, $password, $email, $aData) { self::validateLogin($login); self::validateEmail($email); // Проверка данных EventController::callEvent('users_registration_check_data', $login, $password, $email, $aData); // Проверка существования логина и почты self::checkLoginOrEmailExists($login, $email); $register = new SystemRegister('Applications/users/front-end/'); // Если требуется подтвержденте if ($register->account_confirmation->value) { // Код подтверждения $aData['confirmation_code'] = self::getConfirmationCode(); } // $aData['login'] = $login; $aData['email'] = $email; $user = new UserAccount($aData); $user->obj_password->setValue($password); $user->insert(); // Добавлени в базу $aData['id'] = $user->id->getValue(); $aData['password'] = $password; // Вызов события EventController::callEvent('users_registration_after_signup', $aData, $user); // // Если требуется подтверждение if ($register->account_confirmation->value) { // Высылка письма self::sendEmailConfirmation($aData); } else { UsersLogin::login($login, $password); } if ($register->account_registration_success_email->value) { // Высылка письма self::sendEmailRegistration($aData); } return $aData['id']; }
protected function appendGlobalTemplateEventData($events) { array_unshift($events, 'get_global_template_data'); foreach ($events as $row) { $tmpData = EventController::callEvent($row, $this->aParse); if (is_array($tmpData)) { foreach ($tmpData as $row) { if (is_array($row)) { $this->aParse = array_merge($this->aParse, $row); } } } } }
/** * Удаляет учетную запись * @return */ public function delete() { $data = UsersDBManager::get($this->id->getValue()); if (!empty($data['persistent'])) { return; } $granted = EventController::callFilter('users_account_before_delete', $this); // if granted then call standart removing if (!empty($granted)) { parent::delete($granted); } else { return; } EventController::callEvent('users_account_after_delete', $this); }
/** * * @param array $data хеш массив в формате имя котрола, значение */ public function setValues($data) { foreach ($data as $key => $row) { try { $control = $this->searchControlByName($key); } catch (Exception $e) { continue; } $control->setValue($row); } EventController::callEvent(self::EventName, $this); }
protected function changeLogin($password, $login) { $login = \Faid\DB::$connection->real_escape_string($login); $oUser = UsersLogin::getCurrentSession(); if ($login == $oUser->login->getValue()) { return; } if ($this->register->get('front-end')->ignore_password_field->value == 0) { $isSamePassword = $this->checkPassword($password, $oUser); if (!$isSamePassword) { $this->addValidationError('updatePassword'); return; } } $sql = 'SELECT * FROM `%s` WHERE `login` = "%s" and `id` <> %d'; $sql = sprintf($sql, USERS_TABLE, $login, $oUser->id->getValue()); // $aGet = DB::get($sql); // Ого! уже есть акк с таким емейлом, навиду подстава! ;) if (!empty($aGet)) { $this->addValidationError('updateLogin'); return; } $old_login = $oUser->email->getValue(); $oUser->login - setValue($login); $oUser->update(); EventController::callEvent('users_after_update_login', $oUser, $old_login, $login); $this->addSuccess('updateLogin'); }
/** * Загружает из бд данные о пользователе и если он есть сохраняет в св-ве aUser */ public function processUser() { try { $notAuthorizedAction = empty($this->user) || !$this->isAdmin($this->user); if ($notAuthorizedAction) { UsersLogin::logout(); throw new \ForbiddenException('Access denied. Only administrators & auditors permitted'); } EventController::callEvent(self::EventName, $this); } catch (Exception $e) { $this->user = null; throw $e; } }
/** * * @param unknown $code */ public function confirm($code) { if (!empty($code)) { $oAccount = self::getByCode($code); } if (!empty($oAccount)) { $oAccount->confirmation_code = ''; $oAccount->update(); UsersLogin::forceLogin($oAccount); EventController::callEvent('users_registration_after_confirm', $oAccount); $bFailed = false; $this->addAlert('Аккаунт активирован'); $this->jump('/'); } else { $bFailed = true; } $this->aParse['pageMeta'] = UsersModule::getMeta(UsersRegistration::RegistrationConfigName); $this->aParse['isCodeEmpty'] = empty($code); $this->aParse['bFailed'] = $bFailed; $this->output('users/registration/confirm'); }
/** * */ public static function logout() { if (self::isLogined()) { EventController::callEvent('users_after_logout'); try { $user = self::getCurrentUser(); CMSLog::addMessage(__CLASS__, sprintf('User `%s` logged out', $user->login->getValue())); } catch (\Exception $e) { $short = 'Failed to logout user. Probably, there is an issue inside User Sesison'; $full = sprintf("%s\r\n%s", $short, $e); Record::add(__CLASS__, $short, $full); } } self::unsetSession(); self::$currentUser = null; }