Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 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. 8 // 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. 13 // 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/>. 16 17 /** 18 * Provides an overview of installed availability conditions. 19 * 20 * You can also enable/disable them from this screen. 21 * 22 * @package tool_availabilityconditions 23 * @copyright 2014 The Open University 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 require_once(__DIR__ . '/../../../config.php'); 28 require_once($CFG->libdir . '/adminlib.php'); 29 require_once($CFG->libdir . '/tablelib.php'); 30 31 admin_externalpage_setup('manageavailability'); 32 33 // Get sorted list of all availability condition plugins. 34 $plugins = array(); 35 foreach (core_component::get_plugin_list('availability') as $plugin => $plugindir) { 36 if (get_string_manager()->string_exists('pluginname', 'availability_' . $plugin)) { 37 $strpluginname = get_string('pluginname', 'availability_' . $plugin); 38 } else { 39 $strpluginname = $plugin; 40 } 41 $plugins[$plugin] = $strpluginname; 42 } 43 core_collator::asort($plugins); 44 45 // Do plugin actions. 46 $pageurl = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/'); 47 if (($plugin = optional_param('plugin', '', PARAM_PLUGIN))) { 48 require_sesskey(); 49 if (!array_key_exists($plugin, $plugins)) { 50 print_error('invalidcomponent', 'error', $pageurl); 51 } 52 $action = required_param('action', PARAM_ALPHA); 53 switch ($action) { 54 case 'hide' : 55 set_config('disabled', 1, 'availability_' . $plugin); 56 break; 57 case 'show' : 58 unset_config('disabled', 'availability_' . $plugin); 59 break; 60 } 61 core_plugin_manager::reset_caches(); 62 63 // Always redirect back after an action. 64 redirect($pageurl); 65 } 66 67 echo $OUTPUT->header(); 68 echo $OUTPUT->heading(get_string('manageplugins', 'availability')); 69 70 // Show a table of installed availability conditions. 71 $table = new flexible_table('availabilityconditions_administration_table'); 72 $table->define_columns(array('name', 'version', 'enable')); 73 $table->define_headers(array(get_string('plugin'), 74 get_string('version'), get_string('hide') . '/' . get_string('show'))); 75 $table->define_baseurl($PAGE->url); 76 $table->set_attribute('id', 'availabilityconditions'); 77 $table->set_attribute('class', 'admintable generaltable'); 78 $table->setup(); 79 80 $enabledlist = core\plugininfo\availability::get_enabled_plugins(); 81 foreach ($plugins as $plugin => $name) { 82 83 // Get version or ? if unknown. 84 $version = get_config('availability_' . $plugin); 85 if (!empty($version->version)) { 86 $version = $version->version; 87 } else { 88 $version = '?'; 89 } 90 91 // Get enabled status and use to grey out name if necessary. 92 $enabled = in_array($plugin, $enabledlist); 93 if ($enabled) { 94 $enabledaction = 'hide'; 95 $enabledstr = get_string('hide'); 96 $class = ''; 97 } else { 98 $enabledaction = 'show'; 99 $enabledstr = get_string('show'); 100 $class = 'dimmed_text'; 101 } 102 $namespan = html_writer::span($name, $class); 103 104 // Make enable control. This is a POST request (using a form control rather 105 // than just a link) because it makes a database change. 106 $params = array('sesskey' => sesskey(), 'plugin' => $plugin, 'action' => $enabledaction); 107 $url = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/', $params); 108 $enablecontrol = html_writer::link($url, $OUTPUT->pix_icon('t/' . $enabledaction, $enabledstr)); 109 110 $table->add_data(array($namespan, $version, $enablecontrol)); 111 } 112 113 $table->print_html(); 114 115 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body