Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tools.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00030 require_once(dirname(__FILE__) . '/../config.php');
00031 require_once($CFG->libdir.'/adminlib.php');
00032 require_once($CFG->libdir.'/tablelib.php');
00033 
00034 admin_externalpage_setup('managetools');
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('tools', 'admin'));
00044 
00045     if (!$confirm) {
00046         if (get_string_manager()->string_exists('pluginname', 'tool_' . $delete)) {
00047             $strpluginname = get_string('pluginname', 'tool_' . $delete);
00048         } else {
00049             $strpluginname = $delete;
00050         }
00051         echo $OUTPUT->confirm(get_string('toolsdeleteconfirm', 'admin', $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('tool', $delete);
00059         $a = new stdclass();
00060         $a->name = $delete;
00061         $pluginlocation = get_plugin_types();
00062         $a->directory = $pluginlocation['tool'] . '/' . $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('tools', 'admin'));
00072 
00074 
00075 $table = new flexible_table('toolplugins_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', 'toolplugins');
00080 $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
00081 $table->setup();
00082 
00083 $plugins = array();
00084 foreach (get_plugin_list('tool') as $plugin => $plugindir) {
00085     if (get_string_manager()->string_exists('pluginname', 'tool_' . $plugin)) {
00086         $strpluginname = get_string('pluginname', 'tool_' . $plugin);
00087     } else {
00088         $strpluginname = $plugin;
00089     }
00090     $plugins[$plugin] = $strpluginname;
00091 }
00092 collatorlib::asort($plugins);
00093 
00094 $like = $DB->sql_like('plugin', '?', true, true, false, '|');
00095 $params = array('tool|_%');
00096 $installed = $DB->get_records_select('config_plugins', "$like AND name = 'version'", $params);
00097 $versions = array();
00098 foreach ($installed as $config) {
00099     $name = preg_replace('/^tool_/', '', $config->plugin);
00100     $versions[$name] = $config->value;
00101     if (!isset($plugins[$name])) {
00102         $plugins[$name] = $name;
00103     }
00104 }
00105 
00106 foreach ($plugins as $plugin => $name) {
00107     $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
00108     $delete = html_writer::link($delete, get_string('delete'));
00109 
00110     if (!isset($versions[$plugin])) {
00111         if (file_exists("$CFG->dirroot/$CFG->admin/tool/$plugin/version.php")) {
00112             // not installed yet
00113             $version = '?';
00114         } else {
00115             // no version info available
00116             $version = '-';
00117         }
00118     } else {
00119         $version = $versions[$plugin];
00120         if (file_exists("$CFG->dirroot/$CFG->admin/tool/$plugin")) {
00121             $version = $versions[$plugin];
00122         } else {
00123             // somebody removed plugin without uninstall
00124             $name = '<span class="notifyproblem">'.$name.' ('.get_string('missingfromdisk').')</span>';
00125             $version = $versions[$plugin];
00126         }
00127     }
00128 
00129     $table->add_data(array($name, $version, $delete));
00130 }
00131 
00132 $table->print_html();
00133 
00134 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations