mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-25 22:38:40 +00:00
chore(web/super-manage): tidy up some code
This commit is contained in:
parent
d2ad335128
commit
e1efee927b
@ -143,22 +143,14 @@
|
|||||||
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}'");
|
||||||
$user = queryUser($username);
|
$user = queryUser($username);
|
||||||
$usertype = explode(',', $user['usertype']);
|
$user = addUserType($user, 'problem_uploader');
|
||||||
if (!in_array('problem_uploader', $usertype)) {
|
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
|
||||||
$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}'");
|
||||||
$user = queryUser($username);
|
$user = queryUser($username);
|
||||||
$usertype = explode(',', $user['usertype']);
|
$user = addUserType($user, 'problem_manager');
|
||||||
if (!in_array('problem_manager', $usertype)) {
|
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
|
||||||
$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}'");
|
||||||
|
@ -194,3 +194,20 @@ function sendSystemMsg($username, $title, $content) {
|
|||||||
$title = DB::escape($title);
|
$title = DB::escape($title);
|
||||||
DB::insert("insert into user_system_msg (receiver, title, content, send_time) values ('$username', '$title', '$content', now())");
|
DB::insert("insert into user_system_msg (receiver, title, content, send_time) values ('$username', '$title', '$content', now())");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addUserType($user, $type) {
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
if (!in_array($type, $usertype)) {
|
||||||
|
$usertype[] = $type;
|
||||||
|
}
|
||||||
|
$user['usertype'] = implode(',', $usertype);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
function removeUserType($user, $type) {
|
||||||
|
$usertype = explode(',', $user['usertype']);
|
||||||
|
if (in_array($type, $usertype)) {
|
||||||
|
$usertype = array_diff($usertype, array($type));
|
||||||
|
}
|
||||||
|
$user['usertype'] = implode(',', $usertype);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user