fix(web/submissions): submission_list view permission
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-10 17:03:57 +08:00
parent 34ce6fd556
commit 4018227d8b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 6 additions and 3 deletions

View File

@ -467,9 +467,9 @@ function echoSubmissionsList($cond, $tail, $config, $user) {
$table_name = isset($config['table_name']) ? $config['table_name'] : 'submissions'; $table_name = isset($config['table_name']) ? $config['table_name'] : 'submissions';
if (!isSuperUser($user)) { if (!isProblemManager($user)) {
if ($user != null) { 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 { } else {
$permission_cond = "submissions.is_hidden = false"; $permission_cond = "submissions.is_hidden = false";
} }

View File

@ -200,7 +200,7 @@ function isContestProblemVisibleToUser($problem, $contest, $user) {
} }
function isSubmissionVisibleToUser($submission, $problem, $user) { function isSubmissionVisibleToUser($submission, $problem, $user) {
if (isSuperUser($user)) { if (isProblemManager($user)) {
return true; return true;
} elseif (!$submission['is_hidden']) { } elseif (!$submission['is_hidden']) {
return true; return true;

View File

@ -163,6 +163,9 @@ function isProblemManager($user) {
if ($user == null) { if ($user == null) {
return false; return false;
} }
if (isSuperUser($user)) {
return true;
}
return hasUserType($user, 'problem_manager'); return hasUserType($user, 'problem_manager');
} }
function isContestJudger($user) { function isContestJudger($user) {