Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/localplugins.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00030 require_once(dirname(dirname(__FILE__)) . '/config.php');
00031 require_once($CFG->libdir.'/adminlib.php');
00032 require_once($CFG->libdir.'/tablelib.php');
00033 
00034 admin_externalpage_setup('managelocalplugins');
00035 
00036 $delete  = optional_param('delete', '', PARAM_PLUGIN);
00037 $confirm = optional_param('confirm', '', PARAM_BOOL);
00038 
00040 
00041 if (!empty($delete) and confirm_sesskey()) {
00042     echo $OUTPUT->header();
00043     echo $OUTPUT->heading(get_string('localplugins'));
00044 
00045     if (!$confirm) {
00046         if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) {
00047             $strpluginname = get_string('pluginname', 'local_' . $delete);
00048         } else {
00049             $strpluginname = $delete;
00050         }
00051         echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname),
00052                                 new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
00053                                 $PAGE->url);
00054         echo $OUTPUT->footer();
00055         die();
00056 
00057     } else {
00058         uninstall_plugin('local', $delete);
00059         $a = new stdclass();
00060         $a->name = $delete;
00061         $pluginlocation = get_plugin_types();
00062         $a->directory = $pluginlocation['local'] . '/' . $delete;
00063         echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
00064         echo $OUTPUT->continue_button($PAGE->url);
00065         echo $OUTPUT->footer();
00066         die();
00067     }
00068 }
00069 
00070 echo $OUTPUT->header();
00071 echo $OUTPUT->heading(get_string('localplugins'));
00072 
00074 
00075 $table = new flexible_table('localplugins_administration_table');
00076 $table->define_columns(array('name', 'version', 'delete'));
00077 $table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
00078 $table->define_baseurl($PAGE->url);
00079 $table->set_attribute('id', 'localplugins');
00080 $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
00081 $table->setup();
00082 
00083 $plugins = array();
00084 foreach (get_plugin_list('local') as $plugin => $plugindir) {
00085     if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
00086         $strpluginname = get_string('pluginname', 'local_' . $plugin);
00087     } else {
00088         $strpluginname = $plugin;
00089     }
00090     $plugins[$plugin] = $strpluginname;
00091 }
00092 collatorlib::asort($plugins);
00093 
00094 foreach ($plugins as $plugin => $name) {
00095     $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
00096     $delete = html_writer::link($delete, get_string('delete'));
00097 
00098     $version = get_config('local_' . $plugin);
00099     if (!empty($version->version)) {
00100         $version = $version->version;
00101     } else {
00102         $version = '?';
00103     }
00104 
00105     $table->add_data(array($name, $version, $delete));
00106 }
00107 
00108 $table->print_html();
00109 
00110 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations