Skip to content
Merged
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
340 changes: 177 additions & 163 deletions backend/modules/frontend/views/player/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,183 +5,197 @@
/* @var $this yii\web\View */
/* @var $searchModel app\modules\frontend\models\PlayerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title=ucfirst(Yii::$app->controller->module->id).' / '.ucfirst(Yii::$app->controller->id);
$this->params['breadcrumbs'][]=['label' => 'Players', 'url' => ['index']];

$this->title = ucfirst(Yii::$app->controller->module->id) . ' / ' . ucfirst(Yii::$app->controller->id);
$this->params['breadcrumbs'][] = ['label' => 'Players', 'url' => ['index']];
yii\bootstrap5\Modal::begin([
'title' => '<h2><i class="bi bi-info-circle-fill"></i> '.Html::encode($this->title).' Help</h2>',
'toggleButton' => ['label' => '<i class="bi bi-info-circle-fill"></i> Help','class'=>'btn btn-info'],
'title' => '<h2><i class="bi bi-info-circle-fill"></i> ' . Html::encode($this->title) . ' Help</h2>',
'toggleButton' => ['label' => '<i class="bi bi-info-circle-fill"></i> Help', 'class' => 'btn btn-info'],
]);
echo yii\helpers\Markdown::process($this->render('help/'.$this->context->action->id), 'gfm');
echo yii\helpers\Markdown::process($this->render('help/' . $this->context->action->id), 'gfm');
yii\bootstrap5\Modal::end();
?>
<div class="player-index">

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

<p>
<?= Html::a('Create Player', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Import Players', ['import'], ['class' => 'btn btn-info']) ?>
<?= Html::a(Yii::t('app', 'Fail Validate'), ['fail-validation'], [
'class' => 'btn',
'style'=>'background: #4d246f; color: white;',
'data' => [
'confirm' => Yii::t('app', 'This operation validates all the user details are you sure?'),
],
]) ?>
<?= 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', ]]) ?>
<?= 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', ]]) ?>
</p>
<p>
<?= Html::a('Create Player', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Import Players', ['import'], ['class' => 'btn btn-info']) ?>
<?= Html::a(Yii::t('app', 'Fail Validate'), ['fail-validation'], [
'class' => 'btn',
'style' => 'background: #4d246f; color: white;',
'data' => [
'confirm' => Yii::t('app', 'This operation validates all the user details are you sure?'),
],
]) ?>
<?= 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',]]) ?>
<?= 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',]]) ?>
</p>

<details>
<details>
<summary>Extended Search</summary>
<?php echo $this->render('_search', ['model' => $searchModel]);?>
</details>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
</details>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions' => function ($model, $key, $index, $grid) {
// $model is the current data model being rendered
// check your condition in the if like `if($model->hasMedicalRecord())` which could be a method of model class which checks for medical records.
$model->scenario='validator';
if(!$model->validate()) {
return ['class' => 'text-danger','style'=>'font-weight: 800;'];
}
return [];
},
'columns' => [
[
'attribute'=>'id',
'headerOptions' => ['style' => 'width:4em'],
],
[
'attribute'=>'avatar',
'format'=>['image',['width' => '40px','class'=>'img-thumbnail']],
'value'=>function($data) { return '//'.Yii::$app->sys->offense_domain.'/images/avatars/' . $data->profile->avatar;}
],
['class' => 'app\components\columns\ProfileColumn','idkey'=>'profile.id','attribute'=>'username','field'=>'username'],
'email:email',
[
'attribute'=>'vpn_local_address',
'label'=> 'VPN IP',
'value'=>function($model) { return $model->last && $model->last->vpn_local_address ? long2ip($model->last->vpn_local_address) : null;}
],
'online:boolean',
'active:boolean',
[
'attribute'=>'academic',
'value'=>'academicShort',
'filter'=>[0=>Yii::$app->sys->academic_0short,1=>Yii::$app->sys->academic_1short, 2=>Yii::$app->sys->academic_2short],
],
[
'attribute' => 'status',
'format'=>'playerStatus',
'filter'=>array(10=>'Enabled',9=>'Innactive', 8=>"Change",0=>"Deleted",),
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'rowOptions' => function ($model, $key, $index, $grid) {
// $model is the current data model being rendered
// check your condition in the if like `if($model->hasMedicalRecord())` which could be a method of model class which checks for medical records.
$model->scenario = 'validator';
if (!$model->validate()) {
return ['class' => 'text-danger', 'style' => 'font-weight: 800;'];
}
return [];
},
'columns' => [
[
'attribute' => 'id',
'headerOptions' => ['style' => 'width:4em'],
],
[
'attribute' => 'avatar',
'format' => ['image', ['width' => '40px', 'class' => 'img-thumbnail']],
'value' => function ($data) {
return '//' . Yii::$app->sys->offense_domain . '/images/avatars/' . $data->profile->avatar;
}
],
['class' => 'app\components\columns\ProfileColumn', 'idkey' => 'profile.id', 'attribute' => 'username', 'field' => 'username'],
'email:email',
[
'attribute' => 'vpn_local_address',
'label' => 'VPN IP',
'value' => function ($model) {
return $model->last && $model->last->vpn_local_address ? long2ip($model->last->vpn_local_address) : null;
}
],
'online:boolean',
'active:boolean',
[
'attribute' => 'academic',
'value' => 'academicShort',
'filter' => [0 => Yii::$app->sys->academic_0short, 1 => Yii::$app->sys->academic_1short, 2 => Yii::$app->sys->academic_2short],
],
[
'attribute' => 'status',
'format' => 'playerStatus',
'filter' => array(10 => 'Enabled', 9 => 'Innactive', 8 => "Change", 0 => "Deleted",),

],
[
'attribute' => 'type',
'filter' => ["offense"=>"offense","defense"=>"defense"]
],

'created',
//'ts',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{player-view-full} {view} {generate-ssl} ' . '{update} {delete} {ban} {mail}',
'header' => Html::a(
'<i class="bi bi-person-fill-exclamation"></i>',
['ban-filtered'],
[
'title' => 'Mass Delete and ban users',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => [
'method' => 'post',
'params' => $searchModel->attributes,
'confirm' => 'Are you sure you want to delete and ban the currently filtered users?',
],
]
) . ' ' . Html::a(
'<i class="bi bi-person-dash-fill"></i>',
['delete-filtered'],
[
'title' => 'Mass Delete users',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => [
'method' => 'post',
'params' => $searchModel->attributes,
'confirm' => 'Are you sure you want to delete the currently filtered users?',
],
'created',
//'ts',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{player-view-full} {view} {generate-ssl} '.'{update} {delete} {ban} {mail}',
'header' => Html::a(
'<i class="bi bi-person-fill-exclamation"></i>',
['ban-filtered'],
[
'title' => 'Mass Delete and ban users',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>[
'method'=>'post',
'params'=> $searchModel->attributes,
'confirm'=>'Are you sure you want to delete and ban the currently filtered users?',
],
]
).' '.Html::a(
'<i class="bi bi-person-dash-fill"></i>',
['delete-filtered'],
[
'title' => 'Mass Delete users',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>[
'method'=>'post',
'params'=> $searchModel->attributes,
'confirm'=>'Are you sure you want to delete the currently filtered users?',
],
]
),
'buttons' => [
'delete' => function($url, $model) {
return Html::a('<i class="bi bi-trash3-fill"></i>', ['delete', 'id' => $model->id], [
'class' => '',
'data' => [
'confirm' => 'Are you absolutely sure you want to delete ['.Html::encode($model->username).'] ?',
'method' => 'post',
],
]);
},
'generate-ssl' => function($url) {
return Html::a('<i class="bi bi-shield-lock-fill"></i>', $url,
[
'title' => 'Generate SSL Certificates',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>['confirm'=>"Are you sure you want to regenerate the SSL for this user?"]
]
);
},
'toggle-academic' => function($url) {
return Html::a('<i class="bi bi-building"></i>', $url,
[
'title' => 'Toggle user academic flag',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>['confirm'=>'Are you sure you want to toggle the academic flag for this user?']
]
),
'buttons' => [
'delete' => function ($url, $model) {
return Html::a('<i class="bi bi-trash3-fill"></i>', ['delete', 'id' => $model->id], [
'class' => '',
'data' => [
'confirm' => 'Are you absolutely sure you want to delete [' . Html::encode($model->username) . '] ?',
'method' => 'post',
],
]);
},
'generate-ssl' => function ($url) {
return Html::a(
'<i class="bi bi-shield-lock-fill"></i>',
$url,
[
'title' => 'Generate SSL Certificates',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => ['confirm' => "Are you sure you want to regenerate the SSL for this user?"]
]
);
},
'toggle-academic' => function ($url) {
return Html::a(
'<i class="bi bi-building"></i>',
$url,
[
'title' => 'Toggle user academic flag',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => ['confirm' => 'Are you sure you want to toggle the academic flag for this user?']

]
);
},
'ban' => function($url) {
return Html::a(
'<i class="bi bi-hammer"></i>',
$url,
[
'title' => 'Delete and ban this user',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>['confirm'=>'Are you sure you want to delete and ban this user?']
]
);
},
'mail' => function($url) {
return Html::a(
'<i class="bi bi-envelope-at-fill"></i>',
$url,
[
'title' => 'Mail this user activation',
'data-pjax' => '0',
'data-method' => 'POST',
'data'=>['confirm'=>'Are you sure you want to mail this user his activation URL?']
]
);
},
'player-view-full' => function($url, $model) {
$url = \yii\helpers\Url::to(['/frontend/profile/view-full', 'id' => $model->profile->id]);
return Html::a(
'<i class="bi bi-person-lines-fill"></i>',
$url,
[
'title' => 'View full profile',
'data-pjax' => '0',
]
);
},
]
);
},
'ban' => function ($url) {
return Html::a(
'<i class="bi bi-hammer"></i>',
$url,
[
'title' => 'Delete and ban this user',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => ['confirm' => 'Are you sure you want to delete and ban this user?']
]
);
},
'mail' => function ($url) {
return Html::a(
'<i class="bi bi-envelope-at-fill"></i>',
$url,
[
'title' => 'Mail this user activation',
'data-pjax' => '0',
'data-method' => 'POST',
'data' => ['confirm' => 'Are you sure you want to mail this user his activation URL?']
]
);
},
'player-view-full' => function ($url, $model) {
$url = \yii\helpers\Url::to(['/frontend/profile/view-full', 'id' => $model->profile->id]);
return Html::a(
'<i class="bi bi-person-lines-fill"></i>',
$url,
[
'title' => 'View full profile',
'data-pjax' => '0',
]
);
},

],
],
],
]);?>
],
],
]); ?>


</div>
</div>
9 changes: 4 additions & 5 deletions docs/Sysconfig-Keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* `force_findings_to_claim`: Enable the enforcement of players needing to have discovered the findings before claiming flags
* `maintenance`: Enable site-wide maintenance mode
* `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.

Not activated by default on current code-base but are going to
* _`require_activation`_ Whether it is required for users to activate their accounts
* _`disable_registration`_ Whether online registrations are allowed
* `require_activation` Whether it is required for users to activate their accounts
* `disable_registration` Whether online registrations are allowed

## String and numeric key/val pairs
* `event_name` A name for your event
Expand Down Expand Up @@ -81,9 +79,10 @@ Not activated by default on current code-base but are going to
## Player Specific
* `academic_N` Name for academic value `N`
* `academic_Nshort` Short name for academic value `N`
* `acdemic_grouping` Enable/Disable support for academic grouping
* `academic_grouping` (1)Enable/(2)Disable support for academic grouping of activity stream
example:
```
backend/yii sysconfig/set academic_grouping 1
backend/yii sysconfig/set academic_0 "SuperSite.com"
backend/yii sysconfig/set academic_1 "AnotherSite.com"
backend/yii sysconfig/set academic_0short "supersite"
Expand Down
2 changes: 1 addition & 1 deletion frontend/themes/material/profile/_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
]);?>
<?php endif;?>
</p>
<?php if($subscription->exists):?>
<?php if($subscription->exists && \Yii::$app->sys->all_players_vip!==false):?>
<?php if($subscription->isActive):?>
<h5 class="rounded text-success font-weight-bold"><?= $subscription->product ? $subscription->product->name: "subscription"?> expires in <?=$subscription->expires?></h5>
<?=Html::a('Manage Billing',['/subscription/default/index'],['class'=>'btn btn-block btn-info font-weight-bold']);?>
Expand Down