-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
99 lines (85 loc) · 3.59 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Admin settings and defaults
*
* @package auth_magic
* @copyright 2022 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
// Enrolment duration.
$name = "auth_magic/enrolmentduration";
$title = get_string("defaultenrolmentduration", "auth_magic");
$desc = "";
$setting = new admin_setting_configduration($name, $title, $desc, 0);
$settings->add($setting);
// Enrollment role.
$options = get_default_enrol_roles(context_system::instance());
$student = get_archetype_roles('student');
$student = reset($student);
$name = "auth_magic/enrolmentrole";
$title = get_string("defaultenrolmentrole", "auth_magic");
$desc = "";
$setting = new admin_setting_configselect($name, $title, $desc, $student->id ?? null, $options);
$settings->add($setting);
// Magic login link expiry.
$name = "auth_magic/invitationexpiry";
$title = get_string("invitationexpiry", "auth_magic");
$desc = "";
$setting = new admin_setting_configduration($name, $title, $desc, 1 * WEEKSECS);
$settings->add($setting);
// Magic login link expiry.
$name = "auth_magic/loginexpiry";
$title = get_string("loginexpiry", "auth_magic");
$desc = "";
$setting = new admin_setting_configduration($name, $title, $desc, 4 * HOURSECS);
$settings->add($setting);
// Supported authentication method.
$options = [
0 => get_string('magiconly', 'auth_magic'),
1 => get_string('anymethod', 'auth_magic'),
];
$name = "auth_magic/authmethod";
$title = get_string("strsupportauth", "auth_magic");
$desc = "";
$setting = new admin_setting_configselect($name, $title, $desc, 0, $options);
$settings->add($setting);
// Owener account role.
$options = [];
$options[0] = get_string('none');
$usercontextroles = get_roles_for_contextlevels(CONTEXT_USER);
if ($usercontextroles) {
list($rolesql, $roleparams) = $DB->get_in_or_equal($usercontextroles);
$sql = "SELECT id, name FROM {role} WHERE id $rolesql";
$roles = $DB->get_records_sql($sql, $roleparams);
$options += array_column($roles, 'name', 'id');
}
$name = "auth_magic/owneraccountrole";
$title = get_string("strowneraccountrole", "auth_magic");
$desc = "";
$setting = new admin_setting_configselect($name, $title, $desc, 0, $options);
$settings->add($setting);
}
if (is_enabled_auth('magic')) {
$ADMIN->add('accounts', new admin_externalpage('auth_magic_quickregistration',
get_string('quickregistration', 'auth_magic'),
new moodle_url('/auth/magic/registration.php'), ['auth/magic:cansitequickregistration']));
$ADMIN->add('accounts', new admin_externalpage('auth_magic_loginlinks',
get_string('listofmagiclink', 'auth_magic'),
new moodle_url('/auth/magic/listusers.php')));
}