public function action() { Exits::exit403If(!Operator::currentOperatorHasAnyOfPermissions([Permissions::PERMISSION_PHPAUTH_MANAGE_OPERATORS])); $operator_id = $this->operator_id; $operator_obj = Operator::factory($operator_id); $html = '<div class="col-md-6">'; $html .= '<h2>Параметры</h2>'; $html .= CRUDForm::html($operator_obj, [new CRUDFormRow('title', new CRUDFormWidgetInput('title')), new CRUDFormRow('описание', new CRUDFormWidgetTextarea('description')), new CRUDFormRow('User id', new CRUDFormWidgetReferenceAjax('user_id', User::class, 'login', (new UsersListAjaxAction())->url(), (new UserEditAction('REFERENCED_ID'))->url()))]); $new_operator_permission_obj = new OperatorPermission(); $new_operator_permission_obj->setOperatorId($operator_id); $html .= '</div><div class="col-md-6">'; if (Operator::currentOperatorHasAnyOfPermissions([Permissions::PERMISSION_PHPAUTH_MANAGE_OPERATORS])) { $html .= '<h2>Назначенные разрешения</h2>'; $html .= HTML::div('', '', function () use($operator_id) { $new_permissiontouser_obj = new OperatorPermission(); $new_permissiontouser_obj->setOperatorId($operator_id); echo CRUDTable::html(OperatorPermission::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('operator_id', $operator_id)], ''); echo CallapsibleWidget::buttonAndCollapse('Показать все неназначенные разрешения', function () use($operator_id) { $html = CRUDTable::html(Permission::class, '', [new CRUDTableColumn('Разрешение', new CRUDTableWidgetTextWithLink('{this->title}', (new PermissionAddToOperatorAction($operator_id, '{this->id}'))->url())), new CRUDTableColumn('', new CRUDTableWidgetTextWithLink('Добавить оператору', (new PermissionAddToOperatorAction($operator_id, '{this->id}'))->url(), 'btn btn-default btn-xs'))], [new CRUDTableFilterNotInInvisible('id', OperatorPermission::getPermissionIdsArrForOperatorId($operator_id))], 'id', '79687tg8976rt87'); return $html; }); }); } $html .= '</div>'; AdminLayoutSelector::render($html, $this); }
public function getHtml() { $html = HTML::div('js-filter', '', function () { $input_name = $this->getFilterIniqId(); /** * отдельное поле, наличие которого сообщает что фильтр присутствует в форме * (все другие поля могут отсутствовать когда фильтр например запрещен и т.п.) */ echo '<input type="hidden" name="' . $this->filterIsPassedInputName() . '" value="1">'; echo '<input type="hidden" name="' . $this->enabledCheckboxInputName() . '" value="' . ($this->isEnabled() ? '1' : '') . '">'; echo '<span onclick="f' . $input_name . '_changeFiltres(this);" class="btn btn-xs btn-default ' . ($this->isEnabled() ? '' : 'active') . '">' . $this->getBtnAllText() . '</span>'; echo '<input type="hidden" name="' . $input_name . '" value="' . ($this->isEnabled() ? $this->getValue() : '') . '">'; $options_arr = $this->getOptionsArr(); foreach ($options_arr as $value => $title) { echo '<span data-value="' . $value . '" data-enabled="1" onclick="f' . $input_name . '_changeFiltres(this);" class="btn btn-xs btn-default ' . ($this->isEnabled() && $this->getValue() == $value ? 'active' : '') . '">' . $title . '</span>'; } if ($this->getShowNullCheckbox()) { echo '<input type="hidden" name="' . $this->nullCheckboxInputName() . '" value="' . (is_null($this->getValue()) && $this->isEnabled() ? '1' : '') . '">'; echo '<span data-isnull="1" data-enabled="1" onclick="f' . $input_name . '_changeFiltres(this);" class="btn btn-xs btn-default ' . (is_null($this->getValue()) && $this->isEnabled() ? 'active' : '') . '">Не указано</span>'; } }); $input_name = $this->getFilterIniqId(); ob_start(); ?> <script> function f<?php echo $input_name; ?> _changeFiltres(select_element){ var $this = $(select_element); var $form = $this.closest('form'); var $filter = $this.closest('.js-filter'); $filter.find('.btn').removeClass('active'); $this.addClass('active'); var enabled = $this.data('enabled') || ''; var value = $this.data('value') || ''; var isnull = $this.data('isnull') || ''; $filter.find('[name="<?php echo $this->enabledCheckboxInputName(); ?> "]').val(enabled); $filter.find('[name="<?php echo $input_name; ?> "]').val(value); $filter.find('[name="<?php echo $this->nullCheckboxInputName(); ?> "]').val(isnull); $form.submit(); } </script> <?php $script = ob_get_clean(); return $html . $script; }
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); }
protected static function filtersHtmlInline($table_index_on_page, $filters_arr) { if (empty($filters_arr)) { return ''; } $html = HTML::div('filters-inline', '', function () use($table_index_on_page, $filters_arr) { echo '<form class="filters-form">'; foreach ($filters_arr as $filter_obj) { if ($filter_obj instanceof InterfaceCRUDTableFilter2) { echo '<div style="display: inline-block;margin-right: 10px;">'; if ($filter_obj->getTitle()) { echo '<span style="display: inline-block;margin-right: 5px;">' . $filter_obj->getTitle() . '</span>'; } echo '<span style="display: inline-block;">' . $filter_obj->getHtml() . '</span>'; echo '</div>'; } elseif ($filter_obj instanceof InterfaceCRUDTableFilterInvisible) { // do nothing with invisible filters } else { throw new \Exception('filter doesnt implement interface ...'); } } echo '</form>'; }); return $html; }