Skip to content

Commit

Permalink
Updated a condition in delete_user_course
Browse files Browse the repository at this point in the history
Updated the condition to retrieve dynamically the trainer_access_level.
Other changes.
  • Loading branch information
DydyCraft-21 committed Jul 10, 2024
1 parent 028aa36 commit 9ad4104
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions orif/plafor/Controllers/CoursePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,23 +369,24 @@ public function delete_operational_competence($operational_comp_id = 0, $action
/**
* Deletes a user's course depending on $action
*
* @param integer $user_course_id : ID of the user_course to affect
* @param integer $action : Action to apply on the course plan:
* @param integer $user_course_id ID of the user_course to affect
* @param integer $action Action to apply on the course plan :
* - 0 for displaying the confirmation
* - 1 for deleting (hard delete)
*
* @return void
*
*/
public function delete_user_course($user_course_id = 0, $action = 0)
{
$user_course = $this->user_course_model->find($user_course_id);

// Redirection
if (is_null($user_course)) {
if (is_null($user_course))
return redirect()->to(base_url('plafor/courseplan/list_user_courses'));
}

// Checks if a currently logged trainer is the trainer of the apprentice
if($_SESSION['user_access'] === 2)
if($_SESSION['user_access'] === config('\User\Config\UserConfig')->access_lvl_trainer)
{
$trainer = $this->trainer_apprentice_model->getTrainer($_SESSION['user_id']);
$doesTrainerTrainsApprentice = false;
Expand All @@ -409,7 +410,8 @@ public function delete_user_course($user_course_id = 0, $action = 0)
}

// Access permissions
if ($_SESSION['user_access'] >= config('\User\Config\UserConfig')->access_lvl_admin || (isset($doesTrainerTrainsApprentice) && $doesTrainerTrainsApprentice))
if ($_SESSION['user_access'] >= config('\User\Config\UserConfig')->access_lvl_admin
|| (isset($doesTrainerTrainsApprentice) && $doesTrainerTrainsApprentice))
{
// Gets data for the confirmation view
$course_plan = $this->course_plan_model->find($user_course['fk_course_plan']);
Expand Down

0 comments on commit 9ad4104

Please sign in to comment.