yii2-netdisk/views/admin/user_view.php

63 lines
1.7 KiB
PHP
Raw Normal View History

2024-03-22 14:48:35 +08:00
<?php
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
/** @var yii\web\View $this */
/** @var app\models\User $model */
$this->title = '用户ID: '.$model->id;
$this->params['breadcrumbs'][] = ['label' => '用户管理', 'url' => ['user']];
2024-03-22 14:48:35 +08:00
$this->params['breadcrumbs'][] = $this->title;
$alreadyDisabled = $model->status == 0;
$isCurrentUser = Yii::$app->user->id == $model->id;
$str = $alreadyDisabled ? '启用' : '禁用';
2024-03-22 14:48:35 +08:00
YiiAsset::register($this);
?>
<div class="user-view">
<h1>用户详情</h1>
2024-03-22 14:48:35 +08:00
<p>
<?= Html::a('修改信息', ['user-update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a($str.'用户', ['user-delete', 'id' => $model->id], [
2024-03-22 14:48:35 +08:00
'class' => 'btn btn-danger',
'data' => [
'confirm' => '你确定要'.$str.'这个用户吗?',
2024-03-22 14:48:35 +08:00
'method' => 'post',
],
'disabled' => $isCurrentUser,
'title'=> $isCurrentUser ? '不能'.$str.'自己的账户' : '点击'.$str.'用户',
2024-03-22 14:48:35 +08:00
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'username',
'name',
'password',
'auth_key',
'email:email',
'status',
'created_at',
'last_login',
'last_login_ip',
'bio:ntext',
'role',
'encryption_key',
'otp_secret',
'is_encryption_enabled',
'is_otp_enabled',
'storage_limit',
'recovery_codes',
'dark_mode',
'vault_secret',
'vault_salt',
],
]) ?>
</div>