diff --git a/db/app_uoj233.sql b/db/app_uoj233.sql index d0f01ca..941019f 100644 --- a/db/app_uoj233.sql +++ b/db/app_uoj233.sql @@ -632,6 +632,28 @@ LOCK TABLES `problems_permissions` WRITE; /*!40000 ALTER TABLE `problems_permissions` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `problems_solutions` +-- + +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `problems_solutions` ( + `problem_id` int(11) NOT NULL, + `blog_id` int(11) NOT NULL, + PRIMARY KEY (`problem_id`, `blog_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `problems_solutions` +-- + +LOCK TABLES `problems_solutions` WRITE; +/*!40000 ALTER TABLE `problems_solutions` DISABLE KEYS */; +/*!40000 ALTER TABLE `problems_solutions` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `problems_tags` -- diff --git a/web/app/controllers/problem.php b/web/app/controllers/problem.php index 8c3edf9..0837a85 100644 --- a/web/app/controllers/problem.php +++ b/web/app/controllers/problem.php @@ -314,6 +314,9 @@ $('#contest-countdown').countdown(= $contest['end_time']->getTimestamp() - UOJ
您为问题 #{$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; + } + } + ?> + + + + +