Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-25240

Enable filters to work for messages

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0, 2.0.1
    • Component/s: Filters, Messages
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      It would be great if filters worked for messages so that smilies are converted etc, as in Moodle 1.9.

        Gliffy Diagrams

          Activity

          Hide
          andyjdavis Andrew Davis added a comment - - edited

          Ive committed a fix for this. Note that messages are displayed as "Moodle auto-format". If filters do not appear to be being applied check the filter settings to make sure that Moodle auto-format is ticked.

          Also, messaging exists outside of any course so filters that rely on course data, most notably the glossary auto-link filter, are not used. The filters that convert smileys and that turn URLs into clickable links work fine

          Show
          andyjdavis Andrew Davis added a comment - - edited Ive committed a fix for this. Note that messages are displayed as "Moodle auto-format". If filters do not appear to be being applied check the filter settings to make sure that Moodle auto-format is ticked. Also, messaging exists outside of any course so filters that rely on course data, most notably the glossary auto-link filter, are not used. The filters that convert smileys and that turn URLs into clickable links work fine
          Hide
          tsala Helen Foster added a comment -

          Thanks for the speedy fix. I guess the link filter will convert links into clickable links too? Looking forward to moodle.org being updated!

          Show
          tsala Helen Foster added a comment - Thanks for the speedy fix. I guess the link filter will convert links into clickable links too? Looking forward to moodle.org being updated!
          Hide
          andyjdavis Andrew Davis added a comment -

          "I guess the link filter will convert links into clickable links too?"

          It should do

          Show
          andyjdavis Andrew Davis added a comment - "I guess the link filter will convert links into clickable links too?" It should do
          Hide
          aborrow Anthony Borrow added a comment -

          Andrew - I am re-opening this issue as I was sending a Moodle message to someone and the Moodle Docs filter did not seem to be working.

          In /message/index.php I noticed:

          $messageid = message_post_message($user1, $user2, $data->message, FORMAT_PLAIN, 'direct');

          I grep'd message_post_message and it does not seem to be used consistently. I would expect FORMAT_MOODLE to be used in all places (at least by default) as in /user/messageselect.php

          Yet in /admin/user/user_bulk_message.php we are using FORMAT_HTML.

          Do we want these to all be FORMAT_MOODLE? I figured at least reviewing these to make sure the intended behavior is taking place would be worth a look.

          Peace - Anthony

          Show
          aborrow Anthony Borrow added a comment - Andrew - I am re-opening this issue as I was sending a Moodle message to someone and the Moodle Docs filter did not seem to be working. In /message/index.php I noticed: $messageid = message_post_message($user1, $user2, $data->message, FORMAT_PLAIN, 'direct'); I grep'd message_post_message and it does not seem to be used consistently. I would expect FORMAT_MOODLE to be used in all places (at least by default) as in /user/messageselect.php Yet in /admin/user/user_bulk_message.php we are using FORMAT_HTML. Do we want these to all be FORMAT_MOODLE? I figured at least reviewing these to make sure the intended behavior is taking place would be worth a look. Peace - Anthony
          Hide
          aborrow Anthony Borrow added a comment -

          I would have expected the link to be created - I forgot whether it was a single or double bracket so I tried both. Peace - Anthony

          Show
          aborrow Anthony Borrow added a comment - I would have expected the link to be created - I forgot whether it was a single or double bracket so I tried both. Peace - Anthony
          Hide
          andyjdavis Andrew Davis added a comment - - edited

          I actually think this is a problem with the filter itself. I downloaded it from contrib and all it has in it is moodledocs_filter(). When I added the following to the file it all worked.

          class filter_moodledocs extends moodle_text_filter {
          function filter($text, array $options = array())

          { return moodledocs_filter(null, $text); }

          }

          Im guessing but was the moodle_text_filter class a Moodle 2.0 change and this filter just hasnt been updated?

          Show
          andyjdavis Andrew Davis added a comment - - edited I actually think this is a problem with the filter itself. I downloaded it from contrib and all it has in it is moodledocs_filter(). When I added the following to the file it all worked. class filter_moodledocs extends moodle_text_filter { function filter($text, array $options = array()) { return moodledocs_filter(null, $text); } } Im guessing but was the moodle_text_filter class a Moodle 2.0 change and this filter just hasnt been updated?
          Hide
          andyjdavis Andrew Davis added a comment -

          Attaching a patch that switches IMs to be FORMAT_MOODLE. I think we used FORMAT_PLAIN to be very very secure but FORMAT_MOODLE should be fine. I think.

          Also added a comment explaining by we're using FORMAT_HTML in user_bulk_message.php

          Show
          andyjdavis Andrew Davis added a comment - Attaching a patch that switches IMs to be FORMAT_MOODLE. I think we used FORMAT_PLAIN to be very very secure but FORMAT_MOODLE should be fine. I think. Also added a comment explaining by we're using FORMAT_HTML in user_bulk_message.php
          Hide
          samhemelryk Sam Hemelryk added a comment - - edited

          Hi Andrew,

          The moodle_text_filter is new to Moodle 2.0 however there is support for old filters still. The only for the legacy support is that filters only get applied within courses which I imagine messaging isn't.
          The filter itself does need updating, I see Eloy was the last person who worked on it in contrib so you could check with him. I just checked Moodle.org which uses this filter in case it had been converted there but nothing has changed.

          As for the changes in the patch they looks fine so +1 from me.

          Cheers
          Sam

          Show
          samhemelryk Sam Hemelryk added a comment - - edited Hi Andrew, The moodle_text_filter is new to Moodle 2.0 however there is support for old filters still. The only for the legacy support is that filters only get applied within courses which I imagine messaging isn't. The filter itself does need updating, I see Eloy was the last person who worked on it in contrib so you could check with him. I just checked Moodle.org which uses this filter in case it had been converted there but nothing has changed. As for the changes in the patch they looks fine so +1 from me. Cheers Sam
          Hide
          andyjdavis Andrew Davis added a comment - - edited

          Confirmed, legacy filters are only applied within a course. Messaging exists outside of any course so legacy filters are not applied. For this to work in Moodle 2.0 the filter needs to be updated. There is probably a better way but the code in my comment above does the trick aside from warnings about missing strings.

          Show
          andyjdavis Andrew Davis added a comment - - edited Confirmed, legacy filters are only applied within a course. Messaging exists outside of any course so legacy filters are not applied. For this to work in Moodle 2.0 the filter needs to be updated. There is probably a better way but the code in my comment above does the trick aside from warnings about missing strings.
          Hide
          andyjdavis Andrew Davis added a comment -

          Committed that patch to make the formats a bit more standard and to explain why they're not entirely so.

          Show
          andyjdavis Andrew Davis added a comment - Committed that patch to make the formats a bit more standard and to explain why they're not entirely so.
          Hide
          andyjdavis Andrew Davis added a comment -

          Marking this resolved. I've opened CONTRIB-2592 to get the filter updated.

          Show
          andyjdavis Andrew Davis added a comment - Marking this resolved. I've opened CONTRIB-2592 to get the filter updated.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10