From 4018227d8b42132c97d31f8294f43f65e48a286f Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 10 Oct 2022 17:03:57 +0800 Subject: [PATCH] fix(web/submissions): submission_list view permission --- web/app/libs/uoj-html-lib.php | 4 ++-- web/app/libs/uoj-query-lib.php | 2 +- web/app/libs/uoj-utility-lib.php | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index 207fafd..8580925 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -467,9 +467,9 @@ function echoSubmissionsList($cond, $tail, $config, $user) { $table_name = isset($config['table_name']) ? $config['table_name'] : 'submissions'; - if (!isSuperUser($user)) { + if (!isProblemManager($user)) { if ($user != null) { - $permission_cond = "submissions.is_hidden = false or (submissions.is_hidden = true and submissions.problem_id in (select problem_id from problems_permissions where username = '{$user['username']}'))"; + $permission_cond = "submissions.is_hidden = false or submissions.submitter = '{$user['username']}' or (submissions.is_hidden = true and (submissions.problem_id in (select problem_id from problems_permissions where username = '{$user['username']}') or submissions.problem_id in (select id from problems where uploader = '{$user['username']}')))"; } else { $permission_cond = "submissions.is_hidden = false"; } diff --git a/web/app/libs/uoj-query-lib.php b/web/app/libs/uoj-query-lib.php index 2080050..75988d9 100644 --- a/web/app/libs/uoj-query-lib.php +++ b/web/app/libs/uoj-query-lib.php @@ -200,7 +200,7 @@ function isContestProblemVisibleToUser($problem, $contest, $user) { } function isSubmissionVisibleToUser($submission, $problem, $user) { - if (isSuperUser($user)) { + if (isProblemManager($user)) { return true; } elseif (!$submission['is_hidden']) { return true; diff --git a/web/app/libs/uoj-utility-lib.php b/web/app/libs/uoj-utility-lib.php index d958ed1..89c649a 100644 --- a/web/app/libs/uoj-utility-lib.php +++ b/web/app/libs/uoj-utility-lib.php @@ -163,6 +163,9 @@ function isProblemManager($user) { if ($user == null) { return false; } + if (isSuperUser($user)) { + return true; + } return hasUserType($user, 'problem_manager'); } function isContestJudger($user) {