S2OJ/web/app/controllers/problem_managers_manage.php

190 lines
5.3 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
requireLib('bootstrap5');
requirePHPLib('form');
Auth::check() || redirectToLogin();
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403();
$managers_form = newAddDelCmdForm(
'managers',
'validateUserAndStoreByUsername',
function ($type, $username, &$vdata) {
$user = $vdata['user'][$username];
if ($type == '+') {
DB::insert([
"insert into problems_permissions",
"(problem_id, username)",
"values", DB::tuple([UOJProblem::info('id'), $user['username']])
]);
} else if ($type == '-') {
DB::delete([
"delete from problems_permissions",
"where", [
"problem_id" => UOJProblem::info('id'),
"username" => $user['username']
]
]);
}
2022-03-17 04:00:03 +00:00
}
2022-11-06 02:26:21 +00:00
);
$managers_form->runAtServer();
2022-11-11 23:10:34 +00:00
if (isSuperUser(Auth::user())) {
$update_uploader_form = new UOJForm('update_uploader');
$update_uploader_form->appendHTML(
HTML::tag(
'div',
['class' => 'col-auto'],
HTML::tag('label', ['class' => 'col-form-label'], '上传者')
)
);
2022-11-06 02:26:21 +00:00
$update_uploader_form->addInput(
'new_uploader_username',
[
'div_class' => 'col-auto',
'default_value' => UOJProblem::info('uploader') ?: 'root',
'validator_php' => function ($username, &$vdata) {
if (!UOJUser::query($username)) {
return '用户不存在';
}
2022-04-03 10:18:17 +00:00
$vdata['username'] = $username;
return '';
},
]
2016-07-18 16:39:37 +00:00
);
$update_uploader_form->config['form']['class'] = 'mt-2 row g-3 align-items-center';
$update_uploader_form->config['submit_container']['class'] = 'col-auto';
$update_uploader_form->config['submit_button']['class'] = 'btn btn-warning';
$update_uploader_form->config['submit_button']['text'] = '修改上传者';
$update_uploader_form->config['confirm']['smart'] = true;
2022-11-06 02:26:21 +00:00
$update_uploader_form->handle = function (&$vdata) {
DB::update([
"update problems",
"set", ["uploader" => $vdata['username']],
"where", ["id" => UOJProblem::info('id')]
]);
};
$update_uploader_form->runAtServer();
}
?>
<?php echoUOJPageHeader('管理者 - ' . HTML::stripTags(UOJProblem::info('title'))) ?>
<div class="row">
2022-11-06 02:26:21 +00:00
<!-- left col -->
<div class="col-lg-9">
<h1>
<?= UOJProblem::cur()->getTitle() ?> 管理
</h1>
<ul class="nav nav-pills my-3" role="tablist">
<li class="nav-item">
<a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/statement" role="tab">
题面
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/problem/<?= UOJProblem::info('id') ?>/manage/managers" role="tab">
管理者
</a>
</li>
<?php if (UOJProblem::info('type') === 'local') : ?>
<li class="nav-item">
<a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/data" role="tab">
数据
</a>
</li>
<?php endif ?>
2022-11-06 02:26:21 +00:00
</ul>
<div class="card card-default">
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>用户名</th>
</tr>
</thead>
<tbody>
<?php
$row_id = 0;
$res = DB::selectAll([
"select username from problems_permissions",
"where", ["problem_id" => UOJProblem::info('id')]
]);
foreach ($res as $row) {
$row_id++;
echo '<tr>', '<td>', $row_id, '</td>', '<td>', UOJUser::getLink($row['username']), '</td>', '</tr>';
2022-11-06 02:26:21 +00:00
}
?>
</tbody>
</table>
<p class="text-center">命令格式:命令一行一个,+mike表示把mike加入管理者-mike表示把mike从管理者中移除</p>
<?php $managers_form->printHTML(); ?>
<?php if (isset($update_uploader_form)) : ?>
<hr>
<?php $update_uploader_form->printHTML(); ?>
<?php endif ?>
</div>
</div>
<!-- end left col -->
2022-10-07 01:13:35 +00:00
</div>
2022-11-06 02:26:21 +00:00
<!-- right col -->
<aside class="col-lg-3 mt-3 mt-lg-0">
<div class="card card-default mb-2">
<ul class="nav nav-pills nav-fill flex-column" role="tablist">
<li class="nav-item text-start">
<a href="/problem/<?= UOJProblem::info('id') ?>" class="nav-link" role="tab">
<i class="bi bi-journal-text"></i>
<?= UOJLocale::get('problems::statement') ?>
</a>
</li>
<li class="nav-item text-start">
<a href="/problem/<?= UOJProblem::info('id') ?>#submit" class="nav-link" role="tab">
<i class="bi bi-upload"></i>
<?= UOJLocale::get('problems::submit') ?>
</a>
</li>
2022-11-06 02:26:21 +00:00
<li class="nav-item text-start">
<a href="/problem/<?= UOJProblem::info('id') ?>/solutions" class="nav-link" role="tab">
<i class="bi bi-journal-bookmark"></i>
<?= UOJLocale::get('problems::solutions') ?>
</a>
</li>
2022-11-23 08:31:37 +00:00
<li class="nav-item text-start">
<a class="nav-link" href="/submissions?problem_id=<?= UOJProblem::info('id') ?>">
<i class="bi bi-list-ul"></i>
<?= UOJLocale::get('submissions') ?>
</a>
</li>
2022-11-06 02:26:21 +00:00
<li class="nav-item text-start">
<a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/statistics">
<i class="bi bi-graph-up"></i>
<?= UOJLocale::get('problems::statistics') ?>
</a>
</li>
<li class="nav-item text-start">
<a class="nav-link active" href="#" role="tab">
<i class="bi bi-sliders"></i>
<?= UOJLocale::get('problems::manage') ?>
</a>
</li>
</ul>
</div>
</aside>
<!-- end right col -->
</div>
2022-09-25 13:03:56 +00:00
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>