|
|
@ -10,37 +10,41 @@ class AdminController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public function showAllUsers(): void {
|
|
|
|
public function showAllUsers(): void {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$users = $model->getAllUsers();
|
|
|
|
$users = $model->getAllUsers();
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users]);
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function showAllAdmins(): void {
|
|
|
|
public function showAllAdmins(): void {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$users = $model->getAllAdmins();
|
|
|
|
$users = $model->getAllAdmins();
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users]);
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function showAllTeachers(): void {
|
|
|
|
public function showAllTeachers(): void {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$users = $model->getAllTeachers();
|
|
|
|
$users = $model->getAllTeachers();
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users]);
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function showAllStudents(): void {
|
|
|
|
public function showAllStudents(): void {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$users = $model->getAllStudents();
|
|
|
|
$users = $model->getAllStudents();
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users]);
|
|
|
|
echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function removeUser(): void {
|
|
|
|
public function removeUser(): void {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$id = Validation::filter_int($_GET['userID'] ?? null);
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model->removeUser($id);
|
|
|
|
$model->removeUser($user->getId());
|
|
|
|
$this->showAllUsers();
|
|
|
|
$this->showAllUsers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
catch (Exception $e) {
|
|
|
@ -50,21 +54,24 @@ class AdminController
|
|
|
|
|
|
|
|
|
|
|
|
public function showAllGroups(): void {
|
|
|
|
public function showAllGroups(): void {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$groups = $model->getAllGroups();
|
|
|
|
$groups = $model->getAllGroups();
|
|
|
|
$unassignedUsers = $model->getUnassignedUsers();
|
|
|
|
$unassignedUsers = $model->getUnassignedUsers();
|
|
|
|
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers]);
|
|
|
|
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function showGroupDetails(): void {
|
|
|
|
public function showGroupDetails(): void {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
|
|
|
|
global $user;
|
|
|
|
$selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null);
|
|
|
|
$selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null);
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$groups = $model->getAllGroups();
|
|
|
|
$groups = $model->getAllGroups();
|
|
|
|
$users = $model->getUsersOfGroup($selectedGroup);
|
|
|
|
$users = $model->getUsersOfGroup($selectedGroup);
|
|
|
|
$unassignedUsers = $model->getUnassignedUsers();
|
|
|
|
$unassignedUsers = $model->getUnassignedUsers();
|
|
|
|
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers]);
|
|
|
|
|
|
|
|
|
|
|
|
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
catch (Exception $e) {
|
|
|
|
throw new Exception("invalid group ID");
|
|
|
|
throw new Exception("invalid group ID");
|
|
|
@ -113,10 +120,10 @@ class AdminController
|
|
|
|
|
|
|
|
|
|
|
|
public function addUserToGroup(): void {
|
|
|
|
public function addUserToGroup(): void {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$user = Validation::filter_int($_GET['userID'] ?? null);
|
|
|
|
global $user;
|
|
|
|
$group = Validation::filter_int($_GET['groupID'] ?? null);
|
|
|
|
$group = Validation::filter_int($_GET['groupID'] ?? null);
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model = new MdlAdmin();
|
|
|
|
$model->addUserToGroup($user, $group);
|
|
|
|
$model->addUserToGroup($user->getId(), $group);
|
|
|
|
$_GET['selectedGroup'] = $group;
|
|
|
|
$_GET['selectedGroup'] = $group;
|
|
|
|
$this->showGroupDetails();
|
|
|
|
$this->showGroupDetails();
|
|
|
|
}
|
|
|
|
}
|
|
|
|