1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-25 19:37:23 +02:00

Possibilité de virer ou d'ajouter des personnes dans les équipes par les administrateurs

This commit is contained in:
galaxyoyo
2019-09-28 00:48:30 +02:00
parent c1f37ff530
commit 7ad974c304
4 changed files with 130 additions and 7 deletions

View File

@ -21,15 +21,16 @@ function loadUserValues()
}
}
function quitTeam()
function quitTeam($user_id = -1)
{
global $DB, $URL_BASE;
header("Location: $URL_BASE");
if ($user_id == -1)
header("Location: $URL_BASE");
$user_id = $user_id >= 0 ? $user_id : $_SESSION["user_id"];
/** @var User $user */
$user = $_SESSION["user"];
$user_id = $user->getId();
$user = User::fromId($user_id);
$role = $user->getRole();
if ($role == Role::ADMIN)
@ -47,7 +48,7 @@ function quitTeam()
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
}
$DB->exec("DELETE FROM `teams` WHERE `encadrant` IS NULL OR `participant_1` IS NULL;");
$DB->exec("DELETE FROM `teams` WHERE `encadrant` IS NULL AND `participant_1` IS NULL;");
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = $user_id;");
while (($data = $req->fetch()) !== false)
unlink("$URL_BASE/files/" . $data["file_id"]);