Skip to content

Commit

Permalink
Merge pull request #59 from stopfstedt/58_ignore_disabled_instances_f…
Browse files Browse the repository at this point in the history
…rom_sync

Only process enabled Ilios enrollment instances.
  • Loading branch information
stopfstedt authored Oct 3, 2024
2 parents 0276761 + 1165be4 commit 90d5e62
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,14 @@ public function sync($trace, $courseid = null): int {

$unenrolaction = $this->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL);

// Iterate through all not enrolled yet users.
// Get all enabled enrollment Ilios instances.
$onecourse = $courseid ? "AND e.courseid = :courseid" : "";
$sql = "SELECT *
FROM {enrol} e
WHERE e.enrol = 'ilios' $onecourse";
$sql = "SELECT * FROM {enrol} e WHERE e.enrol = 'ilios' AND e.status = :status $onecourse";

$params = [];
$params['courseid'] = $courseid;
$params['suspended'] = ENROL_USER_SUSPENDED;
$params['status'] = ENROL_INSTANCE_ENABLED;

$instances = $DB->get_recordset_sql($sql, $params);

foreach ($instances as $instance) {
Expand Down

0 comments on commit 90d5e62

Please sign in to comment.