/** * AJAX ONLY ! - Suppression d'une affectation */ public function processRemoveAssignment() { // Récupération des paramètres $userType = _request('user_type', null); $userId = _request('user_id', null); $classroomId = _request('classroom_id', null); // Paramètres obligatoires if (is_null($userType) || is_null($userId) || is_null($classroomId)) { return new CopixActionReturn(CopixActionReturn::HTTPCODE, array('Content-Type: text/plain; charset=utf-8', 'HTTP/1.1 400 Bad Request'), 'Une erreur est survenue'); } // Récupération de la classe $classroomDAO = _ioDAO('kernel|kernel_bu_ecole_classe'); if (!($classroom = $classroomDAO->get($classroomId))) { return new CopixActionReturn(CopixActionReturn::HTTPCODE, array('Content-Type: text/plain; charset=utf-8', 'HTTP/1.1 404 Not found'), 'Classe non trouvée'); } // Récupération du user $userDAO = _ioDAO('kernel|kernel_copixuser'); $user = $userDAO->getUserByBuIdAndBuType($userId, $userType); if (false === $user) { return new CopixActionReturn(CopixActionReturn::HTTPCODE, array('Content-Type: text/plain; charset=utf-8', 'HTTP/1.1 404 Not found'), 'Utilisateur non trouvé'); } // Suppression de l'affectation _classInclude('gestionautonome|GestionAutonomeService'); if ($userType == 'USER_ELE') { // Contrôle des droits _currentUser()->assertCredential('module:classroom|' . $classroomId . '|student|update@gestionautonome'); GestionAutonomeService::removeStudentAssignment($userId, $classroomId); } else { // Contrôle des droits _currentUser()->assertCredential('module:classroom|' . $classroomId . '|teacher|update@gestionautonome'); GestionAutonomeService::removePersonnelAssignment($userId, $classroomId, 'CLASSE'); } return new CopixActionReturn(CopixActionReturn::HTTPCODE, array('Content-Type: text/html; charset=utf-8', 'HTTP/1.1 200 OK'), CopixZone::process('gestionautonome|manageAssignments')); }