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 * Assign submission subplugin info class. 19 * 20 * @package mod_assign 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 mod_assign\plugininfo; 25 26 use core\plugininfo\base, core_plugin_manager, moodle_url; 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 31 class assignsubmission extends base { 32 /** 33 * Finds all enabled plugins, the result may include missing plugins. 34 * @return array|null of enabled plugins $pluginname=>$pluginname, null means unknown 35 */ 36 public static function get_enabled_plugins() { 37 global $DB; 38 39 $plugins = core_plugin_manager::instance()->get_installed_plugins('assignsubmission'); 40 if (!$plugins) { 41 return array(); 42 } 43 $installed = array(); 44 foreach ($plugins as $plugin => $version) { 45 $installed[] = 'assignsubmission_'.$plugin; 46 } 47 48 list($installed, $params) = $DB->get_in_or_equal($installed, SQL_PARAMS_NAMED); 49 $disabled = $DB->get_records_select('config_plugins', "plugin $installed AND name = 'disabled'", $params, 'plugin ASC'); 50 foreach ($disabled as $conf) { 51 if (empty($conf->value)) { 52 continue; 53 } 54 list($type, $name) = explode('_', $conf->plugin, 2); 55 unset($plugins[$name]); 56 } 57 58 $enabled = array(); 59 foreach ($plugins as $plugin => $version) { 60 $enabled[$plugin] = $plugin; 61 } 62 63 return $enabled; 64 } 65 66 public static function enable_plugin(string $pluginname, int $enabled): bool { 67 $haschanged = false; 68 69 $plugin = 'assignsubmission_' . $pluginname; 70 $oldvalue = get_config($plugin, 'disabled'); 71 $disabled = !$enabled; 72 // Only set value if there is no config setting or if the value is different from the previous one. 73 if ($oldvalue === false || ((bool) $oldvalue != $disabled)) { 74 set_config('disabled', $disabled, $plugin); 75 $haschanged = true; 76 77 add_to_config_log('disabled', $oldvalue, $disabled, $plugin); 78 \core_plugin_manager::reset_caches(); 79 } 80 81 return $haschanged; 82 } 83 84 public function is_uninstall_allowed() { 85 return true; 86 } 87 88 /** 89 * Return URL used for management of plugins of this type. 90 * @return moodle_url 91 */ 92 public static function get_manage_url() { 93 return new moodle_url('/mod/assign/adminmanageplugins.php', array('subtype'=>'assignsubmission')); 94 } 95 96 /** 97 * Pre-uninstall hook. 98 * @private 99 */ 100 public function uninstall_cleanup() { 101 global $DB; 102 103 $DB->delete_records('assign_plugin_config', array('plugin'=>$this->name, 'subtype'=>'assignsubmission')); 104 105 parent::uninstall_cleanup(); 106 } 107 108 public function get_settings_section_name() { 109 return $this->type . '_' . $this->name; 110 } 111 112 /** 113 * Loads plugin settings to the settings tree 114 * 115 * This function usually includes settings.php file in plugins folder. 116 * Alternatively it can create a link to some settings page (instance of admin_externalpage) 117 * 118 * @param \part_of_admin_tree $adminroot 119 * @param string $parentnodename 120 * @param bool $hassiteconfig whether the current user has moodle/site:config capability 121 */ 122 public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { 123 global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them. 124 $ADMIN = $adminroot; // May be used in settings.php. 125 $plugininfo = $this; // Also can be used inside settings.php. 126 127 if (!$this->is_installed_and_upgraded()) { 128 return; 129 } 130 131 if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) { 132 return; 133 } 134 135 $section = $this->get_settings_section_name(); 136 137 $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); 138 139 if ($adminroot->fulltree) { 140 $shortsubtype = substr($this->type, strlen('assign')); 141 include($this->full_path('settings.php')); 142 } 143 144 $adminroot->add($this->type . 'plugins', $settings); 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body