diff --git a/controllers/AdminController.php b/controllers/AdminController.php index 851677b..f09d3ab 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -5,6 +5,7 @@ namespace app\controllers; use app\models\User; use app\models\UserSearch; use app\utils\AdminSword; +use app\utils\FileSizeHelper; use Throwable; use Yii; use yii\base\Exception; @@ -135,6 +136,27 @@ class AdminController extends Controller } else { 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 { return ['output' => '', 'message' => '']; } diff --git a/views/admin/user_view.php b/views/admin/user_view.php index 526a672..a5ae9ae 100644 --- a/views/admin/user_view.php +++ b/views/admin/user_view.php @@ -22,6 +22,7 @@ $alreadyDisabled = $model->status == 0; $IPLocation = new IPLocation(); YiiAsset::register($this); FontAwesomeAsset::register($this); +$this->registerCssFile('@web/css/admin-userv.css'); ?>