Skip to content

Commit

Permalink
Bugfix: Remove debug warning in enrol_semco_enrol_user webservice end…
Browse files Browse the repository at this point in the history
…point.
  • Loading branch information
abias committed Jun 17, 2024
1 parent 0e89053 commit 68bc975
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-06-01 - Bugfix: Remove debug warning in enrol_semco_enrol_user webservice endpoint.
* 2024-06-01 - Upgrade: Migrate the enrol_semco_before_standard_top_of_body_html() function to the new hook callback on Moodle 4.4.
* 2024-06-01 - Release: Let codechecker ignore some sniffs in the language pack.

Expand Down
16 changes: 9 additions & 7 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function enrol_semco_detect_enrolment_overlap($courseid, $userid, $timestart, $t
// OR which do not have an end date and start before this one ends
// OR which do not have a start date
// OR which end before this one ends.
$overlapstartexistssql = 'SELECT ue.id
$overlapendexistssql = 'SELECT ue.id
FROM {user_enrolments} ue
JOIN {enrol} e ON ue.enrolid = e.id AND e.courseid = :courseid
WHERE e.enrol = :enrol AND
Expand All @@ -134,18 +134,18 @@ function enrol_semco_detect_enrolment_overlap($courseid, $userid, $timestart, $t
OR ue.timeend = 0 AND ue.timestart <= :timeend1
OR ue.timestart = 0
OR ue.timeend > 0 AND ue.timeend <= :timeend2)';
$overlapstartparams = ['courseid' => $courseid,
$overlapendparams = ['courseid' => $courseid,
'userid' => $userid,
'enrol' => 'semco',
'timeend1' => $timeend,
'timeend2' => $timeend, // For a strange reason, Moodle does not allow to reuse SQL parameters.
'timestart' => $timestart,
];
if ($ignoreoriginalid != null) {
$overlapstartexistssql .= ' AND e.id != :ignoreid';
$overlapstartparams['ignoreid'] = $ignoreoriginalid;
$overlapendexistssql .= ' AND e.id != :ignoreid';
$overlapendparams['ignoreid'] = $ignoreoriginalid;
}
$overlapstartexists = $DB->record_exists_sql($overlapstartexistssql, $overlapstartparams);
$overlapendexists = $DB->record_exists_sql($overlapendexistssql, $overlapendparams);
}

// If we have a given end date and a given start date.
Expand Down Expand Up @@ -182,8 +182,10 @@ function enrol_semco_detect_enrolment_overlap($courseid, $userid, $timestart, $t
}

// If any overlap exists.
if ($overlapunlimitedexists == true || $overlapstartexists == true || $overlapstartexists == true ||
$overlapbothexists == true) {
if ((isset($overlapunlimitedexists) && $overlapunlimitedexists == true) ||
(isset($overlapstartexists) && $overlapstartexists == true) ||
(isset($overlapendexists) && $overlapstartexists == true) ||
(isset($overlapbothexists) && $overlapbothexists == true)) {
return true;

// Otherwise.
Expand Down

0 comments on commit 68bc975

Please sign in to comment.