-
Notifications
You must be signed in to change notification settings - Fork 5
/
confirm_ai_usage.php
85 lines (68 loc) · 2.98 KB
/
confirm_ai_usage.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
<?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/>.
/**
* Configuration page for tenants.
*
* @package local_ai_manager
* @copyright 2024 ISB Bayern
* @author Philipp Memmel
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_login();
global $CFG, $DB, $OUTPUT, $PAGE, $USER;
$PAGE->add_body_class('limitcontentwidth');
$confirm = optional_param('confirm', -1, PARAM_INT);
$url = new moodle_url('/local/ai_manager/confirm_ai_usage.php');
$tenant = \core\di::get(\local_ai_manager\local\tenant::class);
$accessmanager = \core\di::get(\local_ai_manager\local\access_manager::class);
$accessmanager->require_tenant_member();
$PAGE->set_url($url);
$PAGE->set_context($tenant->get_context());
$PAGE->set_pagelayout('admin');
$strtitle = get_string('confirmaitoolsusage_heading', 'local_ai_manager');
$PAGE->set_title($strtitle);
$PAGE->set_heading($strtitle);
$PAGE->navbar->add($strtitle);
$PAGE->set_secondary_navigation(false);
/** @var \local_ai_manager\local\config_manager $configmanager */
$configmanager = \core\di::get(\local_ai_manager\local\config_manager::class);
$userinfo = new \local_ai_manager\local\userinfo($USER->id);
if ($confirm !== -1) {
$userinfo->set_confirmed(!empty($confirm));
$userinfo->store();
redirect($PAGE->url);
}
echo $OUTPUT->header();
$templatecontext = [
'checked' => $userinfo->is_confirmed(),
'description' => $userinfo->is_confirmed() ? get_string('revokeconfirmation', 'local_ai_manager') :
get_string('confirm', 'local_ai_manager'),
'text' => $userinfo->is_confirmed() ? get_string('confirmed', 'local_ai_manager') :
get_string('notconfirmed', 'local_ai_manager'),
'targetwhenchecked' => (new moodle_url('/local/ai_manager/confirm_ai_usage.php',
['confirm' => 0]))->out(false),
'targetwhennotchecked' => (new moodle_url('/local/ai_manager/confirm_ai_usage.php',
['confirm' => 1]))->out(false),
];
$termsofuse = get_config('local_ai_manager', 'termsofuse') ?: '';
$showtermsofuse = !empty($termsofuse);
$templatecontext['showtermsofuse'] = $showtermsofuse;
if ($showtermsofuse) {
$templatecontext['termsofuse'] = $termsofuse;
}
echo $OUTPUT->render_from_template('local_ai_manager/confirm_ai_usage', $templatecontext);
echo $OUTPUT->footer();