From 8aae606acb4c555e38ba0c7625e06aa10a746504 Mon Sep 17 00:00:00 2001
From: Alexander Bias <alexander.bias@uni-ulm.de>
Date: Fri, 11 Dec 2020 08:59:05 +0100
Subject: [PATCH] Adopt code changes from Moodle 3.10 core auth_ldap.
---
CHANGES.md | 1 +
auth.php | 12 +++++-------
settings.php | 5 +++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 7253031..d76cecc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Changes
### Unreleased
+* 2020-12-11 - Adopt code changes from Moodle 3.10 core auth_ldap.
* 2020-12-11 - Prepare compatibility for Moodle 3.10.
* 2020-12-10 - Change in Moodle release support:
For the time being, this plugin is maintained for the most recent LTS release of Moodle as well as the most recent major release of Moodle.
diff --git a/auth.php b/auth.php
index f89f001..7f5fe45 100644
--- a/auth.php
+++ b/auth.php
@@ -118,7 +118,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
do {
if ($ldappagedresults) {
- // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
+ // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
// Before 7.3, use this function that was deprecated in PHP 7.4.
ldap_control_paged_result($ldapconnection, $this->config->pagesize, true, $ldapcookie);
@@ -131,7 +131,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
}
if ($this->config->search_sub) {
// Use ldap_search to find first user from subtree.
- // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
+ // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
$ldapresult = ldap_search($ldapconnection, $context, $filter, array($this->config->user_attribute));
} else {
@@ -140,7 +140,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
}
} else {
// Search only in this context.
- // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
+ // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
$ldapresult = ldap_list($ldapconnection, $context, $filter, array($this->config->user_attribute));
} else {
@@ -154,7 +154,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
if ($ldappagedresults) {
// Get next server cookie to know if we'll need to continue searching.
$ldapcookie = '';
- // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 4.1).
+ // TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
// Before 7.3, use this function that was deprecated in PHP 7.4.
$pagedresp = ldap_control_paged_result_response($ldapconnection, $ldapresult, $ldapcookie);
@@ -451,9 +451,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap {
//
// The cast to int is a workaround for MDL-53959.
$user->suspended = (int)$this->is_user_suspended($user);
- if (empty($user->lang)) {
- $user->lang = $CFG->lang;
- }
+
if (empty($user->calendartype)) {
$user->calendartype = $CFG->calendartype;
}
diff --git a/settings.php b/settings.php
index 32e8e77..7dff891 100644
--- a/settings.php
+++ b/settings.php
@@ -27,8 +27,9 @@ defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
if (!function_exists('ldap_connect')) {
- $settings->add(new admin_setting_heading('auth_ldap_syncplus_noextension', '',
- get_string('auth_ldap_noextension', 'auth_ldap')));
+ $notify = new \core\output\notification(get_string('auth_ldap_noextension', 'auth_ldap'),
+ \core\output\notification::NOTIFY_WARNING);
+ $settings->add(new admin_setting_heading('auth_ldap_noextension', '', $OUTPUT->render($notify)));
} else {
// We use a couple of custom admin settings since we need to massage the data before it is inserted into the DB.
--
GitLab