forked from moodlehq/moodle-local_anonymise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
106 lines (86 loc) · 3.58 KB
/
index.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
100
101
102
103
104
105
106
<?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/>.
/**
* Anonymise personal identifiers
*
* @package local_anonymise
* @copyright 2016 Gavin Henrick
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/local/anonymise/locallib.php');
$anonymise = optional_param('action', false, PARAM_BOOL);
// Allow more time for long query runs.
set_time_limit(0);
// Start page output.
admin_externalpage_setup('local_anonymise');
$PAGE->set_url($CFG->wwwroot . '/local/anonymise/index.php');
$title = get_string('pluginname', 'local_anonymise');
$PAGE->set_title($title);
$PAGE->set_heading($title);
echo $OUTPUT->header();
if ($anonymise) {
require_sesskey();
// Exectute anonmisation based on form selections.
$activities = optional_param('activities', false, PARAM_BOOL);
$categories = optional_param('categories', false, PARAM_BOOL);
$courses = optional_param('courses', false, PARAM_BOOL);
$files = optional_param('files', false, PARAM_BOOL);
$users = optional_param('users', false, PARAM_BOOL);
$password = optional_param('password', false, PARAM_BOOL);
$admin = optional_param('admin', false, PARAM_BOOL);
$site = optional_param('site', false, PARAM_BOOL);
$others = optional_param('others', false, PARAM_BOOL);
if ($activities) {
echo $OUTPUT->heading(get_string('activities', 'local_anonymise'), 3);
anonymise_activities();
}
if ($categories) {
echo $OUTPUT->heading(get_string('categories', 'local_anonymise'), 3);
anonymise_categories();
}
if ($courses) {
echo $OUTPUT->heading(get_string('courses', 'local_anonymise'), 3);
anonymise_courses($site);
}
if ($files) {
echo $OUTPUT->heading(get_string('files', 'local_anonymise'), 3);
anonymise_files();
}
if ($users) {
echo $OUTPUT->heading(get_string('users', 'local_anonymise'), 3);
anonymise_users($password, $admin);
}
if ($others) {
echo $OUTPUT->heading(get_string('others', 'local_anonymise'), 3);
anonymise_others();
}
echo html_writer::tag('p', get_string('done', 'local_anonymise'), array('style' => 'margin-top: 20px;'));
$purgeprompt = get_string('purgeprompt', 'local_anonymise');
$purgeprompt .= ' ';
$params = array('sesskey' => sesskey(), 'confirm' => '1', 'returnurl' => '/');
$url = new moodle_url('/admin/purgecaches.php', $params);
$purgeprompt .= html_writer::link($url, get_string('purgelink', 'local_anonymise'));
$purgeprompt .= '.';
echo html_writer::tag('p', $purgeprompt, array('style' => 'margin-top: 20px;'));
} else {
// Display the form.
echo $OUTPUT->notification(get_string('warning', 'local_anonymise'));
$mform = new local_anonymise_form(new moodle_url('/local/anonymise/'));
$mform->display();
}
echo $OUTPUT->footer();