|
|
|
|
@ -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}",
|
|
|
|
|
|