mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 16:48:41 +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':
|
||||
DB::update("update user_info set usergroup = 'U' 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}'");
|
||||
$user = addUserType($user, 'problem_uploader');
|
||||
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
|
||||
break;
|
||||
case 'problem_manager':
|
||||
DB::update("update user_info set usergroup = 'U' 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}'");
|
||||
$user = addUserType($user, 'problem_manager');
|
||||
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
|
||||
break;
|
||||
case 'superuser':
|
||||
DB::update("update user_info set usergroup = 'S' where username = '{$username}'");
|
||||
|
@ -194,3 +194,20 @@ function sendSystemMsg($username, $title, $content) {
|
||||
$title = DB::escape($title);
|
||||
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