addHidden("blog_id", $blog_id, function($blog_id) { global $myUser, $problem; if (!validateUInt($blog_id)) { return '博客 ID 不是有效的数字'; } $blog = queryBlog($blog_id); if (!$blog) { return '博客不存在'; } if (!hasProblemPermission($myUser, $problem)) { if ($blog['poster'] != $myUser['username']) { return '您只能删除自己的题解'; } } return ''; }, null); $res_form->handle = function() { global $myUser, $problem; $blog_id = $_POST["blog_id"]; DB::query("delete from problems_solutions where problem_id = {$problem['id']} and blog_id = {$blog_id}"); $blog = queryBlog($blog_id); if ($blog['poster'] != $myUser['username']) { $blog_link = getBlogLink($blog['id']); $poster_user_link = getUserLink($blog['poster']); $admin_user_link = getUserLink($myUser['username']); $content = <<{$poster_user_link} 您好:

您为问题 #{$problem['id']} ({$problem['title']}) 提交的题解 {$blog_link} 已经被 {$admin_user_link} 移除。

EOD; sendSystemMsg($blog['poster'], '题解移除通知', $content); } }; $res_form->submit_button_config['margin_class'] = 'mt-0'; $res_form->submit_button_config['class_str'] = 'btn btn-link text-decoration-none text-danger p-0'; $res_form->submit_button_config['text'] = '移除'; $res_form->submit_button_config['align'] = 'inline'; return $res_form; } if ($solution_submittable) { $add_new_solution_form = new UOJForm('add_new_solution'); $add_new_solution_form->addVInput('blog_id_2', 'text', '博客 ID', '', function ($x) { global $myUser, $problem, $solution_submittable; if (!validateUInt($x)) { return 'ID 不合法'; } $blog = queryBlog($x); if (!$blog) { return '博客不存在'; } if (!isSuperUser($myUser)) { if ($blog['poster'] != $myUser['username']) { if ($blog['is_hidden']) { return '博客不存在'; } return '只能提交本人撰写的博客'; } } if ($blog['is_hidden']) { return '只能提交公开的博客'; } if (querySolution($problem['id'], $x)) { return '该题解已提交'; } if (!$solution_submittable) { return '您无权提交题解'; } return ''; }, null ); $add_new_solution_form->submit_button_config['text'] = '发布'; $add_new_solution_form->submit_button_config['align'] = 'center'; $add_new_solution_form->handle = function() { global $problem, $myUser; $blog_id_2 = $_POST['blog_id_2']; $problem_id = $problem['id']; DB::insert("insert into problems_solutions (problem_id, blog_id) values ({$problem_id}, {$blog_id_2})"); }; $add_new_solution_form->runAtServer(); } $pag_config = array('page_len' => 5); $pag_config['col_names'] = array('blog_id', 'content', 'poster', 'post_time', 'zan'); $pag_config['table_name'] = "problems_solutions inner join blogs on problems_solutions.blog_id = blogs.id"; $pag_config['cond'] = "problem_id = {$problem['id']} and is_hidden = 0"; $pag_config['tail'] = "order by zan desc, post_time desc, id asc"; $pag = new Paginator($pag_config); $rows = []; foreach ($pag->get() as $idx => $row) { $rows[$idx] = $row; if ($row['poster'] == $myUser['username'] || hasProblemPermission($myUser, $problem)) { $removeForm = removeSolutionForm($row['blog_id']); $removeForm->runAtServer(); $rows[$idx]['removeForm'] = $removeForm; } } ?>

#.

pagination(); ?>