mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 03:08:41 +00:00
refactor(web/problem/solution): add_new_solution_form
This commit is contained in:
parent
aedc164801
commit
354dd361b0
@ -53,14 +53,14 @@ if (UOJRequest::post('submit-remove_solution') === 'remove_solution') {
|
||||
}
|
||||
|
||||
if (UOJProblem::cur()->userCanManage(Auth::user()) || UOJProblem::cur()->userPermissionCodeCheck(Auth::user(), UOJProblem::cur()->getExtraConfig('submit_solution_type'))) {
|
||||
$add_new_solution_form = new UOJBs4Form('add_new_solution');
|
||||
$add_new_solution_form->addVInput(
|
||||
$add_new_solution_form = new UOJForm('add_new_solution');
|
||||
$add_new_solution_form->addInput(
|
||||
'blog_id_2',
|
||||
'text',
|
||||
'博客 ID',
|
||||
'',
|
||||
function ($blog_id) {
|
||||
[
|
||||
'placeholder' => '博客 ID',
|
||||
'validator_php' => function ($blog_id, &$vdata) {
|
||||
$blog = UOJBlog::query($blog_id);
|
||||
|
||||
if (!$blog) {
|
||||
return '博客不存在';
|
||||
}
|
||||
@ -85,18 +85,19 @@ if (UOJProblem::cur()->userCanManage(Auth::user()) || UOJProblem::cur()->userPer
|
||||
return "该博客已经是题目 #$problem_id 的题解";
|
||||
}
|
||||
|
||||
$vdata['blog'] = $blog;
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
]
|
||||
);
|
||||
$add_new_solution_form->submit_button_config['text'] = '发布';
|
||||
$add_new_solution_form->submit_button_config['align'] = 'center';
|
||||
$add_new_solution_form->submit_button_config['class_str'] = 'btn btn-secondary';
|
||||
$add_new_solution_form->handle = function () {
|
||||
$add_new_solution_form->config['submit_button']['text'] = '发布';
|
||||
$add_new_solution_form->config['submit_button']['class'] = 'btn btn-secondary';
|
||||
$add_new_solution_form->handle = function (&$vdata) {
|
||||
DB::insert([
|
||||
"insert into problems_solutions",
|
||||
DB::bracketed_fields(["problem_id", "blog_id"]),
|
||||
"values", DB::tuple([UOJProblem::info('id'), $_POST['blog_id_2']]),
|
||||
"values", DB::tuple([UOJProblem::info('id'), $vdata['blog']->info['id']]),
|
||||
]);
|
||||
};
|
||||
$add_new_solution_form->runAtServer();
|
||||
|
Loading…
Reference in New Issue
Block a user