diff --git a/lib.php b/lib.php index 0e080ee..3e40142 100644 --- a/lib.php +++ b/lib.php @@ -321,32 +321,28 @@ class enrol_iserv_plugin extends enrol_plugin private function get_courses_ldap($userid = "*") { // Used by a few conditionals below - $pattern = []; + $ldap_filters = []; - // Create course filter + // Create course filter by IServ group prefixes if ($this->config->coursemapping_use_prefixes) { $prefixes = explode(',', $this->config->coursemapping_prefixes); foreach ($prefixes as $prefix) { - $pattern[] = "({$this->config->group_attribute}={$prefix})"; + $ldap_filters[] = "({$this->config->group_attribute}={$prefix})"; } - $pattern = '(|' . implode($pattern) . ')'; - } else if ($this->config->coursemapping_use_attribute) { + } + + if ($this->config->coursemapping_use_attribute) { // If coursemapping attribute value contains a comma, treat it as list of valid attributes (OR'ed) if (strstr($this->config->coursemapping_attribute_value, '|') !== false) { foreach (explode('|', $this->config->coursemapping_attribute_value) as $prefix) { - $pattern[] = "({$this->config->coursemapping_attribute}={$prefix})"; + $ldap_filters[] = "({$this->config->coursemapping_attribute}={$prefix})"; } - $pattern = '(|' . implode($pattern) . ')'; } else { - $pattern = "({$this->config->coursemapping_attribute}={$this->config->coursemapping_attribute_value})"; + $ldap_filters[] = "({$this->config->coursemapping_attribute}={$this->config->coursemapping_attribute_value})"; } - } else { - self::debuglog( - "Invalid settings, enable either coursemapping_use_prefix or coursemapping_use_attribute", - "get_courses_ldap" - ); - return false; } + + $pattern = '(|' . implode($ldap_filters) . ')'; self::debuglog( "Using filter {$pattern} to fetch courses for {$userid}", diff --git a/version.php b/version.php index 7cd2756..b864b5f 100644 --- a/version.php +++ b/version.php @@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2026021601; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2026021602; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2015051100; // Requires Moodle version 2.9 $plugin->component = 'enrol_iserv'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_BETA; // Beta, nees testing.