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

Add a callback to enable extension of file_rewrite_urls_to_pluginfile() in a plugin

    XMLWordPrintable

Details

    • MDL-73596-rewrite-urls-hook
    • Hide

      Untar tool_testfile.tgz in the app root - you should end up with a directory of admin/tool/testfile. In the Moodle app, go to the admin pages so the plugin gets installed.

      Plugins rewrite URLs hook tests plugin

      Rewrite feature is configured (turned on/off) on the `/admin/settings.php?section=tool_testfile` page.

      `file_rewrite_urls()` callback

      Modules can provide `[module_name]_file_rewrite_urls()` callback to revert possible effects of URL rewrite.

      This module introduces `tool_testfile_file_rewrite_urls()` function that strips `#test-rewrite` anchor from URLs, when the feature is turned on.

      Settings

      `enableurlrewrite` - turn rewrite off and on.

      Testing

      With `enableurlrewrite` setting at `off` (default)

       1. Enter a URL with the specified anchor in any text box, eg have `https://example.com/#test-rewrite` in your profile description.
       2. After saving, the URL will stay unchanged.

      With `enableurlrewrite` setting at `on`

       1. Repeat the step 1 above.
       2. After saving, the URL will have `#test-rewrite` removed.

       

      This testing instructions are in  admin/tool/testfile/README.md

      Show
      Untar tool_testfile.tgz in the app root - you should end up with a directory of admin/tool/testfile. In the Moodle app, go to the admin pages so the plugin gets installed. Plugins rewrite URLs hook tests plugin Rewrite feature is configured (turned on/off) on the `/admin/settings.php?section=tool_testfile` page. `file_rewrite_urls()` callback Modules can provide ` [module_name] _file_rewrite_urls()` callback to revert possible effects of URL rewrite. This module introduces `tool_testfile_file_rewrite_urls()` function that strips `#test-rewrite` anchor from URLs, when the feature is turned on. Settings `enableurlrewrite` - turn rewrite off and on. Testing With `enableurlrewrite` setting at `off` (default)  1. Enter a URL with the specified anchor in any text box, eg have ` https://example.com/#test-rewrite ` in your profile description.  2. After saving, the URL will stay unchanged. With `enableurlrewrite` setting at `on`  1. Repeat the step 1 above.  2. After saving, the URL will have `#test-rewrite` removed.   This testing instructions are in   admin/tool/testfile/README.md

    Description

      There are a couple use cases for this:

      1) a file system plugin that signs urls can intercept erroneous signed urls being cut and paste into other places and convert them back into canonical moodle urls

      2) plugins like filters which improve the text in various ways can also have the option of permanently changing this and having it persisted. 

      Plugins that want to use this functionality should provide [plugin_name]_file_rewrite_urls($text, $contextid) function.

      Callbacks are invoked before standard @@PLUGINFILE@@/ rewrite.

      Attachments

        Activity

          People

            srdjan Srdjan Jankovic
            brendanheywood Brendan Heywood
            cameron1729 cameron1729
            Jake Dallimore Jake Dallimore
            Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 10 minutes
                1h 10m