public function _groupUpdate($id)
 {
     try {
         /** @var groupModel $group */
         $group = groupMapper::getInstance()->getById($id);
     } catch (mapperException $mapperException) {
         return self::errorByException($mapperException, $mapperException->getCode());
     }
     if ($this->getSlim()->request()->isPost()) {
         $inputItem = $this->getSlim()->request()->post('item');
         $item = $group->getMapper()->convertDataFromForm($inputItem, $group);
         if (!$this->checkInputByValidator($item, $errors)) {
             return self::error(['item' => $group, 'errors' => $errors], codes::RESPONSE_CODE_FORM_FIELDS_ERROR);
         }
         try {
             $group->updateFields($item);
         } catch (modelException $exception) {
             return self::errorByException($exception, codes::RESPONSE_CODE_FAIL);
         }
         try {
             $result = $group->getMapper()->updateById($id, $group);
         } catch (mapperException $mapperException) {
             return self::errorByException($mapperException, codes::RESPONSE_CODE_FAIL);
         }
         return self::success(['result' => $result, 'group' => $group], codes::RESPONSE_CODE_SAVED);
     }
     return self::nothing(['group' => $group]);
 }
示例#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 array $groupsList
  *
  * @return mixed
  * @throws \InvalidArgumentException
  * @throws \MongoConnectionException
  * @throws \MongoCursorException
  * @throws configurationException
  * @throws storageException
  * @throws \Exception
  */
 public function createGroupsByList(array $groupsList)
 {
     foreach ($groupsList as $groupName) {
         groupMapper::getInstance()->updateBy([groupMapper::FIELD__GROUP_ALIAS => $groupName], [groupMapper::FIELD__GROUP_ALIAS => $groupName, groupMapper::FIELD__GROUP_NAME => $groupName], ['upsert' => true]);
     }
 }