2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Provides an overview of installed plagiarism plugins
20 * Displays the list of found plagiarism plugins, their version (if found) and
21 * a link to delete the plagiarism plugin.
23 * @see http://docs.moodle.org/dev/Plagiarism_API
25 * @copyright 2012 Dan Marsden <dan@danmarsden.com>
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 require_once(dirname(dirname(__FILE__
)) . '/config.php');
30 require_once($CFG->libdir
.'/adminlib.php');
31 require_once($CFG->libdir
.'/tablelib.php');
33 admin_externalpage_setup('manageplagiarismplugins');
35 $delete = optional_param('delete', '', PARAM_PLUGIN
);
36 $confirm = optional_param('confirm', false, PARAM_BOOL
);
38 if (!empty($delete) and confirm_sesskey()) { // If data submitted, then process and store.
39 echo $OUTPUT->header();
40 echo $OUTPUT->heading(get_string('manageplagiarism', 'plagiarism'));
43 if (get_string_manager()->string_exists('pluginname', 'plagiarism_' . $delete)) {
44 $strpluginname = get_string('pluginname', 'plagiarism_' . $delete);
46 $strpluginname = $delete;
48 echo $OUTPUT->confirm(get_string('plagiarismplugindeleteconfirm', 'plagiarism', $strpluginname),
49 new moodle_url($PAGE->url
, array('delete' => $delete, 'confirm' => 1)),
51 echo $OUTPUT->footer();
55 uninstall_plugin('plagiarism', $delete);
58 $pluginlocation = get_plugin_types();
59 $a->directory
= $pluginlocation['plagiarism'] . '/' . $delete;
60 echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
61 echo $OUTPUT->continue_button($PAGE->url
);
62 echo $OUTPUT->footer();
67 echo $OUTPUT->header();
69 // Print the table of all installed plagiarism plugins.
71 $txt = get_strings(array('settings', 'name', 'version', 'delete'));
73 $plagiarismplugins = get_plugin_list('plagiarism');
74 if (empty($plagiarismplugins)) {
75 echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
76 echo $OUTPUT->footer();
80 echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
81 echo $OUTPUT->box_start('generalbox authsui');
83 $table = new html_table();
84 $table->head
= array($txt->name
, $txt->version
, $txt->delete
, $txt->settings
);
85 $table->colclasses
= array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
86 $table->data
= array();
87 $table->attributes
['class'] = 'manageplagiarismtable generaltable';
89 // Iterate through auth plugins and add to the display table.
90 $authcount = count($plagiarismplugins);
91 foreach ($plagiarismplugins as $plugin => $dir) {
92 if (file_exists($dir.'/settings.php')) {
93 $displayname = "<span>".get_string($plugin, 'plagiarism_'.$plugin)."</span>";
95 $url = new moodle_url("/plagiarism/$plugin/settings.php");
96 $settings = html_writer
::link($url, $txt->settings
);
98 $version = get_config('plagiarism_' . $plugin);
99 if (!empty($version->version
)) {
100 $version = $version->version
;
105 $delete = new moodle_url($PAGE->url
, array('delete' => $plugin, 'sesskey' => sesskey()));
106 $delete = html_writer
::link($delete, get_string('delete'));
107 $table->data
[] = array($displayname, $version, $delete, $settings);
110 echo html_writer
::table($table);
111 echo get_string('configplagiarismplugins', 'plagiarism');
112 echo $OUTPUT->box_end();
114 echo $OUTPUT->footer();