Commit 0662bd67 authored by Petr Škoda's avatar Petr Škoda
Browse files

MDL-29996 remove deprecated stuff from filter code

parent fba0abdc
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/adminlib.php');
$action = optional_param('action', '', PARAM_ALPHANUMEXT); $action = optional_param('action', '', PARAM_ALPHANUMEXT);
$filterpath = optional_param('filterpath', '', PARAM_PATH); $filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
require_login(); require_login();
$systemcontext = context_system::instance(); $systemcontext = context_system::instance();
...@@ -84,39 +84,22 @@ ...@@ -84,39 +84,22 @@
case 'down': case 'down':
if (isset($filters[$filterpath])) { if (isset($filters[$filterpath])) {
$oldpos = $filters[$filterpath]->sortorder; filter_set_global_state($filterpath, $filters[$filterpath]->active, 1);
if ($oldpos <= count($filters)) {
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
}
} }
break; break;
case 'up': case 'up':
if (isset($filters[$filterpath])) { if (isset($filters[$filterpath])) {
$oldpos = $filters[$filterpath]->sortorder; $oldpos = $filters[$filterpath]->sortorder;
if ($oldpos >= 1) { filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
}
} }
break; break;
case 'delete': case 'delete':
if (!empty($filternames[$filterpath])) {
$filtername = $filternames[$filterpath];
} else {
$filtername = $filterpath;
}
if (substr($filterpath, 0, 4) == 'mod/') {
$mod = basename($filterpath);
$a = new stdClass;
$a->filter = $filtername;
$a->module = get_string('modulename', $mod);
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
}
// If not yet confirmed, display a confirmation message. // If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) { if (!optional_param('confirm', '', PARAM_BOOL)) {
$filtername = filter_get_name($filterpath);
$title = get_string('deletefilterareyousure', 'admin', $filtername); $title = get_string('deletefilterareyousure', 'admin', $filtername);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($title); echo $OUTPUT->heading($title);
...@@ -129,7 +112,7 @@ ...@@ -129,7 +112,7 @@
} }
// Do the deletion. // Do the deletion.
$title = get_string('deletingfilter', 'admin', $filtername); $title = get_string('deletingfilter', 'admin', $filterpath);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($title); echo $OUTPUT->heading($title);
...@@ -137,8 +120,8 @@ ...@@ -137,8 +120,8 @@
filter_delete_all_for_filter($filterpath); filter_delete_all_for_filter($filterpath);
$a = new stdClass; $a = new stdClass;
$a->filter = $filtername; $a->filter = $filterpath;
$a->directory = $filterpath; $a->directory = "$CFG->dirroot/filter/$filterpath";
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice'); echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($returnurl); echo $OUTPUT->continue_button($returnurl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
...@@ -241,7 +224,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) ...@@ -241,7 +224,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
} }
// Disable/off/on // Disable/off/on
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter)); $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . $filter);
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide')); $select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
$row[] = $OUTPUT->render($select); $row[] = $OUTPUT->render($select);
...@@ -263,25 +246,20 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) ...@@ -263,25 +246,20 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
$row[] = $updown; $row[] = $updown;
// Apply to strings. // Apply to strings.
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter)); $select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide')); $select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED; $select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
$row[] = $OUTPUT->render($select); $row[] = $OUTPUT->render($select);
// Settings link, if required // Settings link, if required
if (filter_has_global_settings($filter)) { if (filter_has_global_settings($filter)) {
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $filter . '">' . get_string('settings') . '</a>';
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
} else { } else {
$row[] = ''; $row[] = '';
} }
// Delete // Delete
if (substr($filter, 0, 4) != 'mod/') { $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
} else {
$row[] = '';
}
return $row; return $row;
} }
...@@ -1817,6 +1817,14 @@ class restore_filters_structure_step extends restore_structure_step { ...@@ -1817,6 +1817,14 @@ class restore_filters_structure_step extends restore_structure_step {
$data = (object)$data; $data = (object)$data;
if (strpos($data->filter, 'filter/') === 0) {
$data->filter = substr($data->filter, 7);
} else if (strpos($data->filter, '/') !== false) {
// Unsupported old filter.
return;
}
if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do
return; return;
} }
...@@ -1827,6 +1835,14 @@ class restore_filters_structure_step extends restore_structure_step { ...@@ -1827,6 +1835,14 @@ class restore_filters_structure_step extends restore_structure_step {
$data = (object)$data; $data = (object)$data;
if (strpos($data->filter, 'filter/') === 0) {
$data->filter = substr($data->filter, 7);
} else if (strpos($data->filter, '/') !== false) {
// Unsupported old filter.
return;
}
if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do
return; return;
} }
......
...@@ -26,6 +26,6 @@ function xmldb_filter_activitynames_install() { ...@@ -26,6 +26,6 @@ function xmldb_filter_activitynames_install() {
global $CFG; global $CFG;
require_once("$CFG->libdir/filterlib.php"); require_once("$CFG->libdir/filterlib.php");
filter_set_global_state('filter/activitynames', TEXTFILTER_ON); filter_set_global_state('activitynames', TEXTFILTER_ON);
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
require_once("../../config.php"); require_once("../../config.php");
if (!filter_is_enabled('filter/algebra')) { if (!filter_is_enabled('algebra')) {
print_error('filternotenabled'); print_error('filternotenabled');
} }
......
...@@ -9,7 +9,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching ...@@ -9,7 +9,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
require_once('../../config.php'); require_once('../../config.php');
if (!filter_is_enabled('filter/algebra')) { if (!filter_is_enabled('algebra')) {
print_error('filternotenabled'); print_error('filternotenabled');
} }
......
...@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../config.php'); ...@@ -27,7 +27,7 @@ require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/adminlib.php');
$contextid = required_param('contextid',PARAM_INT); $contextid = required_param('contextid',PARAM_INT);
$forfilter = optional_param('filter', '', PARAM_SAFEPATH); $forfilter = optional_param('filter', '', PARAM_SAFEDIR);
list($context, $course, $cm) = get_context_info_array($contextid); list($context, $course, $cm) = get_context_info_array($contextid);
...@@ -82,8 +82,8 @@ if ($forfilter) { ...@@ -82,8 +82,8 @@ if ($forfilter) {
print_error('filterdoesnothavelocalconfig', 'error', $forfilter); print_error('filterdoesnothavelocalconfig', 'error', $forfilter);
} }
require_once($CFG->dirroot . '/filter/local_settings_form.php'); require_once($CFG->dirroot . '/filter/local_settings_form.php');
require_once($CFG->dirroot . '/' . $forfilter . '/filterlocalsettings.php'); require_once($CFG->dirroot . '/filter/' . $forfilter . '/filterlocalsettings.php');
$formname = basename($forfilter) . '_filter_local_settings_form'; $formname = $forfilter . '_filter_local_settings_form';
$settingsform = new $formname($CFG->wwwroot . '/filter/manage.php', $forfilter, $context); $settingsform = new $formname($CFG->wwwroot . '/filter/manage.php', $forfilter, $context);
if ($settingsform->is_cancelled()) { if ($settingsform->is_cancelled()) {
redirect($baseurl); redirect($baseurl);
...@@ -96,7 +96,7 @@ if ($forfilter) { ...@@ -96,7 +96,7 @@ if ($forfilter) {
/// Process any form submission. /// Process any form submission.
if ($forfilter == '' && optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { if ($forfilter == '' && optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
foreach ($availablefilters as $filter => $filterinfo) { foreach ($availablefilters as $filter => $filterinfo) {
$newstate = optional_param(str_replace('/', '_', $filter), false, PARAM_INT); $newstate = optional_param($filter, false, PARAM_INT);
if ($newstate !== false && $newstate != $filterinfo->localstate) { if ($newstate !== false && $newstate != $filterinfo->localstate) {
filter_set_local_state($filter, $context->id, $newstate); filter_set_local_state($filter, $context->id, $newstate);
} }
...@@ -181,9 +181,8 @@ if (empty($availablefilters)) { ...@@ -181,9 +181,8 @@ if (empty($availablefilters)) {
} else { } else {
$activechoices[TEXTFILTER_INHERIT] = $strdefaultoff; $activechoices[TEXTFILTER_INHERIT] = $strdefaultoff;
} }
$filtername = str_replace('/', '_', $filter); $select = html_writer::label($filterinfo->localstate, 'menu'. $filter, false, array('class' => 'accesshide'));
$select = html_writer::label($filterinfo->localstate, 'menu'. $filtername, false, array('class' => 'accesshide')); $select .= html_writer::select($activechoices, $filter, $filterinfo->localstate, false);
$select .= html_writer::select($activechoices, $filtername, $filterinfo->localstate, false);
$row[] = $select; $row[] = $select;
// Settings link, if required // Settings link, if required
......
...@@ -27,6 +27,6 @@ function xmldb_filter_mediaplugin_install() { ...@@ -27,6 +27,6 @@ function xmldb_filter_mediaplugin_install() {
global $CFG; global $CFG;
require_once("$CFG->libdir/filterlib.php"); require_once("$CFG->libdir/filterlib.php");
filter_set_global_state('filter/mediaplugin', TEXTFILTER_ON); filter_set_global_state('mediaplugin', TEXTFILTER_ON);
} }
...@@ -29,7 +29,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching ...@@ -29,7 +29,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
require('../../config.php'); require('../../config.php');
if (!filter_is_enabled('filter/tex') and !filter_is_enabled('filter/algebra')) { if (!filter_is_enabled('tex') and !filter_is_enabled('algebra')) {
print_error('filternotenabled'); print_error('filternotenabled');
} }
......
...@@ -9,7 +9,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching ...@@ -9,7 +9,7 @@ define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
require_once('../../config.php'); require_once('../../config.php');
if (!filter_is_enabled('filter/tex')) { if (!filter_is_enabled('tex')) {
print_error('filternotenabled'); print_error('filternotenabled');
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
require_once("../../config.php"); require_once("../../config.php");
if (!filter_is_enabled('filter/tex')) { if (!filter_is_enabled('tex')) {
print_error('filternotenabled'); print_error('filternotenabled');
} }
......
This file describes API changes in core filter API and plugins, This file describes API changes in core filter API and plugins,
information provided here is intended especially for developers. information provided here is intended especially for developers.
=== 2.5 ===
* legacy_filter emulation was removed
* support for 'mod/*' filters was removed
* use short filter name instead of old path, ex.: 'filter/tex' ---> 'tex'
in all filter API functions and methods
=== 2.3 === === 2.3 ===
* new setup() method added to moodle_text_filter, invoked before * new setup() method added to moodle_text_filter, invoked before
......
...@@ -6092,8 +6092,7 @@ class admin_page_managefilters extends admin_externalpage { ...@@ -6092,8 +6092,7 @@ class admin_page_managefilters extends admin_externalpage {
$found = true; $found = true;
break; break;
} }
list($type, $filter) = explode('/', $path); if (strpos($path, $query) !== false) {
if (strpos($filter, $query) !== false) {
$found = true; $found = true;
break; break;
} }
......
...@@ -456,7 +456,7 @@ ...@@ -456,7 +456,7 @@
<TABLE NAME="filter_active" COMMENT="Stores information about which filters are active in which contexts. Also the filter sort order. See get_active_filters in lib/filterlib.php for how this data is used." PREVIOUS="course_format_options" NEXT="filter_config"> <TABLE NAME="filter_active" COMMENT="Stores information about which filters are active in which contexts. Also the filter sort order. See get_active_filters in lib/filterlib.php for how this data is used." PREVIOUS="course_format_options" NEXT="filter_config">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="filter"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="filter"/>
<FIELD NAME="filter" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The filter internal name, like 'filter/tex' or 'mod/glossary'." PREVIOUS="id" NEXT="contextid"/> <FIELD NAME="filter" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The filter internal name, like 'tex'." PREVIOUS="id" NEXT="contextid"/>
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="References context.id." PREVIOUS="filter" NEXT="active"/> <FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="References context.id." PREVIOUS="filter" NEXT="active"/>
<FIELD NAME="active" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="Whether this filter is active in this context. +1 = On, -1 = Off, no row with this contextid = inherit. As a special case, when contextid points to the system context, -9999 means this filter is completely disabled." PREVIOUS="contextid" NEXT="sortorder"/> <FIELD NAME="active" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false" COMMENT="Whether this filter is active in this context. +1 = On, -1 = Off, no row with this contextid = inherit. As a special case, when contextid points to the system context, -9999 means this filter is completely disabled." PREVIOUS="contextid" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Only relevant if contextid points to the system context. In other cases this field should contain 0. The order in which the filters should be applied." PREVIOUS="active"/> <FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Only relevant if contextid points to the system context. In other cases this field should contain 0. The order in which the filters should be applied." PREVIOUS="active"/>
...@@ -472,7 +472,7 @@ ...@@ -472,7 +472,7 @@
<TABLE NAME="filter_config" COMMENT="Stores per-context configuration settings for filters which have them." PREVIOUS="filter_active" NEXT="event"> <TABLE NAME="filter_config" COMMENT="Stores per-context configuration settings for filters which have them." PREVIOUS="filter_active" NEXT="event">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="filter"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="filter"/>
<FIELD NAME="filter" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The filter internal name, like 'filter/tex' or 'mod/glossary'." PREVIOUS="id" NEXT="contextid"/> <FIELD NAME="filter" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="The filter internal name, like 'tex'." PREVIOUS="id" NEXT="contextid"/>
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="References context.id." PREVIOUS="filter" NEXT="name"/> <FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="References context.id." PREVIOUS="filter" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The config variable name." PREVIOUS="contextid" NEXT="value"/> <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The config variable name." PREVIOUS="contextid" NEXT="value"/>
<FIELD NAME="value" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The correspoding config variable value." PREVIOUS="name"/> <FIELD NAME="value" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="The correspoding config variable value." PREVIOUS="name"/>
......
...@@ -1524,5 +1524,46 @@ function xmldb_main_upgrade($oldversion) { ...@@ -1524,5 +1524,46 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012120300.04); upgrade_main_savepoint(true, 2012120300.04);
} }
if ($oldversion < 2012120300.07) {
// Purge removed module filters and all their settings.
$tables = array('filter_active', 'filter_config');
foreach ($tables as $table) {
$DB->delete_records_select($table, "filter LIKE 'mod/%'");
$filters = $DB->get_records_sql("SELECT DISTINCT filter FROM {{$table}} WHERE filter LIKE 'filter/%'");
foreach ($filters as $filter) {
$DB->set_field($table, 'filter', substr($filter->filter, 7), array('filter'=>$filter->filter));
}
}
$configs = array('stringfilters', 'filterall');
foreach ($configs as $config) {
if ($filters = get_config(null, $config)) {
$filters = explode(',', $filters);
$newfilters = array();
foreach($filters as $filter) {
if (strpos($filter, '/') === false) {
$newfilters[] = $filter;
} else if (strpos($filter, 'filter/') === 0) {
$newfilters[] = substr($filter, 7);
}
}
$filters = implode(',', $newfilters);
set_config($config, $filters);
}
}
unset($tables);
unset($table);
unset($configs);
unset($newfilters);
unset($filters);
unset($filter);
// Main savepoint reached.
upgrade_main_savepoint(true, 2012120300.07);
}
return true; return true;
} }
...@@ -33,7 +33,7 @@ class tinymce_dragmath extends editor_tinymce_plugin { ...@@ -33,7 +33,7 @@ class tinymce_dragmath extends editor_tinymce_plugin {
if ($this->get_config('requiretex', 1)) { if ($this->get_config('requiretex', 1)) {
// If TeX filter is disabled, do not add button. // If TeX filter is disabled, do not add button.
$filters = filter_get_active_in_context($context); $filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/tex', $filters)) { if (!array_key_exists('tex', $filters)) {
return; return;
} }
} }
......
...@@ -34,7 +34,7 @@ class tinymce_moodleemoticon extends editor_tinymce_plugin { ...@@ -34,7 +34,7 @@ class tinymce_moodleemoticon extends editor_tinymce_plugin {
if ($this->get_config('requireemoticon', 1)) { if ($this->get_config('requireemoticon', 1)) {
// If emoticon filter is disabled, do not add button. // If emoticon filter is disabled, do not add button.
$filters = filter_get_active_in_context($context); $filters = filter_get_active_in_context($context);
if (!array_key_exists('filter/emoticon', $filters)) { if (!array_key_exists('emoticon', $filters)) {
return; return;
} }
} }
......
...@@ -2,6 +2,11 @@ This files describes API changes in /lib/editor/tinymce/* - TinyMCE editor, ...@@ -2,6 +2,11 @@ This files describes API changes in /lib/editor/tinymce/* - TinyMCE editor,
information provided here is intended especially for developers. information provided here is intended especially for developers.
=== 2.5 ===
* update filter related code to use short filter names instead
of original paths, ex.: 'filter/tex' ---> 'tex'
=== 2.4 === === 2.4 ===
new features: new features:
......
...@@ -2715,7 +2715,7 @@ function file_modify_html_header($text) { ...@@ -2715,7 +2715,7 @@ function file_modify_html_header($text) {
}*/ }*/
$ufo = ''; $ufo = '';
if (filter_is_enabled('filter/mediaplugin')) { if (filter_is_enabled('mediaplugin')) {
// this script is needed by most media filter plugins. // this script is needed by most media filter plugins.
$attributes = array('type'=>'text/javascript', 'src'=>$CFG->httpswwwroot . '/lib/ufo.js'); $attributes = array('type'=>'text/javascript', 'src'=>$CFG->httpswwwroot . '/lib/ufo.js');
$ufo = html_writer::tag('script', '', $attributes) . "\n"; $ufo = html_writer::tag('script', '', $attributes) . "\n";
......
This diff is collapsed.
...@@ -2654,12 +2654,12 @@ class plugininfo_filter extends plugininfo_base { ...@@ -2654,12 +2654,12 @@ class plugininfo_filter extends plugininfo_base {
// get the list of filters from both /filter and /mod location // get the list of filters from both /filter and /mod location
$installed = filter_get_all_installed(); $installed = filter_get_all_installed();
foreach ($installed as $filterlegacyname => $displayname) { foreach ($installed as $name => $displayname) {
$plugin = new $typeclass(); $plugin = new $typeclass();
$plugin->type = $type; $plugin->type = $type;
$plugin->typerootdir = $typerootdir; $plugin->typerootdir = $typerootdir;
$plugin->name = self::normalize_legacy_name($filterlegacyname); $plugin->name = $name;
$plugin->rootdir = $CFG->dirroot . '/' . $filterlegacyname; $plugin->rootdir = "$CFG->dirroot/filter/$name";
$plugin->displayname = $displayname; $plugin->displayname = $displayname;
$plugin->load_disk_version(); $plugin->load_disk_version();
...@@ -2676,9 +2676,9 @@ class plugininfo_filter extends plugininfo_base { ...@@ -2676,9 +2676,9 @@ class plugininfo_filter extends plugininfo_base {
// if we're upgrading from 1.9, the table does not exist yet // if we're upgrading from 1.9, the table does not exist yet
// if it does, make sure that all installed filters are registered // if it does, make sure that all installed filters are registered
$needsreload = false; $needsreload = false;
foreach (array_keys($installed) as $filterlegacyname) { foreach (array_keys($installed) as $name) {
if (!isset($globalstates[self::normalize_legacy_name($filterlegacyname)])) { if (!isset($globalstates[$name])) {
filter_set_global_state($filterlegacyname, TEXTFILTER_DISABLED); filter_set_global_state($name, TEXTFILTER_DISABLED);
$needsreload = true; $needsreload = true;
} }
} }
...@@ -2695,8 +2695,8 @@ class plugininfo_filter extends plugininfo_base { ...@@ -2695,8 +2695,8 @@ class plugininfo_filter extends plugininfo_base {
$plugin->type = $type; $plugin->type = $type;
$plugin->typerootdir = $typerootdir; $plugin->typerootdir = $typerootdir;
$plugin->name = $name; $plugin->name = $name;
$plugin->rootdir = $CFG->dirroot . '/' . $info->legacyname; $plugin->rootdir = "$CFG->dirroot/filter/$name";
$plugin->displayname = $info->legacyname; $plugin->displayname = $name;
$plugin->load_db_version(); $plugin->load_db_version();
...@@ -2721,11 +2721,6 @@ class plugininfo_filter extends plugininfo_base { ...@@ -2721,11 +2721,6 @@ class plugininfo_filter extends plugininfo_base {
* @see load_version_php() * @see load_version_php()
*/ */
protected function load_version_php() { protected function load_version_php() {
if (strpos($this->name, 'mod_') === 0) {
// filters bundled with modules do not have a version.php and so
// do not provide their own versioning information.
return new stdClass();
}
return parent::load_version_php(); return parent::load_version_php();
} }
...@@ -2733,8 +2728,7 @@ class plugininfo_filter extends plugininfo_base { ...@@ -2733,8 +2728,7 @@ class plugininfo_filter extends plugininfo_base {
$globalstates = self::get_global_states();