[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 * Lets users manage data formats 19 * 20 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 21 * @copyright 2016 Brendan Heywood (brendan@catalyst-au.net) 22 * @package core 23 * @subpackage dataformat 24 */ 25 26 require_once('../config.php'); 27 require_once($CFG->libdir.'/adminlib.php'); 28 29 $action = required_param('action', PARAM_ALPHANUMEXT); 30 $name = required_param('name', PARAM_PLUGIN); 31 32 $syscontext = context_system::instance(); 33 $PAGE->set_url('/admin/dataformats.php'); 34 $PAGE->set_context($syscontext); 35 36 require_login(); 37 require_capability('moodle/site:config', $syscontext); 38 require_sesskey(); 39 40 $return = new moodle_url('/admin/settings.php', array('section' => 'managedataformats')); 41 42 $plugins = core_plugin_manager::instance()->get_plugins_of_type('dataformat'); 43 $sortorder = array_flip(array_keys($plugins)); 44 45 if (!isset($plugins[$name])) { 46 print_error('courseformatnotfound', 'error', $return, $name); 47 } 48 49 switch ($action) { 50 case 'disable': 51 if ($plugins[$name]->is_enabled()) { 52 set_config('disabled', 1, 'dataformat_'. $name); 53 core_plugin_manager::reset_caches(); 54 } 55 break; 56 case 'enable': 57 if (!$plugins[$name]->is_enabled()) { 58 unset_config('disabled', 'dataformat_'. $name); 59 core_plugin_manager::reset_caches(); 60 } 61 break; 62 case 'up': 63 if ($sortorder[$name]) { 64 $currentindex = $sortorder[$name]; 65 $seq = array_keys($plugins); 66 $seq[$currentindex] = $seq[$currentindex - 1]; 67 $seq[$currentindex - 1] = $name; 68 set_config('dataformat_plugins_sortorder', implode(',', $seq)); 69 } 70 break; 71 case 'down': 72 if ($sortorder[$name] < count($sortorder) - 1) { 73 $currentindex = $sortorder[$name]; 74 $seq = array_keys($plugins); 75 $seq[$currentindex] = $seq[$currentindex + 1]; 76 $seq[$currentindex + 1] = $name; 77 set_config('dataformat_plugins_sortorder', implode(',', $seq)); 78 } 79 break; 80 } 81 redirect($return); 82
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |