Example #1
0
 /**
  * Получение массива назначенных ролей пользователя
  * @return array
  */
 public function getRoles()
 {
     $assignments = AuthAssignment::findAll(['user_id' => $this->id]);
     $result = [];
     foreach ($assignments as $assign) {
         $result[] = $assign->item_name;
     }
     return $result;
 }
Example #2
0
 /**
  * Deletes an existing User model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if ($this->findModel($id)->delete()) {
         $assignmets = AuthAssignment::findAll(['user_id' => $id]);
         foreach ($assignmets as $assign) {
             $assign->delete();
         }
     }
     return $this->redirect(['index']);
 }
Example #3
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены что хотите удалить этого пользователя?', 'method' => 'post']]);
?>
        <?php 
echo Html::a('Изменить пароль', ['password-change', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
$status = User::getStatusName($model->status);
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', 'name', 'email:email', ['attribute' => 'status', 'format' => 'raw', 'value' => $model->status == 10 ? '<span class="label label-success">' . $status . '</span>' : '<span class="label label-danger">' . $status . '</span>'], ['attribute' => 'created_at', 'value' => date('d-M-Y H:i:s', $model->created_at)], ['attribute' => 'updated_at', 'value' => date('d-M-Y H:i:s', $model->updated_at)]]]);
echo Html::tag('p', 'Назначенные роли');
$auth = AuthAssignment::findAll(['user_id' => $model->id]);
$assignment = [];
foreach ($auth as $item) {
    $assignment[] = $item->item_name;
}
echo Html::listBox('roles', null, $assignment);
?>

</div>