diff --git a/filter/upgrade.txt b/filter/upgrade.txt index 6b9370b2f1e..2570898291a 100644 --- a/filter/upgrade.txt +++ b/filter/upgrade.txt @@ -3,6 +3,10 @@ information provided here is intended especially for developers. === 3.0 === + +* New admin setting class admin_setting_filter_types which can be used if you + want to make the disablefilters value in your code configurable. + * Methods filter_manager::text_filtering_hash and moodle_text_filter::hash have been deprecated. There were use by the old Moodle filtered text caching system that was removed several releases ago. diff --git a/lib/adminlib.php b/lib/adminlib.php index ef27f56716e..e9360f0d0da 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4724,6 +4724,50 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox { } +/** + * Admin setting that is a list of installed filter plugins. + * + * @copyright 2015 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class admin_setting_pickfilters extends admin_setting_configmulticheckbox { + + /** + * Constructor + * + * @param string $name unique ascii name, either 'mysetting' for settings + * that in config, or 'myplugin/mysetting' for ones in config_plugins. + * @param string $visiblename localised name + * @param string $description localised long description + * @param array $default the default. E.g. array('urltolink' => 1, 'emoticons' => 1) + */ + public function __construct($name, $visiblename, $description, $default) { + if (empty($default)) { + $default = array(); + } + $this->load_choices(); + foreach ($default as $plugin) { + if (!isset($this->choices[$plugin])) { + unset($default[$plugin]); + } + } + parent::__construct($name, $visiblename, $description, $default, null); + } + + public function load_choices() { + if (is_array($this->choices)) { + return true; + } + $this->choices = array(); + + foreach (core_component::get_plugin_list('filter') as $plugin => $unused) { + $this->choices[$plugin] = filter_get_name($plugin); + } + return true; + } +} + + /** * Text field with an advanced checkbox, that controls a additional $name.'_adv' setting. *