From f0974dbe8268e56826b9cb466d330bdd5f3dd892 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 8 Oct 2022 10:06:44 +0800 Subject: [PATCH] feat(web/problem/solution): hidden solutions --- web/app/controllers/problem_solutions.php | 38 +++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/web/app/controllers/problem_solutions.php b/web/app/controllers/problem_solutions.php index 6ec0c8a..0e43362 100644 --- a/web/app/controllers/problem_solutions.php +++ b/web/app/controllers/problem_solutions.php @@ -95,7 +95,7 @@ EOD; return '博客不存在'; } - if (!isSuperUser($myUser)) { + if (!hasProblemPermission($myUser, $problem)) { if ($blog['poster'] != $myUser['username']) { if ($blog['is_hidden']) { return '博客不存在'; @@ -103,10 +103,10 @@ EOD; return '只能提交本人撰写的博客'; } - } - if ($blog['is_hidden']) { - return '只能提交公开的博客'; + if ($blog['is_hidden']) { + return '只能提交公开的博客'; + } } if (querySolution($problem['id'], $x)) { @@ -135,9 +135,12 @@ EOD; } $pag_config = array('page_len' => 5); - $pag_config['col_names'] = array('blog_id', 'content', 'poster', 'post_time', 'zan'); + $pag_config['col_names'] = array('blog_id', 'content', 'poster', 'post_time', 'zan', 'is_hidden'); $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['cond'] = "problem_id = {$problem['id']}"; + if (!hasProblemPermission($myUser, $problem)) { + $pag_config['cond'] .= " and (is_hidden = 0 or poster = '{$myUser['username']}')"; + } $pag_config['tail'] = "order by zan desc, post_time desc, id asc"; $pag = new Paginator($pag_config); @@ -186,19 +189,34 @@ EOD; : + + 隐藏 +
-
+
+ +
  • + + 修改 + +
  • + +
  • + 在 Ta 的博客上查看 +
  • + +
  • + isEmpty()): ?>