Example #1
0
 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;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getParents()
 {
     return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable(AuthItemChild::tableName(), ['child' => 'name']);
 }
Example #4
0
$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>
Example #5
0
		</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 
Example #6
0
 */
$this->title = Yii::t('maddoger/user', 'Roles');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="auth-item-index">
	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<div>
		<div class="pull-left"><?php 
echo Html::a(Yii::t('maddoger/user', 'Create new role'), ['create'], ['class' => 'btn btn-success']);
?>
</div>
		<div class="pull-right"><?php 
echo Html::a(Yii::t('maddoger/user', 'Update roles from modules'), ['update-from-modules'], ['class' => 'btn btn-primary']);
?>
</div>
		<div class="clearfix"></div>
	</div>
	<br />

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'class' => 'grid-view', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'description:ntext', 'name', ['value' => function ($model, $index, $widget) {
    $values = AuthItem::getTypeValues();
    return isset($values[$model->type]) ? $values[$model->type] : null;
}, 'filter' => AuthItem::getTypeValues(), 'attribute' => 'type'], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>