public function action() { Exits::exit403If(!Operator::currentOperatorHasAnyOfPermissions([Permissions::PERMISSION_PHPAUTH_MANAGE_GROUPS])); $group_obj = Group::factory($this->getGroupId()); Exits::exit403If(!OwnerCheck::currentUserOwnsObj($group_obj)); $html = ''; $html .= CRUDForm::html($group_obj, [new CRUDFormRow('Title', new CRUDFormWidgetInput(Group::_TITLE))]); $html .= self::adminParamsForm($this->group_id); $html .= self::usersInGroupTable($this->group_id); AdminLayoutSelector::render($html, $this); }
public function action() { Exits::exit403If(!Operator::currentOperatorHasAnyOfPermissions([Permissions::PERMISSION_PHPAUTH_MANAGE_USERS])); $user_id = $this->user_id; $user_obj = User::factory($user_id); Exits::exit403If(!OwnerCheck::currentUserOwnsObj($user_obj)); Operations::matchOperation(self::OPERATION_SET_PASSWORD, function () use($user_id) { $new_password = POSTAccess::getOptionalPostValue(self::FIELD_NAME_PASSWORD); $new_password_hash = password_hash($new_password, PASSWORD_BCRYPT); $user_obj = User::factory($user_id); $user_obj->setPasswordHash($new_password_hash); $user_obj->save(); }); $html = ''; $html .= '<div class="row"><div class="col-md-6">'; $html .= self::commonParamsForm($user_id); $html .= self::passwordForm(); $html .= self::userOperatorsTable($user_id); $html .= self::adminParamsForm($user_id); $html .= '</div><div class="col-md-6">'; if (Operator::currentOperatorHasAnyOfPermissions([Permissions::PERMISSION_PHPAUTH_MANAGE_USERS_PERMISSIONS])) { $html .= '<h2>Разрешения</h2>'; $html .= HTML::div('', '', function () use($user_id) { $new_permissiontouser_obj = new PermissionToUser(); $new_permissiontouser_obj->setUserId($user_id); echo CRUDTable::html(PermissionToUser::class, '', [new \OLOG\CRUD\CRUDTableColumn('Разрешение', new \OLOG\CRUD\CRUDTableWidgetText('{' . Permission::class . '.{this->permission_id}->title}')), new \OLOG\CRUD\CRUDTableColumn('Удалить', new \OLOG\CRUD\CRUDTableWidgetDelete())], [new CRUDTableFilterEqualInvisible('user_id', $user_id)], ''); echo CallapsibleWidget::buttonAndCollapse('Показать все неназначенные разрешения', function () use($user_id) { $html = CRUDTable::html(Permission::class, '', [new CRUDTableColumn('Разрешение', new CRUDTableWidgetTextWithLink('{this->title}', (new PermissionAddToUserAction($user_id, '{this->id}'))->url())), new CRUDTableColumn('', new CRUDTableWidgetTextWithLink('Добавить пользователю', (new PermissionAddToUserAction($user_id, '{this->id}'))->url(), 'btn btn-default btn-xs'))], [new CRUDTableFilterNotInInvisible('id', PermissionToUser::getPermissionIdsArrForUserId($user_id))], 'id', '79687tg8976rt87'); return $html; }); }); } $html .= self::userInGroupsTable($user_id); $html .= '</div></div>'; AdminLayoutSelector::render($html, $this); }