public function search($params) { $query = AuthItem::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->defaultOrder = ['name' => SORT_ASC]; if (!($this->load($params) && $this->validate())) { $this->addCondition($query, 'type'); return $dataProvider; } $this->addCondition($query, 'name', true); $this->addCondition($query, 'type'); $this->addCondition($query, 'description', true); $this->addCondition($query, 'rule_name', true); $this->addCondition($query, 'data', true); return $dataProvider; }
$this->params['breadcrumbs'][] = ['label' => Yii::t('maddoger/user', 'Users'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-view"> <p> <?php echo Html::a(Yii::t('maddoger/user', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('maddoger/user', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data-confirm' => Yii::t('maddoger/user', 'Are you sure to delete this item?'), 'data-method' => 'post']); ?> </p> <?php $all = AuthItem::find()->where(['type' => \yii\rbac\Item::TYPE_ROLE])->select(['name', 'description'])->orderBy('name')->asArray()->all(); $items = []; foreach ($all as $ar) { $items[$ar['name']] = $ar['name'] . ' - ' . $ar['description']; } //echo $form->field($model, 'rolesNames')->listBox($items, ['class'=>'form-control select2', 'multiple'=> true, 'prompt' => Yii::t('maddoger/user', 'No roles')]); $roles = '<ul class="list-unstyled">'; foreach ($model->getRolesNames() as $name) { $roles .= '<li>' . Html::encode($items[$name]) . '</li>'; } $roles .= '</ul>'; $genders = User::getGenderItems(); echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', 'email:email', 'email_confirmed:boolean', 'last_name', 'first_name', 'patronymic', 'nick_name', 'short_name', 'full_name', 'date_of_birth:date', ['label' => Yii::t('maddoger/user', 'Gender'), 'format' => 'text', 'value' => $genders[$model->gender]], 'facebook_uid', 'facebook_name', 'facebook_data:ntext', 'twitter_uid', 'twitter_name', 'twitter_data:ntext', 'gplus_uid', 'gplus_name', 'gplus_data:ntext', 'vk_uid', 'vk_name', 'vk_data:ntext', ['label' => Yii::t('maddoger/user', 'Roles'), 'format' => 'html', 'value' => $roles], 'last_visit_time:datetime', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'avatar', 'format' => 'image', 'value' => $model->getAvatarSrc()]]]); ?> </div>
</div> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 64]); ?> <?php echo $form->field($model, 'type')->dropDownList(AuthItem::getTypeValues(), ['prompt' => Yii::t('maddoger/user', 'Choose item type')]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 2]); ?> <?php $all = AuthItem::find()->select(['name', 'type', 'description'])->orderBy('type, name')->asArray()->all(); $items = [1 => [], 2 => []]; foreach ($all as $ar) { if ($ar['name'] != $model->name) { $items[$ar['type']][$ar['name']] = $ar['description']; } } $items = [Yii::t('maddoger/user', 'Roles') => $items[1], Yii::t('maddoger/user', 'Permissions') => $items[2]]; echo $form->field($model, 'children')->listBox($items, ['class' => 'form-control select2', 'multiple' => true, 'size' => 20, 'prompt' => Yii::t('maddoger/user', 'No children')]); ?> <?php echo $form->field($model, 'rule_name')->textInput(['rows' => 2]); ?> <?php