MDL-58439 admin: Ignore guest logins for all admin pages
[moodle.git] / auth / db / settings.php
blob54f3450eb0a1f67557d3f1db7c4c0d43ae32a570
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Admin settings and defaults.
20 * @package auth_db
21 * @copyright 2017 Stephen Bourget
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die;
27 if ($ADMIN->fulltree) {
29 // We use a couple of custom admin settings since we need to massage the data before it is inserted into the DB.
30 require_once($CFG->dirroot.'/auth/db/classes/admin_setting_special_auth_configtext.php');
32 // Needed for constants.
33 require_once($CFG->libdir.'/authlib.php');
35 // Introductory explanation.
36 $settings->add(new admin_setting_heading('auth_db/pluginname', '', new lang_string('auth_dbdescription', 'auth_db')));
38 // Host.
39 $settings->add(new admin_setting_configtext('auth_db/host', get_string('auth_dbhost_key', 'auth_db'),
40 get_string('auth_dbhost', 'auth_db') . ' ' .get_string('auth_multiplehosts', 'auth'),
41 '127.0.0.1', PARAM_RAW));
43 // Type.
44 $dboptions = array();
45 $dbtypes = array("access", "ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2",
46 "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mssql_n", "mssqlnative",
47 "mysql", "mysqli", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle",
48 "oracle", "pdo", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
49 foreach ($dbtypes as $dbtype) {
50 $dboptions[$dbtype] = $dbtype;
53 $settings->add(new admin_setting_configselect('auth_db/type',
54 new lang_string('auth_dbtype_key', 'auth_db'),
55 new lang_string('auth_dbtype', 'auth_db'), 'mysqli', $dboptions));
57 // Sybase quotes.
58 $yesno = array(
59 new lang_string('no'),
60 new lang_string('yes'),
63 $settings->add(new admin_setting_configselect('auth_db/sybasequoting',
64 new lang_string('auth_dbsybasequoting', 'auth_db'), new lang_string('auth_dbsybasequotinghelp', 'auth_db'), 0, $yesno));
66 // DB Name.
67 $settings->add(new admin_setting_configtext('auth_db/name', get_string('auth_dbname_key', 'auth_db'),
68 get_string('auth_dbname', 'auth_db'), '', PARAM_RAW_TRIMMED));
70 // DB Username.
71 $settings->add(new admin_setting_configtext('auth_db/user', get_string('auth_dbuser_key', 'auth_db'),
72 get_string('auth_dbuser', 'auth_db'), '', PARAM_RAW_TRIMMED));
74 // Password.
75 $settings->add(new admin_setting_configpasswordunmask('auth_db/pass', get_string('auth_dbpass_key', 'auth_db'),
76 get_string('auth_dbpass', 'auth_db'), ''));
78 // DB Table.
79 $settings->add(new admin_setting_configtext('auth_db/table', get_string('auth_dbtable_key', 'auth_db'),
80 get_string('auth_dbtable', 'auth_db'), '', PARAM_RAW_TRIMMED));
82 // DB User field.
83 $settings->add(new admin_setting_configtext('auth_db/fielduser', get_string('auth_dbfielduser_key', 'auth_db'),
84 get_string('auth_dbfielduser', 'auth_db'), '', PARAM_RAW_TRIMMED));
86 // DB User password.
87 $settings->add(new admin_setting_configtext('auth_db/fieldpass', get_string('auth_dbfieldpass_key', 'auth_db'),
88 get_string('auth_dbfieldpass', 'auth_db'), '', PARAM_RAW_TRIMMED));
91 // DB Password Type.
92 $passtype = array();
93 $passtype["plaintext"] = get_string("plaintext", "auth");
94 $passtype["md5"] = get_string("md5", "auth");
95 $passtype["sha1"] = get_string("sha1", "auth");
96 $passtype["saltedcrypt"] = get_string("auth_dbsaltedcrypt", "auth_db");
97 $passtype["internal"] = get_string("internal", "auth");
99 $settings->add(new admin_setting_configselect('auth_db/passtype',
100 new lang_string('auth_dbpasstype_key', 'auth_db'), new lang_string('auth_dbpasstype', 'auth_db'), 'plaintext', $passtype));
102 // Encoding.
103 $settings->add(new admin_setting_configtext('auth_db/extencoding', get_string('auth_dbextencoding', 'auth_db'),
104 get_string('auth_dbextencodinghelp', 'auth_db'), 'utf-8', PARAM_RAW_TRIMMED));
106 // DB SQL SETUP.
107 $settings->add(new admin_setting_configtext('auth_db/setupsql', get_string('auth_dbsetupsql', 'auth_db'),
108 get_string('auth_dbsetupsqlhelp', 'auth_db'), '', PARAM_RAW_TRIMMED));
110 // Debug ADOOB.
111 $settings->add(new admin_setting_configselect('auth_db/debugauthdb',
112 new lang_string('auth_dbdebugauthdb', 'auth_db'), new lang_string('auth_dbdebugauthdbhelp', 'auth_db'), 0, $yesno));
114 // Password change URL.
115 $settings->add(new auth_db_admin_setting_special_auth_configtext('auth_db/changepasswordurl',
116 get_string('auth_dbchangepasswordurl_key', 'auth_db'),
117 get_string('changepasswordhelp', 'auth'), '', PARAM_URL));
119 // Label and Sync Options.
120 $settings->add(new admin_setting_heading('auth_db/usersync', new lang_string('auth_sync_script', 'auth'), ''));
122 // Sync Options.
123 $deleteopt = array();
124 $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep', 'auth');
125 $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend', 'auth');
126 $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete', 'auth');
128 $settings->add(new admin_setting_configselect('auth_db/removeuser',
129 new lang_string('auth_remove_user_key', 'auth'),
130 new lang_string('auth_remove_user', 'auth'), AUTH_REMOVEUSER_KEEP, $deleteopt));
132 // Update users.
133 $settings->add(new admin_setting_configselect('auth_db/updateusers',
134 new lang_string('auth_dbupdateusers', 'auth_db'),
135 new lang_string('auth_dbupdateusers_description', 'auth_db'), 0, $yesno));
137 // Display locking / mapping of profile fields.
138 $authplugin = get_auth_plugin('db');
139 display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields,
140 get_string('auth_dbextrafields', 'auth_db'),
141 true, true, $authplugin->get_custom_user_profile_fields());