mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 12:18:42 +00:00
feat(web): multiple permissions for user
This commit is contained in:
parent
a5a3fb9288
commit
0af24b52ac
@ -142,11 +142,23 @@
|
|||||||
break;
|
break;
|
||||||
case 'problem_uploader':
|
case 'problem_uploader':
|
||||||
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
|
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
|
||||||
DB::update("update user_info set usertype = 'problem_uploader' where username = '{$username}'");
|
$user = queryUser($username);
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
if (!in_array('problem_uploader', $usertype)) {
|
||||||
|
$usertype[] = 'problem_uploader';
|
||||||
|
}
|
||||||
|
$usertype = implode(',', $usertype);
|
||||||
|
DB::update("update user_info set usertype = '{$usertype}' where username = '{$username}'");
|
||||||
break;
|
break;
|
||||||
case 'problem_manager':
|
case 'problem_manager':
|
||||||
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
|
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
|
||||||
DB::update("update user_info set usertype = 'problem_manager' where username = '{$username}'");
|
$user = queryUser($username);
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
if (!in_array('problem_manager', $usertype)) {
|
||||||
|
$usertype[] = 'problem_manager';
|
||||||
|
}
|
||||||
|
$usertype = implode(',', $usertype);
|
||||||
|
DB::update("update user_info set usertype = '{$usertype}' where username = '{$username}'");
|
||||||
break;
|
break;
|
||||||
case 'superuser':
|
case 'superuser':
|
||||||
DB::update("update user_info set usergroup = 'S' where username = '{$username}'");
|
DB::update("update user_info set usergroup = 'S' where username = '{$username}'");
|
||||||
@ -427,7 +439,7 @@ EOD;
|
|||||||
echo <<<EOD
|
echo <<<EOD
|
||||||
<tr>
|
<tr>
|
||||||
<td>${hislink}</td>
|
<td>${hislink}</td>
|
||||||
<td>{$row['usergroup']}</td>
|
<td>{$row['usergroup']}, {$row['usertype']}</td>
|
||||||
<td>{$row['register_time']}</td>
|
<td>{$row['register_time']}</td>
|
||||||
</tr>
|
</tr>
|
||||||
EOD;
|
EOD;
|
||||||
|
@ -130,10 +130,18 @@ function blog_name_decode($name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isProblemUploader($user) {
|
function isProblemUploader($user) {
|
||||||
return $user != null && $user['usertype'] == 'problem_uploader';
|
if ($user == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
return in_array('problem_uploader', $usertype);
|
||||||
}
|
}
|
||||||
function isProblemManager($user) {
|
function isProblemManager($user) {
|
||||||
return $user != null && $user['usertype'] == 'problem_manager';
|
if ($user == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
return in_array('problem_manager', $usertype);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSuperUser($user) {
|
function isSuperUser($user) {
|
||||||
|
Loading…
Reference in New Issue
Block a user