Skip to content

Commit 0b213e7

Browse files
authored
Merge pull request #981 from proditis/master
frontend profile and backend player layout updates
2 parents 19ad1fc + 9f2ddfd commit 0b213e7

File tree

3 files changed

+182
-169
lines changed

3 files changed

+182
-169
lines changed

backend/modules/frontend/views/player/index.php

Lines changed: 177 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -5,183 +5,197 @@
55
/* @var $this yii\web\View */
66
/* @var $searchModel app\modules\frontend\models\PlayerSearch */
77
/* @var $dataProvider yii\data\ActiveDataProvider */
8-
$this->title=ucfirst(Yii::$app->controller->module->id).' / '.ucfirst(Yii::$app->controller->id);
9-
$this->params['breadcrumbs'][]=['label' => 'Players', 'url' => ['index']];
8+
9+
$this->title = ucfirst(Yii::$app->controller->module->id) . ' / ' . ucfirst(Yii::$app->controller->id);
10+
$this->params['breadcrumbs'][] = ['label' => 'Players', 'url' => ['index']];
1011
yii\bootstrap5\Modal::begin([
11-
'title' => '<h2><i class="bi bi-info-circle-fill"></i> '.Html::encode($this->title).' Help</h2>',
12-
'toggleButton' => ['label' => '<i class="bi bi-info-circle-fill"></i> Help','class'=>'btn btn-info'],
12+
'title' => '<h2><i class="bi bi-info-circle-fill"></i> ' . Html::encode($this->title) . ' Help</h2>',
13+
'toggleButton' => ['label' => '<i class="bi bi-info-circle-fill"></i> Help', 'class' => 'btn btn-info'],
1314
]);
14-
echo yii\helpers\Markdown::process($this->render('help/'.$this->context->action->id), 'gfm');
15+
echo yii\helpers\Markdown::process($this->render('help/' . $this->context->action->id), 'gfm');
1516
yii\bootstrap5\Modal::end();
1617
?>
1718
<div class="player-index">
1819

19-
<h1><?= Html::encode($this->title) ?></h1>
20+
<h1><?= Html::encode($this->title) ?></h1>
2021

