示例#1
0
 public function getUsersByGroup(groupModel $groupModel = null)
 {
     if ($groupModel === null) {
         $groupModel = $this;
     }
     $userMapper = userMapper::getInstance();
     return $userMapper->getAllBy([userMapper::FIELD__GROUPS => $groupModel->getIdValue()]);
 }
示例#2
0
 /**
  * Bind some custom actions
  *
  * @return mixed
  * @throws actionException
  */
 public function bind()
 {
     $userKey = userMapper::getInstance()->getKey();
     $groupKey = groupMapper::getInstance()->getKey();
     $this->registerAction('userManagement.main', new action(['name' => 'Панель управления', 'method' => '_main', 'path' => '/userManagement', 'http' => ['GET'], 'required' => [], 'useBase' => true, 'template' => 'userManagement/main.tpl', 'relative' => false, 'type' => action::TYPE__GLOBAL, 'acl' => []], $this));
     $this->registerAction('userManagement.groupUpdate', new action(['name' => 'Обновление группы', 'method' => '_groupUpdate', 'path' => "/groupUpdate/:{$groupKey}", 'http' => ['GET', 'POST'], 'required' => [$groupKey], 'useBase' => true, 'template' => 'userManagement/groupUpdate.tpl', 'relative' => false, 'type' => action::TYPE__DEFAULT, 'acl' => []], $this));
     $this->registerAction('userManagement.groupGet', new action(['name' => 'Просмотр группы', 'method' => '_groupGet', 'path' => "/groupGet/:{$groupKey}", 'http' => ['GET'], 'required' => [$groupKey], 'useBase' => true, 'template' => 'userManagement/groupGet.tpl', 'relative' => false, 'type' => action::TYPE__DEFAULT, 'acl' => []], $this));
     $this->registerAction('userManagement.userUpdate', new action(['name' => 'Обновление пользователя', 'method' => '_userUpdate', 'path' => "/userUpdate/:{$userKey}", 'http' => ['GET', 'POST'], 'required' => [$userKey], 'useBase' => true, 'template' => 'userManagement/userUpdate.tpl', 'relative' => false, 'type' => action::TYPE__DEFAULT, 'acl' => []], $this));
     $this->registerAction('userManagement.userGet', new action(['name' => 'Просмотр пользователя', 'method' => '_userGet', 'path' => "/userGet/:{$userKey}", 'http' => ['GET'], 'required' => [$userKey], 'useBase' => true, 'template' => 'userManagement/userGet.tpl', 'relative' => false, 'type' => action::TYPE__DEFAULT, 'acl' => []], $this));
     $this->registerAction('userManagement.userTokenUpdate', new action(['name' => 'Обновить пользовательский токен', 'method' => '_userTokenUpdate', 'path' => "/userTokenUpdate/:{$userKey}", 'http' => ['POST'], 'required' => [$userKey], 'useBase' => true, 'template' => 'json.pretty.tpl', 'relative' => false, 'type' => action::TYPE__DEFAULT, 'acl' => []], $this));
 }
示例#3
0
 /**
  * @param $cookieData
  *
  * @return mixed
  * @throws \mpcmf\modules\moduleBase\exceptions\modelException
  * @throws mapperException
  */
 public function getCurrentUser($cookieData)
 {
     if (!$cookieData) {
         static $guestCacheKey = 'acl/user/guest';
         if (!($guestData = cache::getCached($guestCacheKey))) {
             $guestModel = userMapper::getInstance()->getGuestUser();
             /** @noinspection ReferenceMismatchInspection */
             $guestData = $guestModel->export();
             cache::setCached($guestCacheKey, $guestData, 3600);
         } else {
             $guestModel = userModel::fromArray($guestData);
         }
         return $guestModel;
     }
     $userId = $cookieData[userMapper::FIELD__USER_ID];
     $userCacheKey = "acl/user/{$userId}";
     if (!($userData = cache::getCached($userCacheKey))) {
         $userModel = userMapper::getInstance()->getById($userId);
         /** @noinspection ReferenceMismatchInspection */
         $userData = $userModel->export();
         cache::setCached($userCacheKey, $userData, 300);
     } else {
         $userModel = userModel::fromArray($userData);
     }
     return $userModel;
 }
 public function _userTokenUpdate($userId)
 {
     try {
         /** @var userModel $user */
         $user = userMapper::getInstance()->getById($userId);
     } catch (mapperException $mapperException) {
         return self::errorByException($mapperException);
     }
     return tokenController::getInstance()->_token_generate($user);
 }