public function deleteFormation($idFormation) { try { mysqli_query($_SESSION['bdd'], "DELETE FROM `assouserformation` WHERE `id_formation` = '" . $idFormation . "'"); $managerModule = new ModuleDAO(); $resultats = $managerModule->getModulesByFormation($idFormation); $moduleToDelete = array(); foreach ($resultats as $module) { $query = mysqli_query($_SESSION['bdd'], "SELECT * FROM `assomoduleformation` WHERE `id_formation` != '" . $idFormation . "' AND `id_module` = '" . $module['id'] . "'"); if (mysqli_num_rows($query) == '0') { array_push($moduleToDelete, $module); } } mysqli_query($_SESSION['bdd'], "DELETE FROM `assomoduleformation` WHERE `id_formation` = '" . $idFormation . "'"); foreach ($moduleToDelete as $module) { mysqli_query($_SESSION['bdd'], "DELETE FROM `practices` WHERE `id_module` = '" . $module['id'] . "'"); mysqli_query($_SESSION['bdd'], "DELETE FROM `modules` WHERE `id` = '" . $module['id'] . "'"); } mysqli_query($_SESSION['bdd'], "DELETE FROM `formations` WHERE `id` = '" . $idFormation . "'"); } catch (Exception $e) { $_SESSION['error'] = 'Erreur requete BDD'; $_SESSION['display_msg_error'] = true; } }
public function deleteModule($idModule) { $managerModule = new ModuleDAO(); $managerModule->deleteModule($idModule); }
public function showFormation() { if (isset($_GET['idFormation'])) { $infosUser = new UserDAO(); $infos = $infosUser->getInfoUser($_SESSION['idUser']); $managerFormation = new FormationDAO(); $haveRight = false; if ($infos['type'] != 'Admin') { $formations = $managerFormation->getFormationsByUser($infos['id']); foreach ($formations as $formation) { if ($formation['id'] == $_GET['idFormation']) { $haveRight = true; } } } if ($haveRight || $infos['type'] == 'Admin') { $verifFormation = new FormationDAO(); $isFormationExist = $verifFormation->verifFormation($_GET['idFormation']); if (!$isFormationExist) { $_SESSION['error'] = 'La formation n\'existe pas'; $_SESSION['display_msg_error'] = true; $this->profile(); } else { $managerModule = new ModuleDAO(); $mesModules = $managerModule->getModulesByFormation($_GET['idFormation']); $infosFormation = $managerFormation->getNameAndDescriptionFormation($_GET['idFormation']); $moduleView = new ModuleView(); echo $moduleView->getView($mesModules, $infos['type'], $infosFormation['name']); } } else { $_SESSION['error'] = 'Vous n\'avez pas les droits requis pour accéder à cette page'; $_SESSION['display_msg_error'] = true; $this->profile(); } } else { $_SESSION['error'] = '[11] La page n\'existe pas'; $_SESSION['display_msg_error'] = true; $this->profile(); } }