See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 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 * Subplugin info class. 19 * 20 * @package tool_log 21 * @copyright 2013 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_log\plugininfo; 25 26 use core\plugininfo\base, moodle_url, part_of_admin_tree, admin_settingpage; 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 /** 31 * Plugin info class for logging store plugins. 32 */ 33 class logstore extends base { 34 35 public function is_enabled() { 36 $enabled = get_config('tool_log', 'enabled_stores'); 37 if (!$enabled) { 38 return false; 39 } 40 41 $enabled = array_flip(explode(',', $enabled)); 42 return isset($enabled['logstore_' . $this->name]); 43 } 44 45 public static function enable_plugin(string $pluginname, int $enabled): bool { 46 $haschanged = false; 47 $plugins = []; 48 $oldvalue = get_config('tool_log', 'enabled_stores'); 49 if (!empty($oldvalue)) { 50 $plugins = array_flip(explode(',', $oldvalue)); 51 } 52 // Only set visibility if it's different from the current value. 53 if ($enabled && !array_key_exists($pluginname, $plugins)) { 54 $plugins[$pluginname] = $pluginname; 55 $haschanged = true; 56 } else if (!$enabled && array_key_exists($pluginname, $plugins)) { 57 unset($plugins[$pluginname]); 58 $haschanged = true; 59 } 60 61 if ($haschanged) { 62 $new = implode(',', array_flip($plugins)); 63 add_to_config_log('tool_logstore_visibility', !$enabled, $enabled, $pluginname); 64 set_config('enabled_stores', $new, 'tool_log'); 65 // Reset caches. 66 \core_plugin_manager::reset_caches(); 67 } 68 69 return $haschanged; 70 } 71 72 public function get_settings_section_name() { 73 return 'logsetting' . $this->name; 74 } 75 76 public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { 77 global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them. 78 $ADMIN = $adminroot; // May be used in settings.php. 79 $section = $this->get_settings_section_name(); 80 81 if (!$this->is_installed_and_upgraded()) { 82 return; 83 } 84 85 if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) { 86 return; 87 } 88 89 $settings = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); 90 include($this->full_path('settings.php')); 91 92 if ($settings) { 93 $ADMIN->add($parentnodename, $settings); 94 } 95 } 96 97 public static function get_manage_url() { 98 return new moodle_url('/admin/settings.php', array('section' => 'managelogging')); 99 } 100 101 public function is_uninstall_allowed() { 102 return true; 103 } 104 105 public function uninstall_cleanup() { 106 $enabled = get_config('tool_log', 'enabled_stores'); 107 if ($enabled) { 108 $enabled = array_flip(explode(',', $enabled)); 109 unset($enabled['logstore_' . $this->name]); 110 $enabled = array_flip($enabled); 111 set_config('enabled_stores', implode(',', $enabled), 'tool_log'); 112 } 113 114 parent::uninstall_cleanup(); 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body