Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lbplanner/classes/helpers/course_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
]
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions lbplanner/services/slots/book_reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -148,15 +150,15 @@ 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…');
}

$id = $DB->insert_record(slot_helper::TABLE_RESERVATIONS, $reservation->prepare_for_db());
$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.
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading