diff --git a/lbplanner/classes/helpers/course_helper.php b/lbplanner/classes/helpers/course_helper.php index 20e30b8c..d43d31d8 100644 --- a/lbplanner/classes/helpers/course_helper.php +++ b/lbplanner/classes/helpers/course_helper.php @@ -109,7 +109,7 @@ public static function get_all_eduplanner_courses(bool $onlyenrolled=true): arra AND ue.timestart <= :now AND c.enddate > :courseexpiredate AND ti.tagid = :lbptagid - AND ti.itemtype = \"course\"", + AND ti.itemtype = 'course'", [ "userid" => $userid, "active" => ENROL_USER_ACTIVE, @@ -123,9 +123,8 @@ public static function get_all_eduplanner_courses(bool $onlyenrolled=true): arra $mdlcourses = $DB->get_records_sql(" SELECT c.* FROM {course} c INNER JOIN {tag_instance} ti ON (ti.itemid = c.id) - WHERE c.enddate > :courseexpiredate AND ti.tagid = :lbptagid AND ti.itemtype = \"course\"", + WHERE c.enddate > :courseexpiredate AND ti.tagid = :lbptagid AND ti.itemtype = 'course'", [ - "now" => time(), "courseexpiredate" => $courseexpiredate, "lbptagid" => $lbptag->id, ] diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php index 39606d23..ab063e4f 100644 --- a/lbplanner/db/upgrade.php +++ b/lbplanner/db/upgrade.php @@ -95,7 +95,7 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool { } core_tag_tag::add_item_tag('core', 'course', $courseid, context_course::instance($courseid), $tag->rawname); } - + upgrade_plugin_savepoint(true, 202509060001, 'local', 'lbplanner'); } return true; diff --git a/lbplanner/services/slots/book_reservation.php b/lbplanner/services/slots/book_reservation.php index 2795f499..98241378 100644 --- a/lbplanner/services/slots/book_reservation.php +++ b/lbplanner/services/slots/book_reservation.php @@ -99,14 +99,16 @@ public static function book_reservation(int $slotid, string $date, int $userid): $maxdays = null; $student = null; - if ($userid === intval($USER->id)) { + $curuserid = intval($USER->id); + + if ($userid === $curuserid) { // Student reserving slot for themself. $maxdays = config_helper::get_slot_futuresight(); $student = $USER; } else { // Supervisor reserving slot for student. - slot_helper::assert_slot_supervisor($USER->id, $slotid); + slot_helper::assert_slot_supervisor($curuserid, $slotid); $maxdays = slot_helper::RESERVATION_RANGE_SUPERVISOR; $student = core_user::get_user($userid, '*', MUST_EXIST); @@ -135,7 +137,7 @@ public static function book_reservation(int $slotid, string $date, int $userid): throw new \moodle_exception('Slot is already full'); } - $reservation = new reservation(0, $slotid, $dateobj, $userid, $USER->id); + $reservation = new reservation(0, $slotid, $dateobj, $userid, $curuserid); $reservation->set_slot($slot); // Check if user is already in a different slot at the same time. @@ -148,7 +150,7 @@ public static function book_reservation(int $slotid, string $date, int $userid): } // If this is not a supervisor doing supervising, we throw an error if the user is in an oevrlapping reservation. - if ($userid === $USER->id && count($overlapreservations) > 0) { + if ($userid === $curuserid && count($overlapreservations) > 0) { throw new \moodle_exception('you\'re already in another reservation at this date and time…'); } @@ -156,7 +158,7 @@ public static function book_reservation(int $slotid, string $date, int $userid): $reservation->set_fresh($id, $slot); // If this is a supervisor reserving for a student, notify the student. - if ($userid !== $USER->id) { + if ($userid !== $curuserid) { notifications_helper::notify_user($userid, $reservation->id, NOTIF_TRIGGER::BOOK_FORCED); // Remove user from each overlapping reservation and notify them about it. diff --git a/lbplanner/version.php b/lbplanner/version.php index 95a2b620..7a1aa98a 100644 --- a/lbplanner/version.php +++ b/lbplanner/version.php @@ -28,7 +28,7 @@ $plugin->maturity = MATURITY_BETA; $plugin->component = 'local_lbplanner'; $plugin->release = '1.1.2'; -$plugin->version = 202509260000; +$plugin->version = 202509260002; $plugin->dependencies = [ // Depend upon version 2023110600 of local_modcustomfields. 'local_modcustomfields' => 2023110600,