Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions messages/zh-CN/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
'Release news' => '发布新闻',
'Male' => '男',
'Nickname' => '昵称',
'New Nickname' => '新昵称',
'Prefix' => '前缀',
'Number' => '数量',
'Names' => '名称',
Expand All @@ -89,6 +90,7 @@
'Verify Password' => '确认密码',
'Female' => '女',
'Major' => '专业',
'class' => '班级',
'Contest' => '比赛',
'Title' => '标题',
'Type' => '类型',
Expand Down
3 changes: 2 additions & 1 deletion migrations/m180401_030422_import_initial_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`);');
Expand Down
3 changes: 3 additions & 0 deletions migrations/m190309_123832_setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand All @@ -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');
}

Expand Down
6 changes: 5 additions & 1 deletion models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class User extends ActiveRecord implements IdentityInterface
public $newPassword;
public $verifyPassword;

public $newNickname;
/**
* 是否已经验证邮箱
*/
Expand Down Expand Up @@ -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]
];
}

Expand All @@ -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'),
Expand Down
4 changes: 3 additions & 1 deletion models/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
}
Expand All @@ -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')
];
}
}
7 changes: 7 additions & 0 deletions modules/admin/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
7 changes: 7 additions & 0 deletions modules/admin/views/problem/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 14 additions & 1 deletion modules/admin/views/setting/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@
<?= Html::label(Yii::t('app', 'OJ名称'), 'ojName') ?>
<?= Html::textInput('ojName', $settings['ojName'], ['class' => 'form-control']) ?>
</div>

<div class="form-group">
<?= Html::label('注册功能', 'SigninMode') ?>
<?= Html::radioList('SigninMode', $settings['SigninMode'], [
1 => '启用',
0 => '禁用'
]) ?>
</div>
<div class="form-group">
<?= Html::label('小组功能', 'GroupMode') ?>
<?= Html::radioList('GroupMode', $settings['GroupMode'], [
1 => '启用',
0 => '禁用'
]) ?>
</div>
<div class="form-group">
<?= Html::label(Yii::t('app', 'OI 模式'), 'oiMode') ?>
<?= Html::radioList('oiMode', $settings['oiMode'], [
Expand Down
2 changes: 2 additions & 0 deletions modules/admin/views/user/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'newNickname')->textInput() ?>

<?= $form->field($model, 'newPassword')->textInput() ?>

<?= $form->field($model, 'role')->radioList([
Expand Down
7 changes: 7 additions & 0 deletions modules/admin/views/user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions modules/admin/views/user/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
?>
<div class="user-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>
Expand Down
7 changes: 7 additions & 0 deletions modules/admin/views/user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
],
]) ?>

Expand Down
17 changes: 12 additions & 5 deletions views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,26 @@
'url' => ['/rating/problem'],
'active' => Yii::$app->controller->id == 'rating'
],
[
'label' => '<span class="glyphicon glyphicon-user"></span> ' . Yii::t('app', 'Group'),
'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group']
],
['label' => '<span class="glyphicon glyphicon-knight"></span> ' . Yii::t('app', 'Contests'), 'url' => ['/contest/index']],
[
'label' => '<span class="glyphicon glyphicon-info-sign"></span> '. Yii::t('app', 'Wiki'),
'url' => ['/wiki/index'],
'active' => Yii::$app->controller->id == 'wiki'
],
];
if (!(Yii::$app->user->isGuest) && Yii::$app->user->identity->isAdmin()) {
$menuItems[] = ['label' => '<span class="glyphicon glyphicon-user"></span> ' . Yii::t('app', 'Group'),
'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group']];
} else {
if (Yii::$app->setting->get('GroupMode') == "1") {
$menuItems[] = ['label' => '<span class="glyphicon glyphicon-user"></span> ' . Yii::t('app', 'Group'),
'url' => Yii::$app->user->isGuest ? ['/group/index'] : ['/group/my-group']];
}
}
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => '<span class="glyphicon glyphicon-new-window"></span> ' . Yii::t('app', 'Signup'), 'url' => ['/site/signup']];
if (Yii::$app->setting->get('SigninMode') == "1"){
$menuItems[] = ['label' => '<span class="glyphicon glyphicon-new-window"></span> ' . Yii::t('app', 'Signup'), 'url' => ['/site/signup']];
}
$menuItems[] = ['label' => '<span class="glyphicon glyphicon-log-in"></span> ' . Yii::t('app', 'Login'), 'url' => ['/site/login']];
} else {
if (Yii::$app->user->identity->isAdmin()) {
Expand Down
8 changes: 5 additions & 3 deletions views/user/_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'nickname')->textInput() ?>
<?= $form->field($model, 'nickname')->textInput(['readonly' => true]) ?>

<?= $form->field($profile, 'qq_number')->textInput() ?>

<?= $form->field($profile, 'student_number')->textInput() ?>

<?= $form->field($profile, 'gender')->radioList([Yii::t('app', 'Male'), Yii::t('app', 'Female')]) ?>

<?= $form->field($profile, 'major')->textInput() ?>

<?= $form->field($profile, 'class')->textInput() ?>

<?= $form->field($profile, 'gender')->radioList([Yii::t('app', 'Male'), Yii::t('app', 'Female')]) ?>

<div class="form-group">
<?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
Expand Down
7 changes: 7 additions & 0 deletions views/user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down