From 6d30969f427b41f332ffb8e25cbf430afde19ee2 Mon Sep 17 00:00:00 2001 From: Dani Tome Date: Wed, 30 May 2018 12:57:25 +0200 Subject: [PATCH] Added support to Moodle v3.3+ --- auth.php | 15 --------------- config.html | 52 ---------------------------------------------------- settings.php | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 67 deletions(-) delete mode 100755 config.html create mode 100644 settings.php diff --git a/auth.php b/auth.php index 3458bf1..1479341 100755 --- a/auth.php +++ b/auth.php @@ -123,21 +123,6 @@ class auth_plugin_ip extends auth_plugin_manual { return false; } - /** - * Prints a form for configuring this authentication plugin. - * - * This function is called from admin/auth.php, and outputs a full page with - * a form for configuring this plugin. - * - * @param array $config An object containing all the data for this page. - * @param string $error - * @param array $user_fields - * @return void - */ - function config_form($config, $error, $user_fields) { - include 'config.html'; - } - /** * Updates the list of IPs and sends a notification by email. * diff --git a/config.html b/config.html deleted file mode 100755 index 86b4240..0000000 --- a/config.html +++ /dev/null @@ -1,52 +0,0 @@ -. - -/** - * Configuration settings form - * - * @package auth - * @subpackage ip - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @author Robert Boloc - * @author Jordi Pujol-Ahulló - * @copyright 2013 onwards Servei de Recursos Educatius (http://www.sre.urv.cat) - */ - - -// set to defaults if undefined -if (!isset($config->valid_ips)) { - $config->valid_ips = ''; -} - -?> - - - - - - - -
- -
- -
- diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..3bd38bc --- /dev/null +++ b/settings.php @@ -0,0 +1,40 @@ +. +/** + * @author Daniel Tomé + * @copyright 2017 Servei de Recursos Educatius (http://www.sre.urv.cat) + */ + +defined('MOODLE_INTERNAL') || die; + +if ($ADMIN->fulltree) { + $settings->add( + new admin_setting_heading( + 'auth_ip/auth_ipdescription', + '', + new lang_string('auth_ipdescription', 'auth_ip') + ) + ); + + $settings->add( + new admin_setting_configtextarea( + 'auth_ip/valid_ips', + new lang_string('auth_ipvalidips', 'auth_ip'), + new lang_string('auth_ipexampleips', 'auth_ip'), + '' + ) + ); +}