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
3 changes: 2 additions & 1 deletion lbplanner/classes/helpers/slot_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ public static function filter_slots_for_time(array $allslots, int $range): array
foreach ($allslots as $slot) {
$slotdatetime = self::calculate_slot_datetime($slot, $now);

if ($now->diff($slotdatetime)->days <= $range) {
// Compare only date difference, ignoring time.
if ($now->setTime(0, 0, 0)->diff($slotdatetime->setTime(0, 0, 0))->days < $range) {
array_push($slots, $slot);
}
}
Expand Down
1 change: 1 addition & 0 deletions lbplanner/db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
'local_lbplanner_slots_get_all_slots',
'local_lbplanner_slots_get_my_slots',
'local_lbplanner_slots_get_slot_filters',
'local_lbplanner_slots_get_slot_reservations',
'local_lbplanner_slots_get_student_slots',
'local_lbplanner_slots_get_supervisor_slots',
'local_lbplanner_slots_remove_slot_supervisor',
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/services/plan/update_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function update_access(int $accesstype, int $memberid) {

$planid = plan_helper::get_plan_id($USER->id);

if (plan_helper::get_owner($planid) !== $USER->id) {
if (plan_helper::get_owner($planid) !== intval($USER->id)) {
throw new \moodle_exception('Access denied');
}

Expand Down
8 changes: 5 additions & 3 deletions lbplanner/services/slots/book_reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use core_user;
use core_external\{external_api, external_function_parameters, external_single_structure, external_value};
use DateTimeZone;
use local_lbplanner\enums\NOTIF_TRIGGER;
use local_lbplanner\helpers\notifications_helper;
use local_lbplanner\helpers\slot_helper;
Expand Down Expand Up @@ -82,14 +83,15 @@ public static function book_reservation(int $slotid, string $date, int $userid):
]
);

$now = new DateTimeImmutable();
$dateobj = DateTimeImmutable::createFromFormat("Y-m-d", $date);
$utctz = new DateTimeZone('UTC');
$now = new DateTimeImmutable('today', $utctz);
$dateobj = DateTimeImmutable::createFromFormat("Y-m-d", $date, $utctz);
if ($dateobj === false) {
throw new \moodle_exception("invalid date formatting: got '{$date}', must be YYYY-MM-DD");
}
$td = $now->diff($dateobj);

if ($td->invert) {
if ($td->invert === 1) {
throw new \moodle_exception('Can\'t reserve date in the past');
}

Expand Down
6 changes: 3 additions & 3 deletions lbplanner/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

defined('MOODLE_INTERNAL') || die();

$release = '0.0.0';
$release = '1.0.0';

$plugin->component = 'local_lbplanner';
$plugin->release = 'Alpha v.'.$release;
$plugin->version = 2025012803;
$plugin->release = 'Beta v.'.$release;
$plugin->version = 2025021100;
$plugin->dependencies = [
// Depend upon version 2023110600 of local_modcustomfields.
'local_modcustomfields' => 2023110600,
Expand Down
Loading