diff --git a/filter/censor/README.txt b/filter/censor/README.txt deleted file mode 100644 index cc1ee810c665e..0000000000000 --- a/filter/censor/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -////////////////////////// -// // -// Censorship Filter // -// // -////////////////////////// - -This is a very simple Text Filter that searches text -being output to the screen, replacing "bad" words -with other words. - -To customise the word list, use the censor settings page -in the filters administration page. - -If no customised list has been provided, a default list -specified in the current language pack will be used. Note that -the custom list is an alternative to the default list not -an addition to it. diff --git a/filter/censor/classes/privacy/provider.php b/filter/censor/classes/privacy/provider.php deleted file mode 100644 index c7d386bf4fbf1..0000000000000 --- a/filter/censor/classes/privacy/provider.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -/** - * Privacy Subsystem implementation for filter_censor. - * - * @package filter_censor - * @copyright 2018 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace filter_censor\privacy; - -defined('MOODLE_INTERNAL') || die(); - -/** - * Privacy Subsystem for filter_censor implementing null_provider. - * - * @copyright 2018 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class provider implements \core_privacy\local\metadata\null_provider { - - /** - * Get the language string identifier with the component's language - * file to explain why this plugin stores no data. - * - * @return string - */ - public static function get_reason() : string { - return 'privacy:metadata'; - } -} diff --git a/filter/censor/filter.php b/filter/censor/filter.php deleted file mode 100644 index 67d695ed8a75c..0000000000000 --- a/filter/censor/filter.php +++ /dev/null @@ -1,86 +0,0 @@ -. - -/** - * Censorship filtering - * - * This very simple example of a Text Filter will parse - * printed text, blacking out words perceived to be bad - * - * @package filter - * @subpackage censor - * @copyright 2004 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -////////////////////////////////////////////////////////////// -// Censorship filtering -// -// This very simple example of a Text Filter will parse -// printed text, blacking out words perceived to be bad -// -// The list of words is in the lang/xx/moodle.php -// -////////////////////////////////////////////////////////////// - -class filter_censor extends moodle_text_filter { - private function _canseecensor() { - return is_siteadmin(); //TODO: add proper access control - } - - function hash(){ - $cap = "mod/filter:censor"; - if (is_siteadmin()) { //TODO: add proper access control - $cap = "mod/filter:seecensor"; - } - return $cap; - } - - function filter($text, array $options = array()){ - static $words; - global $CFG; - - if (!isset($CFG->filter_censor_badwords)) { - set_config( 'filter_censor_badwords','' ); - } - - if (empty($words)) { - $words = array(); - if (empty($CFG->filter_censor_badwords)) { - $badwords = explode(',',get_string('badwords', 'filter_censor')); - } - else { - $badwords = explode(',', $CFG->filter_censor_badwords); - } - foreach ($badwords as $badword) { - $badword = trim($badword); - if($this->_canseecensor()){ - $words[] = new filterobject($badword, '', '', - false, false, $badword); - } else { - $words[] = new filterobject($badword, '', - '', false, false, str_pad('',strlen($badword),'*')); - } - } - } - return filter_phrases($text, $words); - } -} - - diff --git a/filter/censor/lang/en/filter_censor.php b/filter/censor/lang/en/filter_censor.php deleted file mode 100644 index 1a4cc6e951ce1..0000000000000 --- a/filter/censor/lang/en/filter_censor.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * Strings for component 'filter_censor', language 'en', branch 'MOODLE_20_STABLE' - * - * @package filter_censor - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['badwords'] = 'shit,fucked,fucker,fuck,dickhead,dick,cockhead,cock,cunt,asshole,arsehole,prick,bitch,jism,whore,slut,wanker,wank,bastard,dildo,masturbate,orgasm,penis,nigger,pussy,vagina'; -$string['filtername'] = 'Word censorship'; -$string['privacy:metadata'] = 'The Word censorship plugin does not store any personal data.'; diff --git a/filter/censor/settings.php b/filter/censor/settings.php deleted file mode 100644 index 323d1ef142672..0000000000000 --- a/filter/censor/settings.php +++ /dev/null @@ -1,9 +0,0 @@ -fulltree) { - - $settings->add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'), - get_string('badwordsconfig', 'admin').'
'.get_string('badwordsdefault', 'admin'), '')); -} diff --git a/filter/censor/version.php b/filter/censor/version.php deleted file mode 100644 index 0d2fe422e2129..0000000000000 --- a/filter/censor/version.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/** - * Version details - * - * @package filter - * @subpackage censor - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2021052500; // Requires this Moodle version. -$plugin->component = 'filter_censor'; // Full name of the plugin (used for diagnostics) diff --git a/filter/upgrade.txt b/filter/upgrade.txt index dfccf3f5f4e92..4f28d94b3ef4e 100644 --- a/filter/upgrade.txt +++ b/filter/upgrade.txt @@ -1,6 +1,11 @@ This file describes API changes in core filter API and plugins, information provided here is intended especially for developers. +=== 4.0 === + +* The Word censorship (filter_censor) filter has been completely removed from core. It has been moved to the plugins database +repository, so it can still be installed as a third-party plugin. + === 3.9 === * The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 9a4c7a746024b..cf61945a6efd2 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1725,8 +1725,9 @@ public static function is_deleted_standard_plugin($type, $name) { 'block' => array('course_overview', 'messages', 'community', 'participants'), 'cachestore' => array('memcache'), 'enrol' => array('authorize'), - 'portfolio' => array('picasa'), + 'filter' => array('censor'), 'media' => array('swf'), + 'portfolio' => array('picasa'), 'qformat' => array('webct'), 'message' => array('jabber'), 'quizaccess' => array('safebrowser'), @@ -1861,7 +1862,7 @@ public static function standard_plugins_list($type) { ), 'filter' => array( - 'activitynames', 'algebra', 'censor', 'emailprotect', + 'activitynames', 'algebra', 'emailprotect', 'emoticon', 'displayh5p', 'mathjaxloader', 'mediaplugin', 'multilang', 'tex', 'tidy', 'urltolink', 'data', 'glossary' ), diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f6919eb54d526..316892110bf30 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2862,5 +2862,15 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2021092400.03); } + if ($oldversion < 2021100300.01) { + // Remove filter_censor (unless it has manually been added back). + if (!file_exists($CFG->dirroot . '/filter/censor/filter.php')) { + unset_all_config_for_plugin('filter_censor'); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2021100300.01); + } + return true; } diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index 864981aab6d39..bed77bb205344 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -76,9 +76,9 @@ public function test_format_string_static_caching_with_filters() { $generator = $this->getDataGenerator(); $course = $generator->create_course(); $user = $generator->create_user(); - $rawstring = 'Shortname link curseword'; - $expectednofilter = strip_links($rawstring); - $expectedfilter = 'Shortname link \*\**'; + $rawstring = 'EnglishCatalan'; + $expectednofilter = strip_tags($rawstring); + $expectedfilter = 'English'; $striplinks = true; $context = context_course::instance($course->id); $options = [ @@ -94,22 +94,21 @@ public function test_format_string_static_caching_with_filters() { $nofilterresult = format_string($rawstring, $striplinks, $options); $this->assertEquals($expectednofilter, $nofilterresult); - // Add the censor filter. Make sure it's enabled globally. + // Add the multilang filter. Make sure it's enabled globally. $CFG->filterall = true; - $CFG->stringfilters = 'censor'; - $CFG->filter_censor_badwords = 'curseword'; - filter_set_global_state('censor', TEXTFILTER_ON); - filter_set_local_state('censor', $context->id, TEXTFILTER_ON); + $CFG->stringfilters = 'multilang'; + filter_set_global_state('multilang', TEXTFILTER_ON); + filter_set_local_state('multilang', $context->id, TEXTFILTER_ON); // This time we want to apply the filters. $options['filter'] = true; $filterresult = format_string($rawstring, $striplinks, $options); $this->assertMatchesRegularExpression("/$expectedfilter/", $filterresult); - filter_set_local_state('censor', $context->id, TEXTFILTER_OFF); + filter_set_local_state('multilang', $context->id, TEXTFILTER_OFF); // Confirm that we get back the cached string. The result should be // the same as the filtered text above even though we've disabled the - // censor filter in between. + // multilang filter in between. $cachedresult = format_string($rawstring, $striplinks, $options); $this->assertMatchesRegularExpression("/$expectedfilter/", $cachedresult); } diff --git a/version.php b/version.php index e59cc0b730b8b..6b98bb9c1afe0 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2021100300.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2021100300.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.0dev (Build: 20211003)'; // Human-friendly version name