moodlehq / moodle-auth_pop3

Pop3 authentication plugin removed from standard distibution in Moodle 3.4
0 stars 2 forks source link

map pop3 username to local email feature #1

Closed PawelSuwinski closed 6 years ago

PawelSuwinski commented 6 years ago

Hi

Here is my little addon I did on my moodle site, should be self-explainable.

Index: auth.php
===================================================================
--- auth.php    (wersja 4)
+++ auth.php    (kopia robocza)
@@ -137,6 +137,17 @@
         }
     }

+    /**
+     * {@inheritdoc} 
+     *
+     * @param string $username username
+     * @return mixed array with no magic quotes or false on error
+     */
+    function get_userinfo($username) {
+        return !empty($this->config->mapusernametoemail) 
+           ? array('email' => $username)
+            : array();
+    }
 }

 Index: lang/en/auth_pop3.php
===================================================================
--- lang/en/auth_pop3.php       (wersja 4)
+++ lang/en/auth_pop3.php       (kopia robocza)
@@ -34,3 +34,5 @@
 $string['auth_pop3type'] = 'Server type. If your server uses certificate security, choose pop3cert.';
 $string['auth_pop3type_key'] = 'Type';
 $string['pluginname'] = 'POP3 server';
+$string['auth_pop3mapusernametoemail'] = 'Map pop3 username to local email';
+$string['auth_pop3mapusernametoemailhelp'] = 'If an email address is used as remote pop3 username to authenticate you can map it to local email (for example to be able to lock email field).';
Index: settings.php
===================================================================
--- settings.php        (wersja 4)
+++ settings.php        (kopia robocza)
@@ -58,6 +58,11 @@
             get_string('auth_pop3changepasswordurl_key', 'auth_pop3'),
             get_string('changepasswordhelp', 'auth'), '', PARAM_URL));

+    // Map pop3 username to email
+    $settings->add(new admin_setting_configcheckbox('auth_pop3/mapusernametoemail',
+        get_string('auth_pop3mapusernametoemail', 'auth_pop3'),
+        get_string('auth_pop3mapusernametoemailhelp', 'auth_pop3'), ''));
+
     // Display locking / mapping of profile fields.
     $authplugin = get_auth_plugin('pop3');
     display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,

auth_pop3-mapusernametoemail-201807031000.diff.txt

PawelSuwinski commented 6 years ago

I did a pull request (#2).