From 4ad0d0f2f50860e4d07236ee2645c87e7a74fa6e Mon Sep 17 00:00:00 2001 From: Vadim Dvorovenko Date: Thu, 15 Jan 2015 00:44:37 +0700 Subject: [PATCH] MDL-43415 auth_db: Adding custom profile fields to "Lock user fields" Adding custom profile fields to "Lock user fields". It's needed to sync custom user profile fields with external DB. --- auth/db/auth.php | 10 +++++++++- auth/db/config.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/auth/db/auth.php b/auth/db/auth.php index 3feed3edfb6..fe3ebeccf0e 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -168,7 +168,15 @@ class auth_plugin_db extends auth_plugin_base { */ function db_attributes() { $moodleattributes = array(); - foreach ($this->userfields as $field) { + // If we have custom fields then merge them with user fields. + $customfields = $this->get_custom_user_profile_fields(); + if (!empty($customfields) && !empty($this->userfields)) { + $userfields = array_merge($this->userfields, $customfields); + } else { + $userfields = $this->userfields; + } + + foreach ($userfields as $field) { if (!empty($this->config->{"field_map_$field"})) { $moodleattributes[$field] = $this->config->{"field_map_$field"}; } diff --git a/auth/db/config.html b/auth/db/config.html index 331ad04127a..8d04d04444b 100644 --- a/auth/db/config.html +++ b/auth/db/config.html @@ -270,7 +270,7 @@ authtype, $user_fields, get_string('auth_dbextrafields', 'auth_db'), true, true); +print_auth_lock_options($this->authtype, $user_fields, get_string('auth_dbextrafields', 'auth_db'), true, true, $this->get_custom_user_profile_fields()); ?>