Allow using both prefixes and attributes to fetch IServ groups as courses
This commit is contained in:
24
lib.php
24
lib.php
@@ -321,33 +321,29 @@ 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}",
|
||||
"get_courses_ldap",
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user