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']
]
]);
}
},
null,
[
'help' => '命令格式:命令一行一个,+mike
表示把 mike
加入管理者,-mike
表示把 mike
从管理者中移除。',
]
);
$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();
?>