Moodle

Should be a way to control filtering on/off for individual file or resource

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 1.9.3, 2.0
  • Fix Version/s: None
  • Component/s: Filters
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

One of our courses is teaching HTML and they object to their HTML example files being messed with. Moodle adds stylesheet links in there because it is set to run filters on HTML files ($CFG->filteruploadedfiles=1). Unfortunately we need the setting on for other courses.

My trivial solution is the following one-liner:

Index: file.php
===================================================================
RCS file: /home/cvs_repositories/globalcvs/ou-moodle/file.php,v
retrieving revision 1.19.4.1
diff -u -r1.19.4.1 file.php
— file.php 30 Oct 2008 11:20:37 -0000 1.19.4.1
+++ file.php 6 Nov 2008 16:18:47 -0000
@@ -266,8 +266,14 @@
// ========================================
session_write_close(); // unlock session during fileserving
$filename = $args[count($args)-1];

  • send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
    + send_file($pathname, $filename, $lifetime,
    + optional_param('preventfilter',0,PARAM_INT) ? 0 : $CFG->filteruploadedfiles,
    + false, $forcedownload);

function not_found($courseid) {
global $CFG;
header('HTTP/1.0 404 not found');

As you can see this just lets people do ?preventfilter=1 on a file.php request.

There may well be better ways to achieve this objective, especially with regard to Petr's file handling changes for 2.0, so I am not necessarily suggesting this patch should be committed, just pointing out this (minor) issue.

Issue Links

Activity

Hide
Petr Škoda (skodak) added a comment -

in 2.0 we should definitely have:

  • filter controls per course
  • filter controls per activity

This will be possible because we will know the exact activity file belongs to and modules will be responsible for final file serving decisions including filtering.

This proposal looks like a good workaround for 1.9.x

Show
Petr Škoda (skodak) added a comment - in 2.0 we should definitely have:
  • filter controls per course
  • filter controls per activity
This will be possible because we will know the exact activity file belongs to and modules will be responsible for final file serving decisions including filtering. This proposal looks like a good workaround for 1.9.x
Hide
Tim Hunt added a comment -

My idea was filter configuration by context, so by default you get the filters from the parent context, but each context can then adjust that by adding extra filters, disabling some of the ones set in the parent, or maybe just changing the configuration options for one.

That would let you do things like only enable the TeX filter in the Maths course category.

I think if we have a filter_config table that stores information about how filters are configured, and which links to the contexts table with a foreign key, we can get all the filter config for context $context using something like:

$fcs = $DB->get_recordset_sql('SELECT fc.* FROM filter_config fc JOIN context ctx ON fc.contextid = ctx.id WHERE ? || '/' LIKE ctx.path || '/%' ORDER BY ctx.depth DESC", array($context->path));
$filters = array();
foreach ($fcs as $fc) {
if (!is_set($filters[$fc->filtertype])) {
if ($dc->disabled) { $filters[$fc->filtertype] = false; } else { $filters[$fc->filtertype] = new ($fc->filtertype)($fc); }
}
}
foreach ($filters as $type -> $filter) {
if ($filters[$fc->filtertype] === false) { unset($filters[$fc->filtertype]); }
}

Then, filter configuration would become one of the tabs next to assign roles and override roles. (The plan is to move course/activity settings into the same set of tabs already.)

Also, we should make smilies a filter, rather than a hard-coded thing.

Show
Tim Hunt added a comment - My idea was filter configuration by context, so by default you get the filters from the parent context, but each context can then adjust that by adding extra filters, disabling some of the ones set in the parent, or maybe just changing the configuration options for one. That would let you do things like only enable the TeX filter in the Maths course category. I think if we have a filter_config table that stores information about how filters are configured, and which links to the contexts table with a foreign key, we can get all the filter config for context $context using something like: $fcs = $DB->get_recordset_sql('SELECT fc.* FROM filter_config fc JOIN context ctx ON fc.contextid = ctx.id WHERE ? || '/' LIKE ctx.path || '/%' ORDER BY ctx.depth DESC", array($context->path)); $filters = array(); foreach ($fcs as $fc) { if (!is_set($filters[$fc->filtertype])) { if ($dc->disabled) { $filters[$fc->filtertype] = false; } else { $filters[$fc->filtertype] = new ($fc->filtertype)($fc); } } } foreach ($filters as $type -> $filter) { if ($filters[$fc->filtertype] === false) { unset($filters[$fc->filtertype]); } } Then, filter configuration would become one of the tabs next to assign roles and override roles. (The plan is to move course/activity settings into the same set of tabs already.) Also, we should make smilies a filter, rather than a hard-coded thing.
Hide
Nadav Kavalerchik added a comment -

we have similar issues with several courses (teachers)
that would not like to see some of the filters active
in their course boundaries.

but system-wise, we do need those filters !

so we implemented similar hacks as did Sam.

i am really looking forward for having this new feature
introduced in the nearest version.

Show
Nadav Kavalerchik added a comment - we have similar issues with several courses (teachers) that would not like to see some of the filters active in their course boundaries. but system-wise, we do need those filters ! so we implemented similar hacks as did Sam. i am really looking forward for having this new feature introduced in the nearest version.
Hide
Tim Hunt added a comment -

Looks like a duplicate to me.

Show
Tim Hunt added a comment - Looks like a duplicate to me.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: