diff --git a/messages/zh-CN/app.php b/messages/zh-CN/app.php index b34854686..7798b2727 100644 --- a/messages/zh-CN/app.php +++ b/messages/zh-CN/app.php @@ -77,6 +77,7 @@ 'Release news' => '发布新闻', 'Male' => '男', 'Nickname' => '昵称', + 'New Nickname' => '新昵称', 'Prefix' => '前缀', 'Number' => '数量', 'Names' => '名称', @@ -89,6 +90,7 @@ 'Verify Password' => '确认密码', 'Female' => '女', 'Major' => '专业', + 'class' => '班级', 'Contest' => '比赛', 'Title' => '标题', 'Type' => '类型', diff --git a/migrations/m180401_030422_import_initial_table.php b/migrations/m180401_030422_import_initial_table.php index a762740ae..3a764fc68 100644 --- a/migrations/m180401_030422_import_initial_table.php +++ b/migrations/m180401_030422_import_initial_table.php @@ -67,7 +67,8 @@ public function up() 'description' => $this->string(), 'school' => $this->string(), 'student_number' => $this->string(64), - 'major' => $this->string(64) + 'major' => $this->string(64), + 'class' => $this->string(64) ], $this->tableOptions); $this->execute('ALTER TABLE {{%user_profile}} ADD PRIMARY KEY(`user_id`);'); diff --git a/migrations/m190309_123832_setting.php b/migrations/m190309_123832_setting.php index e31b86439..d3deae436 100644 --- a/migrations/m190309_123832_setting.php +++ b/migrations/m190309_123832_setting.php @@ -18,6 +18,8 @@ public function safeUp() $this->insert('{{%setting}}', ['key' => 'scoreboardFrozenTime', 'value' => '7200']); $this->insert('{{%setting}}', ['key' => 'isShareCode', 'value' => '1']); $this->insert('{{%setting}}', ['key' => 'oiMode', 'value' => '0']); + $this->insert('{{%setting}}', ['key' => 'SigninMode', 'value' => '1']); + $this->insert('{{%setting}}', ['key' => 'GroupMode', 'value' => '1']); } /** @@ -30,6 +32,7 @@ public function safeDown() $this->delete('{{%setting}}', ['key' => 'scoreboardFrozenTime']); $this->delete('{{%setting}}', ['key' => 'isShareCode']); $this->delete('{{%setting}}', ['key' => 'oiMode']); + $this->delete('{{%setting}}', ['key' => 'SigninMode']); $this->dropColumn('{{%setting}}', 'id'); } diff --git a/models/User.php b/models/User.php index c17c4c954..b59acd6e5 100644 --- a/models/User.php +++ b/models/User.php @@ -50,6 +50,7 @@ class User extends ActiveRecord implements IdentityInterface public $newPassword; public $verifyPassword; + public $newNickname; /** * 是否已经验证邮箱 */ @@ -97,7 +98,9 @@ public function rules() [['oldPassword'], 'validateOldPassword'], [['verifyPassword'], 'compare', 'compareAttribute' => 'newPassword'], [['oldPassword', 'verifyPassword', 'newPassword'], 'required'], - ['newPassword', 'string', 'min' => 6, 'max' => 16] + ['newPassword', 'string', 'min' => 6, 'max' => 16], + + [['newNickname'], 'string', 'max' => 16] ]; } @@ -120,6 +123,7 @@ public function attributeLabels() 'id' => Yii::t('app', 'ID'), 'username' => Yii::t('app', 'Username'), 'nickname' => Yii::t('app', 'Nickname'), + 'newNickname' => Yii::t('app', 'New Nickname'), 'password' => Yii::t('app', 'Password'), 'oldPassword' => Yii::t('app', 'Old Password'), 'newPassword' => Yii::t('app', 'New Password'), diff --git a/models/UserProfile.php b/models/UserProfile.php index 034f63830..56c2e194e 100644 --- a/models/UserProfile.php +++ b/models/UserProfile.php @@ -40,6 +40,7 @@ public function rules() [['address', 'description', 'major'], 'string'], [['signature', 'school'], 'string', 'max' => 128], [['major'], 'string', 'max' => 64], + [['class'], 'string', 'max' => 64], [['user_id'], 'unique'], ]; } @@ -59,7 +60,8 @@ public function attributeLabels() 'description' => Yii::t('app', 'Description'), 'school' => Yii::t('app', 'School'), 'student_number' => Yii::t('app', 'Student Number'), - 'major' => Yii::t('app', 'Major') + 'major' => Yii::t('app', 'Major'), + 'class' => Yii::t('app', 'class') ]; } } diff --git a/modules/admin/controllers/UserController.php b/modules/admin/controllers/UserController.php index a5a6909f6..50f77639f 100644 --- a/modules/admin/controllers/UserController.php +++ b/modules/admin/controllers/UserController.php @@ -122,6 +122,13 @@ public function actionUpdate($id) $model = $this->findModel($id); if (Yii::$app->request->isPost) { + $newNickname = Yii::$app->request->post('User')['newNickname']; + if (!empty($newNickname)) { + Yii::$app->db->createCommand()->update('{{%user}}', + ['username' => $newNickname, 'nickname' => $newNickname], + ['id' => $model->id] + )->execute(); + } $newPassword = Yii::$app->request->post('User')['newPassword']; $role = Yii::$app->request->post('User')['role']; if (!empty($newPassword)) { diff --git a/modules/admin/views/problem/index.php b/modules/admin/views/problem/index.php index db471dcef..b3a79f7ac 100644 --- a/modules/admin/views/problem/index.php +++ b/modules/admin/views/problem/index.php @@ -58,6 +58,13 @@ }, 'format' => 'raw' ], + [ + 'attribute' => 'tags', + 'value' => function ($model, $key, $index, $column) { + return Html::a(Html::encode($model->tags), ['problem/view', 'id' => $key]); + }, + 'format' => 'raw' + ], [ 'attribute' => 'status', 'value' => function ($model, $key, $index, $column) { diff --git a/modules/admin/views/setting/index.php b/modules/admin/views/setting/index.php index f52e8ae14..ad8bb2603 100644 --- a/modules/admin/views/setting/index.php +++ b/modules/admin/views/setting/index.php @@ -19,7 +19,20 @@ 'form-control']) ?> - +
+ + '启用', + 0 => '禁用' + ]) ?> +
+
+ + '启用', + 0 => '禁用' + ]) ?> +
+ field($model, 'newNickname')->textInput() ?> + field($model, 'newPassword')->textInput() ?> field($model, 'role')->radioList([ diff --git a/modules/admin/views/user/index.php b/modules/admin/views/user/index.php index f35aaf560..1869f4b4c 100644 --- a/modules/admin/views/user/index.php +++ b/modules/admin/views/user/index.php @@ -74,6 +74,13 @@ }, 'format' => 'raw' ], + [ + 'attribute' => Yii::t('app', 'class'), + 'value' => function ($model, $widget) { + return Html::encode($model->profile->class); + }, + 'format' => 'raw' + ], // 'status', // 'created_at', // 'updated_at', diff --git a/modules/admin/views/user/update.php b/modules/admin/views/user/update.php index 7fbcacf0d..9f1c03d85 100644 --- a/modules/admin/views/user/update.php +++ b/modules/admin/views/user/update.php @@ -9,14 +9,14 @@ 'username' => $model->username, 'nickname' => $model->nickname ]); -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Users'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'User'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); ?>

title) ?>

- + render('_form', [ 'model' => $model, ]) ?> diff --git a/modules/admin/views/user/view.php b/modules/admin/views/user/view.php index 0f59cc81f..e2e23ca6b 100644 --- a/modules/admin/views/user/view.php +++ b/modules/admin/views/user/view.php @@ -32,6 +32,13 @@ 'username', 'created_at', 'updated_at', + [ + 'attribute' => Yii::t('app', 'class'), + 'value' => function ($model, $widget) { + return Html::encode($model->profile->class); + }, + 'format' => 'raw' + ], ], ]) ?> diff --git a/views/layouts/main.php b/views/layouts/main.php index 5986b5f95..74de4e2fe 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -63,10 +63,6 @@ 'url' => ['/rating/problem'], 'active' => Yii::$app->controller->id == 'rating' ], - [ - 'label' => ' ' . Yii::t('app', 'Group'), - 'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group'] - ], ['label' => ' ' . Yii::t('app', 'Contests'), 'url' => ['/contest/index']], [ 'label' => ' '. Yii::t('app', 'Wiki'), @@ -74,8 +70,19 @@ 'active' => Yii::$app->controller->id == 'wiki' ], ]; + if (!(Yii::$app->user->isGuest) && Yii::$app->user->identity->isAdmin()) { + $menuItems[] = ['label' => ' ' . Yii::t('app', 'Group'), + 'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group']]; + } else { + if (Yii::$app->setting->get('GroupMode') == "1") { + $menuItems[] = ['label' => ' ' . Yii::t('app', 'Group'), + 'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group']]; + } + } if (Yii::$app->user->isGuest) { - $menuItems[] = ['label' => ' ' . Yii::t('app', 'Signup'), 'url' => ['/site/signup']]; + if (Yii::$app->setting->get('SigninMode') == "1"){ + $menuItems[] = ['label' => ' ' . Yii::t('app', 'Signup'), 'url' => ['/site/signup']]; + } $menuItems[] = ['label' => ' ' . Yii::t('app', 'Login'), 'url' => ['/site/login']]; } else { if (Yii::$app->user->identity->isAdmin()) { diff --git a/views/user/_profile.php b/views/user/_profile.php index d49f409a8..02bcd9a7a 100644 --- a/views/user/_profile.php +++ b/views/user/_profile.php @@ -11,15 +11,17 @@ -field($model, 'nickname')->textInput() ?> +field($model, 'nickname')->textInput(['readonly' => true]) ?> field($profile, 'qq_number')->textInput() ?> field($profile, 'student_number')->textInput() ?> -field($profile, 'gender')->radioList([Yii::t('app', 'Male'), Yii::t('app', 'Female')]) ?> - field($profile, 'major')->textInput() ?> + +field($profile, 'class')->textInput() ?> + +field($profile, 'gender')->radioList([Yii::t('app', 'Male'), Yii::t('app', 'Female')]) ?>
'btn btn-success']) ?> diff --git a/views/user/view.php b/views/user/view.php index 668813161..4499ff4b5 100644 --- a/views/user/view.php +++ b/views/user/view.php @@ -138,6 +138,13 @@ function showTooltip(x, y, contents) { }, 'format' => 'raw' ], + [ + 'attribute' => Yii::t('app', 'class'), + 'value' => function ($model, $widget) { + return Html::encode($model->profile->class); + }, + 'format' => 'raw' + ], [ 'attribute' => Yii::t('app', 'Student Number'), 'value' => function ($model, $widget) {