21-
<p>
22-
<?= Html::a('Create Player', ['create'], ['class' => 'btn btn-success']) ?>
23-
<?= Html::a('Import Players', ['import'], ['class' => 'btn btn-info']) ?>
24-
<?= Html::a(Yii::t('app', 'Fail Validate'), ['fail-validation'], [
25-
'class' => 'btn',
26-
'style'=>'background: #4d246f; color: white;',
27-
'data' => [
28-
'confirm' => Yii::t('app', 'This operation validates all the user details are you sure?'),
29-
],
30-
]) ?>
31-
<?= Html::a('Reset All player data', ['reset-playdata'], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete all player data?', 'method' => 'post', ]]) ?>
32-
<?= Html::a('Reset All player progress', ['reset-player-progress'], ['class' => 'btn btn-warning', 'data' => ['confirm' => 'Are you sure you want to delete all player progress?', 'method' => 'post', ]]) ?>
33-
</p>
22+
<p>
23+
<?= Html::a('Create Player', ['create'], ['class' => 'btn btn-success']) ?>
24+
<?= Html::a('Import Players', ['import'], ['class' => 'btn btn-info']) ?>
25+
<?= Html::a(Yii::t('app', 'Fail Validate'), ['fail-validation'], [
26+
'class' => 'btn',
27+
'style' => 'background: #4d246f; color: white;',
28+
'data' => [
29+
'confirm' => Yii::t('app', 'This operation validates all the user details are you sure?'),
30+
],
31+
]) ?>
32+
<?= Html::a('Reset All player data', ['reset-playdata'], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete all player data?', 'method' => 'post',]]) ?>
33+
<?= Html::a('Reset All player progress', ['reset-player-progress'], ['class' => 'btn btn-warning', 'data' => ['confirm' => 'Are you sure you want to delete all player progress?', 'method' => 'post',]]) ?>
34+
</p>
3435

35-
<details>
36+
<details>
3637
<summary>Extended Search</summary>
37-
<?php echo $this->render('_search', ['model' => $searchModel]);?>
38-
</details>
38+
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
39+
</details>
3940

40-
<?= GridView::widget([
41-
'dataProvider' => $dataProvider,
42-
'filterModel' => $searchModel,
43-
'rowOptions' => function ($model, $key, $index, $grid) {
44-
// $model is the current data model being rendered
45-
// check your condition in the if like `if($model->hasMedicalRecord())` which could be a method of model class which checks for medical records.
46-
$model->scenario='validator';
47-
if(!$model->validate()) {
48-
return ['class' => 'text-danger','style'=>'font-weight: 800;'];
49-
}
50-
return [];
51-
},
52-
'columns' => [
53-
[
54-
'attribute'=>'id',
55-
'headerOptions' => ['style' => 'width:4em'],
56-
],
57-
[
58-
'attribute'=>'avatar',
59-
'format'=>['image',['width' => '40px','class'=>'img-thumbnail']],
60-
'value'=>function($data) { return '//'.Yii::$app->sys->offense_domain.'/images/avatars/' . $data->profile->avatar;}
61-
],
62-
['class' => 'app\components\columns\ProfileColumn','idkey'=>'profile.id','attribute'=>'username','field'=>'username'],
63-
'email:email',
64-
[
65-
'attribute'=>'vpn_local_address',
66-
'label'=> 'VPN IP',
67-
'value'=>function($model) { return $model->last && $model->last->vpn_local_address ? long2ip($model->last->vpn_local_address) : null;}
68-
],
69-
'online:boolean',
70-
'active:boolean',
71-
[
72-
'attribute'=>'academic',
73-
'value'=>'academicShort',
74-
'filter'=>[0=>Yii::$app->sys->academic_0short,1=>Yii::$app->sys->academic_1short, 2=>Yii::$app->sys->academic_2short],
75-
],
76-
[
77-
'attribute' => 'status',
78-
'format'=>'playerStatus',
79-
'filter'=>array(10=>'Enabled',9=>'Innactive', 8=>"Change",0=>"Deleted",),
41+
<?= GridView::widget([
42+
'dataProvider' => $dataProvider,
43+
'filterModel' => $searchModel,
44+
'rowOptions' => function ($model, $key, $index, $grid) {
45+
// $model is the current data model being rendered
46+
// check your condition in the if like `if($model->hasMedicalRecord())` which could be a method of model class which checks for medical records.
47+
$model->scenario = 'validator';
48+
if (!$model->validate()) {
49+
return ['class' => 'text-danger', 'style' => 'font-weight: 800;'];
50+
}
51+
return [];
52+
},
53+
'columns' => [
54+
[
55+
'attribute' => 'id',
56+
'headerOptions' => ['style' => 'width:4em'],
57+
],
58+
[
59+
'attribute' => 'avatar',
60+
'format' => ['image', ['width' => '40px', 'class' => 'img-thumbnail']],
61+
'value' => function ($data) {
62+
return '//' . Yii::$app->sys->offense_domain . '/images/avatars/' . $data->profile->avatar;
63+
}
64+
],
65+
['class' => 'app\components\columns\ProfileColumn', 'idkey' => 'profile.id', 'attribute' => 'username', 'field' => 'username'],
66+
'email:email',
67+
[
68+
'attribute' => 'vpn_local_address',
69+
'label' => 'VPN IP',
70+
'value' => function ($model) {
71+
return $model->last && $model->last->vpn_local_address ? long2ip($model->last->vpn_local_address) : null;
72+
}
73+
],
74+
'online:boolean',
75+
'active:boolean',
76+
[
77+
'attribute' => 'academic',
78+
'value' => 'academicShort',
79+
'filter' => [0 => Yii::$app->sys->academic_0short, 1 => Yii::$app->sys->academic_1short, 2 => Yii::$app->sys->academic_2short],
80+
],
81+
[
82+
'attribute' => 'status',
83+
'format' => 'playerStatus',
84+
'filter' => array(10 => 'Enabled', 9 => 'Innactive', 8 => "Change", 0 => "Deleted",),
8085

86+
],
87+
[
88+
'attribute' => 'type',
89+
'filter' => ["offense"=>"offense","defense"=>"defense"]
90+
],
91+
92+
'created',
93+
//'ts',
94+
[
95+
'class' => 'yii\grid\ActionColumn',
96+
'template' => '{player-view-full} {view} {generate-ssl} ' . '{update} {delete} {ban} {mail}',
97+
'header' => Html::a(
98+
'<i class="bi bi-person-fill-exclamation"></i>',
99+
['ban-filtered'],
100+
[
101+
'title' => 'Mass Delete and ban users',
102+
'data-pjax' => '0',
103+
'data-method' => 'POST',
104+
'data' => [
105+
'method' => 'post',
106+
'params' => $searchModel->attributes,
107+
'confirm' => 'Are you sure you want to delete and ban the currently filtered users?',
108+
],
109+
]
110+
) . ' ' . Html::a(
111+
'<i class="bi bi-person-dash-fill"></i>',
112+
['delete-filtered'],
113+
[
114+
'title' => 'Mass Delete users',
115+
'data-pjax' => '0',
116+
'data-method' => 'POST',
117+
'data' => [
118+
'method' => 'post',
119+
'params' => $searchModel->attributes,
120+
'confirm' => 'Are you sure you want to delete the currently filtered users?',
81121
],
82-
'created',
83-
//'ts',
84-
[
85-
'class' => 'yii\grid\ActionColumn',
86-
'template' => '{player-view-full} {view} {generate-ssl} '.'{update} {delete} {ban} {mail}',
87-
'header' => Html::a(
88-
'<i class="bi bi-person-fill-exclamation"></i>',
89-
['ban-filtered'],
90-
[
91-
'title' => 'Mass Delete and ban users',
92-
'data-pjax' => '0',
93-
'data-method' => 'POST',
94-
'data'=>[
95-
'method'=>'post',
96-
'params'=> $searchModel->attributes,
97-
'confirm'=>'Are you sure you want to delete and ban the currently filtered users?',
98-
],
99-
]
100-
).' '.Html::a(
101-
'<i class="bi bi-person-dash-fill"></i>',
102-
['delete-filtered'],
103-
[
104-
'title' => 'Mass Delete users',
105-
'data-pjax' => '0',
106-
'data-method' => 'POST',
107-
'data'=>[
108-
'method'=>'post',
109-
'params'=> $searchModel->attributes,
110-
'confirm'=>'Are you sure you want to delete the currently filtered users?',
111-
],
112-
]
113-
),
114-
'buttons' => [
115-
'delete' => function($url, $model) {
116-
return Html::a('<i class="bi bi-trash3-fill"></i>', ['delete', 'id' => $model->id], [
117-
'class' => '',
118-
'data' => [
119-
'confirm' => 'Are you absolutely sure you want to delete ['.Html::encode($model->username).'] ?',
120-
'method' => 'post',
121-
],
122-
]);
123-
},
124-
'generate-ssl' => function($url) {
125-
return Html::a('<i class="bi bi-shield-lock-fill"></i>', $url,
126-
[
127-
'title' => 'Generate SSL Certificates',
128-
'data-pjax' => '0',
129-
'data-method' => 'POST',
130-
'data'=>['confirm'=>"Are you sure you want to regenerate the SSL for this user?"]
131-
]
132-
);
133-
},
134-
'toggle-academic' => function($url) {
135-
return Html::a('<i class="bi bi-building"></i>', $url,
136-
[
137-
'title' => 'Toggle user academic flag',
138-
'data-pjax' => '0',
139-
'data-method' => 'POST',
140-
'data'=>['confirm'=>'Are you sure you want to toggle the academic flag for this user?']
122+
]
123+
),
124+
'buttons' => [
125+
'delete' => function ($url, $model) {
126+
return Html::a('<i class="bi bi-trash3-fill"></i>', ['delete', 'id' => $model->id], [
127+
'class' => '',
128+
'data' => [
129+
'confirm' => 'Are you absolutely sure you want to delete [' . Html::encode($model->username) . '] ?',
130+
'method' => 'post',
131+
],
132+
]);
133+
},
134+
'generate-ssl' => function ($url) {
135+
return Html::a(
136+
'<i class="bi bi-shield-lock-fill"></i>',
137+
$url,
138+
[
139+
'title' => 'Generate SSL Certificates',
140+
'data-pjax' => '0',
141+
'data-method' => 'POST',
142+
'data' => ['confirm' => "Are you sure you want to regenerate the SSL for this user?"]
143+
]
144+
);
145+
},
146+
'toggle-academic' => function ($url) {
147+
return Html::a(
148+
'<i class="bi bi-building"></i>',
149+
$url,
150+
[
151+
'title' => 'Toggle user academic flag',
152+
'data-pjax' => '0',
153+
'data-method' => 'POST',
154+
'data' => ['confirm' => 'Are you sure you want to toggle the academic flag for this user?']
141155

142-
]
143-
);
144-
},
145-
'ban' => function($url) {
146-
return Html::a(
147-
'<i class="bi bi-hammer"></i>',
148-
$url,
149-
[
150-
'title' => 'Delete and ban this user',
151-
'data-pjax' => '0',
152-
'data-method' => 'POST',
153-
'data'=>['confirm'=>'Are you sure you want to delete and ban this user?']
154-
]
155-
);
156-
},
157-
'mail' => function($url) {
158-
return Html::a(
159-
'<i class="bi bi-envelope-at-fill"></i>',
160-
$url,
161-
[
162-
'title' => 'Mail this user activation',
163-
'data-pjax' => '0',
164-
'data-method' => 'POST',
165-
'data'=>['confirm'=>'Are you sure you want to mail this user his activation URL?']
166-
]
167-
);
168-
},
169-
'player-view-full' => function($url, $model) {
170-
$url = \yii\helpers\Url::to(['/frontend/profile/view-full', 'id' => $model->profile->id]);
171-
return Html::a(
172-
'<i class="bi bi-person-lines-fill"></i>',
173-
$url,
174-
[
175-
'title' => 'View full profile',
176-
'data-pjax' => '0',
177-
]
178-
);
179-
},
156+
]
157+
);
158+
},
159+
'ban' => function ($url) {
160+
return Html::a(
161+
'<i class="bi bi-hammer"></i>',
162+
$url,
163+
[
164+
'title' => 'Delete and ban this user',
165+
'data-pjax' => '0',
166+
'data-method' => 'POST',
167+
'data' => ['confirm' => 'Are you sure you want to delete and ban this user?']
168+
]
169+
);
170+
},
171+
'mail' => function ($url) {
172+
return Html::a(
173+
'<i class="bi bi-envelope-at-fill"></i>',
174+
$url,
175+
[
176+
'title' => 'Mail this user activation',
177+
'data-pjax' => '0',
178+
'data-method' => 'POST',
179+
'data' => ['confirm' => 'Are you sure you want to mail this user his activation URL?']
180+
]
181+
);
182+
},
183+
'player-view-full' => function ($url, $model) {
184+
$url = \yii\helpers\Url::to(['/frontend/profile/view-full', 'id' => $model->profile->id]);
185+
return Html::a(
186+
'<i class="bi bi-person-lines-fill"></i>',
187+
$url,
188+
[
189+
'title' => 'View full profile',
190+
'data-pjax' => '0',
191+
]
192+
);
193+
},
180194

181-
],
182-
],
183195
],
184-
]);?>
196+
],
197+
],
198+
]); ?>
185199

186200

187-
</div>
201+
</div>

docs/Sysconfig-Keys.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
* `force_findings_to_claim`: Enable the enforcement of players needing to have discovered the findings before claiming flags
1919
* `maintenance`: Enable site-wide maintenance mode
2020
* `maintenance_notification`: Send maintenance notification to everyone connected to the frontend interface. The popup can be dismissed but it always comes back. No other notifications are delivered.
21-
22-
Not activated by default on current code-base but are going to
23-
* _`require_activation`_ Whether it is required for users to activate their accounts
24-
* _`disable_registration`_ Whether online registrations are allowed
21+
* `require_activation` Whether it is required for users to activate their accounts
22+
* `disable_registration` Whether online registrations are allowed
2523

2624
## String and numeric key/val pairs
2725
* `event_name` A name for your event
@@ -81,9 +79,10 @@ Not activated by default on current code-base but are going to
8179
## Player Specific
8280
* `academic_N` Name for academic value `N`
8381
* `academic_Nshort` Short name for academic value `N`
84-
* `acdemic_grouping` Enable/Disable support for academic grouping
82+
* `academic_grouping` (1)Enable/(2)Disable support for academic grouping of activity stream
8583
example:
8684
```
85+
backend/yii sysconfig/set academic_grouping 1
8786
backend/yii sysconfig/set academic_0 "SuperSite.com"
8887
backend/yii sysconfig/set academic_1 "AnotherSite.com"
8988
backend/yii sysconfig/set academic_0short "supersite"

frontend/themes/material/profile/_card.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
]);?>
5757
<?php endif;?>
5858
</p>
59-
<?php if($subscription->exists):?>
59+
<?php if($subscription->exists && \Yii::$app->sys->all_players_vip!==false):?>
6060
<?php if($subscription->isActive):?>
6161
<h5 class="rounded text-success font-weight-bold"><?= $subscription->product ? $subscription->product->name: "subscription"?> expires in <?=$subscription->expires?></h5>
6262
<?=Html::a('Manage Billing',['/subscription/default/index'],['class'=>'btn btn-block btn-info font-weight-bold']);?>

0 commit comments

Comments
 (0)