用户管理功能增强
*支持修改用户容量配额 输入值需要带单位,-1或∞为无限 最低值为1MB
This commit is contained in:
parent
9bedcd0d08
commit
83519f2946
@ -5,6 +5,7 @@ namespace app\controllers;
|
|||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\models\UserSearch;
|
use app\models\UserSearch;
|
||||||
use app\utils\AdminSword;
|
use app\utils\AdminSword;
|
||||||
|
use app\utils\FileSizeHelper;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
@ -135,6 +136,27 @@ class AdminController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
return ['output' => $oldValue, 'message' => 'Incorrect Value! Please reenter.'];
|
return ['output' => $oldValue, 'message' => 'Incorrect Value! Please reenter.'];
|
||||||
}
|
}
|
||||||
|
} elseif (isset($_POST['storage_limit'])) { //修改用户存储限制
|
||||||
|
$oldValue = $model->storage_limit;
|
||||||
|
$input_limit = $_POST['storage_limit'];
|
||||||
|
$limit = FileSizeHelper::getConvertedLimit($input_limit);
|
||||||
|
switch ($limit) {
|
||||||
|
case -1:
|
||||||
|
$model->storage_limit = -1;
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
return ['output' => $oldValue, 'message' => '值不能为空'];
|
||||||
|
case -3:
|
||||||
|
return ['output' => $oldValue, 'message' => '格式错误'];
|
||||||
|
default:
|
||||||
|
$model->storage_limit = $limit;
|
||||||
|
}
|
||||||
|
if ($model->save(true, ['storage_limit'])) {
|
||||||
|
return ['output' => FileSizeHelper::formatMegaBytes($model->storage_limit), 'message' => ''];
|
||||||
|
} else {
|
||||||
|
return ['output' => FileSizeHelper::formatMegaBytes($oldValue), 'message' => 'Incorrect Value! Please reenter.'];
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return ['output' => '', 'message' => ''];
|
return ['output' => '', 'message' => ''];
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ $alreadyDisabled = $model->status == 0;
|
|||||||
$IPLocation = new IPLocation();
|
$IPLocation = new IPLocation();
|
||||||
YiiAsset::register($this);
|
YiiAsset::register($this);
|
||||||
FontAwesomeAsset::register($this);
|
FontAwesomeAsset::register($this);
|
||||||
|
$this->registerCssFile('@web/css/admin-userv.css');
|
||||||
?>
|
?>
|
||||||
<div class="user-view">
|
<div class="user-view">
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ FontAwesomeAsset::register($this);
|
|||||||
['attribute' => 'name', 'label' => '昵称', 'format' => 'raw', 'value' => function ($model) {
|
['attribute' => 'name', 'label' => '昵称', 'format' => 'raw', 'value' => function ($model) {
|
||||||
return Editable::widget([
|
return Editable::widget([
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'asPopover' => false,
|
'asPopover' => true,
|
||||||
'value' => $model->name,
|
'value' => $model->name,
|
||||||
'header' => '昵称',
|
'header' => '昵称',
|
||||||
'size' => 'md',
|
'size' => 'md',
|
||||||
@ -141,11 +142,24 @@ FontAwesomeAsset::register($this);
|
|||||||
}
|
}
|
||||||
return FileSizeHelper::formatBytes(FileSizeHelper::getUserVaultDirSize($model->id));
|
return FileSizeHelper::formatBytes(FileSizeHelper::getUserVaultDirSize($model->id));
|
||||||
}],
|
}],
|
||||||
['attribute' => 'storage_limit', 'label' => '存储容量限制', 'value' => function ($model) {
|
// ['attribute' => 'storage_limit', 'label' => '存储容量限制', 'value' => function ($model) {
|
||||||
|
// if ($model->role == 'admin') {
|
||||||
|
// return '不可用';
|
||||||
|
// }
|
||||||
|
// return FileSizeHelper::formatMegaBytes($model->storage_limit);
|
||||||
|
// }],
|
||||||
|
['attribute' => 'storage_limit', 'label' => '存储容量限制', 'format' => 'raw', 'value' => function ($model) {
|
||||||
if ($model->role == 'admin') {
|
if ($model->role == 'admin') {
|
||||||
return '不可用';
|
return '不可用';
|
||||||
}
|
}
|
||||||
return FileSizeHelper::formatMegaBytes($model->storage_limit);
|
return Editable::widget([
|
||||||
|
'name' => 'storage_limit',
|
||||||
|
'asPopover' => true,
|
||||||
|
'value' => FileSizeHelper::formatMegaBytes($model->storage_limit),
|
||||||
|
'header' => '存储容量限制(最小1MB)',
|
||||||
|
'size' => 'md',
|
||||||
|
'options' => ['class' => 'form-control', 'placeholder' => '在这里输入容量限制(最小值为1MB)...'],
|
||||||
|
]);
|
||||||
}],
|
}],
|
||||||
['attribute' => 'storage_limit', 'format' => 'html', 'label' => '存储空间使用状态', 'value' => function ($model) {
|
['attribute' => 'storage_limit', 'format' => 'html', 'label' => '存储空间使用状态', 'value' => function ($model) {
|
||||||
if ($model->role == 'admin') {
|
if ($model->role == 'admin') {
|
||||||
|
Loading…
Reference in New Issue
Block a user