forked from elearningstudio/moodle-report_filetrash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (70 loc) · 2.79 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
<?php
// This file is part of the File Trash report by Barry Oosthuizen - http://elearningstudio.co.uk
//
// 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/>.
/**
* Displays live view of recent logs
*
* This file generates live view of recent logs.
*
* @package report_filetrash
* @copyright 2013 Barry Oosthuizen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/report/filetrash/form.php');
$confirmdelete = optional_param('confirmdelete', null, PARAM_TEXT);
admin_externalpage_setup('report_filetrash', '', null, '', array('pagelayout'=>'report'));
$context = context_system::instance();
$PAGE->set_context($context);
require_login(null, false);
require_capability('report/filetrash:view', $context);
raise_memory_limit(MEMORY_HUGE);
if ($confirmdelete) {
$deleteurl = new moodle_url('/report/filetrash/delete.php', array('confirmdelete' => $confirmdelete));
redirect($deleteurl);
}
$filetrash = get_string('pluginname', 'report_filetrash');
$url = new moodle_url('/report/filetrash/index.php');
$PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$PAGE->set_title($filetrash);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'report_filetrash'));
$report = new report_filetrash_compare();
$customdata = array('orphanedfiles' => $report->orphanedfiles);
$form = new report_filetrash_form(null, $customdata);
if ($form->is_submitted()) {
$data = $form->get_data();
$cache = $form->store_options($data, $report->orphanedfiles);
$filestodelete = unserialize($cache->filestodelete);
$confirmurl = new moodle_url('/report/filetrash/index.php', array(
'confirmdelete' => true,
'cacheid' => $cache->id));
echo html_writer::tag('p', get_string('confirm_delete', 'report_filetrash'));
$i = 0;
foreach ($filestodelete as $key => $file) {
if ($file == '/') {
continue;
}
$i++;
echo html_writer::tag('p', $i . '. ' . $file);
}
echo html_writer::link($confirmurl, get_string('delete'));
} else {
$form->display();
$PAGE->requires->js_init_call('M.report_filetrash.init');
}
echo $OUTPUT->footer();