mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 14:48:41 +00:00
refactor(problem/manage): permissions manage
This commit is contained in:
parent
8bc961fb3c
commit
066f12e899
@ -11,6 +11,22 @@ requirePHPLib('data');
|
||||
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
|
||||
UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403();
|
||||
UOJProblem::info('type') === 'local' || UOJResponse::page404();
|
||||
|
||||
$tabs_info = [
|
||||
'statement' => [
|
||||
'name' => '题面',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/statement'),
|
||||
],
|
||||
'permissions' => [
|
||||
'name' => '权限',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/permissions'),
|
||||
],
|
||||
'data' => [
|
||||
'name' => '数据',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/data'),
|
||||
],
|
||||
];
|
||||
|
||||
$problem = UOJProblem::info();
|
||||
$problem_extra_config = UOJProblem::cur()->getExtraConfig();
|
||||
|
||||
@ -535,23 +551,9 @@ if ($problem['hackable']) {
|
||||
<?= UOJProblem::cur()->getTitle(['with' => 'id']) ?> 管理
|
||||
</h1>
|
||||
|
||||
<ul class="nav nav-pills my-3" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?= UOJProblem::cur()->getUri('/manage/statement') ?>" role="tab">
|
||||
题面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?= UOJProblem::cur()->getUri('/manage/managers') ?>" role="tab">
|
||||
管理者
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="<?= UOJProblem::cur()->getUri('/manage/data') ?>" role="tab">
|
||||
数据
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="my-3">
|
||||
<?= HTML::tablist($tabs_info, 'data', 'nav-pills') ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header" id="div-file_list">
|
||||
|
@ -1,189 +0,0 @@
|
||||
<?php
|
||||
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']
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$managers_form->runAtServer();
|
||||
|
||||
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'], '上传者')
|
||||
)
|
||||
);
|
||||
$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 '用户不存在';
|
||||
}
|
||||
|
||||
$vdata['username'] = $username;
|
||||
|
||||
return '';
|
||||
},
|
||||
]
|
||||
);
|
||||
$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;
|
||||
$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">
|
||||
<!-- 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 ?>
|
||||
</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>';
|
||||
}
|
||||
?>
|
||||
</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 -->
|
||||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
306
web/app/controllers/problem_permissions_manage.php
Normal file
306
web/app/controllers/problem_permissions_manage.php
Normal file
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
requireLib('bootstrap5');
|
||||
requirePHPLib('form');
|
||||
|
||||
Auth::check() || redirectToLogin();
|
||||
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
|
||||
UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403();
|
||||
|
||||
$tabs_info = [
|
||||
'statement' => [
|
||||
'name' => '题面',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/statement'),
|
||||
],
|
||||
'permissions' => [
|
||||
'name' => '权限',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/permissions'),
|
||||
],
|
||||
];
|
||||
|
||||
if (UOJProblem::info('type') === 'local') {
|
||||
$tabs_info['data'] = [
|
||||
'name' => '数据',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/data'),
|
||||
];
|
||||
} else if (UOJProblem::info('type') === 'remote') {
|
||||
//
|
||||
}
|
||||
|
||||
$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']
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$managers_form->runAtServer();
|
||||
|
||||
if (isSuperUser(Auth::user())) {
|
||||
$update_uploader_form = new UOJForm('update_uploader');
|
||||
$update_uploader_form->addInput('new_uploader_username', [
|
||||
'div_class' => 'col-auto',
|
||||
'label' => '上传者',
|
||||
'default_value' => UOJProblem::info('uploader') ?: 'root',
|
||||
'validator_php' => function ($username, &$vdata) {
|
||||
if (!UOJUser::query($username)) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
$vdata['username'] = $username;
|
||||
|
||||
return '';
|
||||
},
|
||||
]);
|
||||
$update_uploader_form->config['submit_button']['class'] = 'btn btn-warning';
|
||||
$update_uploader_form->config['submit_button']['text'] = '修改上传者';
|
||||
$update_uploader_form->config['confirm']['smart'] = true;
|
||||
$update_uploader_form->handle = function (&$vdata) {
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["uploader" => $vdata['username']],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$update_uploader_form->runAtServer();
|
||||
}
|
||||
|
||||
$view_type_form = new UOJForm('view_type');
|
||||
$view_type_form->addSelect('view_content_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1 me-2',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看提交文件',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_content_type'),
|
||||
]);
|
||||
$view_type_form->addSelect('view_all_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1 me-2',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看全部详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人'
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_all_details_type'),
|
||||
]);
|
||||
$view_type_form->addSelect('view_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1 me-2',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看测试点详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_details_type'),
|
||||
]);
|
||||
$view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_content_type'] = $_POST['view_content_type'];
|
||||
$config['view_all_details_type'] = $_POST['view_all_details_type'];
|
||||
$config['view_details_type'] = $_POST['view_details_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$view_type_form->runAtServer();
|
||||
|
||||
$solution_view_type_form = new UOJForm('solution_view_type');
|
||||
$solution_view_type_form->addSelect('view_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1 me-2',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_solution_type'),
|
||||
]);
|
||||
$solution_view_type_form->addSelect('submit_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1 me-2',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '提交题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('submit_solution_type'),
|
||||
]);
|
||||
$solution_view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_solution_type'] = $_POST['view_solution_type'];
|
||||
$config['submit_solution_type'] = $_POST['submit_solution_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$solution_view_type_form->runAtServer();
|
||||
?>
|
||||
<?php echoUOJPageHeader('权限管理 - ' . HTML::stripTags(UOJProblem::info('title'))) ?>
|
||||
|
||||
<div class="row">
|
||||
<!-- left col -->
|
||||
<div class="col-lg-9">
|
||||
<h1>
|
||||
<?= UOJProblem::cur()->getTitle() ?> 管理
|
||||
</h1>
|
||||
|
||||
<div class="my-3">
|
||||
<?= HTML::tablist($tabs_info, 'permissions', 'nav-pills') ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header fw-bold">管理者</div>
|
||||
<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>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="text-center">
|
||||
命令格式:命令一行一个,<code>+mike</code> 表示把 <code>mike</code> 加入管理者,<code>-mike</code> 表示把 <code>mike</code> 从管理者中移除。
|
||||
</p>
|
||||
|
||||
<?php $managers_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3 gy-2 gx-3">
|
||||
<div class="col-auto">
|
||||
<div class="card">
|
||||
<div class="card-header fw-bold">
|
||||
提交记录可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
<div class="card">
|
||||
<div class="card-header fw-bold">
|
||||
题解可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $solution_view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($update_uploader_form)) : ?>
|
||||
<div class="col-auto">
|
||||
<div class="card border-danger">
|
||||
<div class="card-header fw-bold text-bg-danger">
|
||||
题目上传者
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $update_uploader_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end left col -->
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
@ -6,6 +6,27 @@ Auth::check() || redirectToLogin();
|
||||
|
||||
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
|
||||
UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403();
|
||||
|
||||
$tabs_info = [
|
||||
'statement' => [
|
||||
'name' => '题面',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/statement'),
|
||||
],
|
||||
'permissions' => [
|
||||
'name' => '权限',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/permissions'),
|
||||
],
|
||||
];
|
||||
|
||||
if (UOJProblem::info('type') === 'local') {
|
||||
$tabs_info['data'] = [
|
||||
'name' => '数据',
|
||||
'url' => UOJProblem::cur()->getUri('/manage/data'),
|
||||
];
|
||||
} else if (UOJProblem::info('type') === 'remote') {
|
||||
//
|
||||
}
|
||||
|
||||
$problem_content = UOJProblem::cur()->queryContent();
|
||||
|
||||
$problem_editor = new UOJBlogEditor();
|
||||
@ -195,102 +216,9 @@ if (UOJProblem::info('type') == 'remote') {
|
||||
$convert_local_form->config['confirm']['text'] = '您真的要*不可逆*地将本题转换为本地题目吗?';
|
||||
$convert_local_form->runAtServer();
|
||||
}
|
||||
|
||||
$view_type_form = new UOJForm('view_type');
|
||||
$view_type_form->addSelect('view_content_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看提交文件',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_content_type'),
|
||||
]);
|
||||
$view_type_form->addSelect('view_all_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看全部详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人'
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_all_details_type'),
|
||||
]);
|
||||
$view_type_form->addSelect('view_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看测试点详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_details_type'),
|
||||
]);
|
||||
$view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_content_type'] = $_POST['view_content_type'];
|
||||
$config['view_all_details_type'] = $_POST['view_all_details_type'];
|
||||
$config['view_details_type'] = $_POST['view_details_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$view_type_form->runAtServer();
|
||||
|
||||
$solution_view_type_form = new UOJForm('solution_view_type');
|
||||
$solution_view_type_form->addSelect('view_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('view_solution_type'),
|
||||
]);
|
||||
$solution_view_type_form->addSelect('submit_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '提交题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => UOJProblem::cur()->getExtraConfig('submit_solution_type'),
|
||||
]);
|
||||
$solution_view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_solution_type'] = $_POST['view_solution_type'];
|
||||
$config['submit_solution_type'] = $_POST['submit_solution_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$solution_view_type_form->runAtServer();
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader('题面编辑 - ' . HTML::stripTags(UOJProblem::info('title'))) ?>
|
||||
<?php echoUOJPageHeader('题面管理 - ' . HTML::stripTags(UOJProblem::info('title'))) ?>
|
||||
|
||||
<div class="row">
|
||||
<!-- left col -->
|
||||
@ -299,25 +227,9 @@ $solution_view_type_form->runAtServer();
|
||||
<?= UOJProblem::cur()->getTitle(['with' => 'id']) ?> 管理
|
||||
</h1>
|
||||
|
||||
<ul class="nav nav-pills my-3" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="/problem/<?= UOJProblem::info('id') ?>/manage/statement" role="tab">
|
||||
题面
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" 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 ?>
|
||||
</ul>
|
||||
<div class="my-3">
|
||||
<?= HTML::tablist($tabs_info, 'statement', 'nav-pills') ?>
|
||||
</div>
|
||||
|
||||
<div class="card card-default">
|
||||
<div class="card-body">
|
||||
@ -330,7 +242,7 @@ $solution_view_type_form->runAtServer();
|
||||
<div class="card-body">
|
||||
<h2 class="h3 card-title">提示</h2>
|
||||
<ol>
|
||||
<li>请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),以便备份及后期维护;</li>
|
||||
<li>请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),可以上传至 <a href="<?= UOJProblem::cur()->getUri('/resources') ?>">题目资源</a> 中,以便备份及后期维护;</li>
|
||||
<li>请勿在题面中直接插入大段 HTML 代码,这可能会破坏页面的显示,可以考虑使用 <a class="text-decoration-none" href="/apps/html2markdown" target="_blank">转换工具</a> 转换后再作修正;</li>
|
||||
<li>图片上传推荐使用 <a class="text-decoration-none" href="/apps/image_hosting" target="_blank">S2OJ 图床</a>,以免后续产生外链图片大量失效的情况。</li>
|
||||
</ol>
|
||||
@ -494,24 +406,6 @@ $solution_view_type_form->runAtServer();
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-header fw-bold">
|
||||
提交记录可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-header fw-bold">
|
||||
题解可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $solution_view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
@ -87,11 +87,15 @@ class HTML {
|
||||
}
|
||||
|
||||
public static function tablist($tabs_info, $cur, $type = 'nav-tabs') {
|
||||
$html = '<ul class="nav ' . $type . '" role="tablist">';
|
||||
$html = HTML::tag_begin('ul', ['class' => "nav $type", 'role' => 'tablist']);
|
||||
foreach ($tabs_info as $id => $tab) {
|
||||
$html .= '<li class="nav-item"><a class="nav-link' . ($cur == $id ? ' active' : '') . '" href="' . $tab['url'] . '" role="tab">' . $tab['name'] . '</a></li>';
|
||||
$html .= HTML::tag('li', ['class' => 'nav-item'], HTML::tag('a', [
|
||||
'class' => 'nav-link' . ($cur == $id ? ' active' : ''),
|
||||
'href' => $tab['url'],
|
||||
'role' => 'tab',
|
||||
], $tab['name']));
|
||||
}
|
||||
$html .= '</ul>';
|
||||
$html .= HTML::tag_end('ul');
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ Route::group(
|
||||
Route::any('/problem/{id}/statistics', '/problem_statistics.php');
|
||||
Route::any('/problem/{id}/resources(?:/{sub_path})?', '/problem_resources.php');
|
||||
Route::any('/problem/{id}/manage/statement', '/problem_statement_manage.php');
|
||||
Route::any('/problem/{id}/manage/managers', '/problem_managers_manage.php');
|
||||
Route::any('/problem/{id}/manage/permissions', '/problem_permissions_manage.php');
|
||||
Route::any('/problem/{id}/manage/data', '/problem_data_manage.php');
|
||||
Route::any('/download/testlib.h', '/download.php?type=testlib.h');
|
||||
Route::any('/download/problem/{id}/data.zip', '/download.php?type=problem');
|
||||
|
Loading…
Reference in New Issue
Block a user