From 88d89512e4f968d16cfaf3999614c4fba7636e7a Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 3 Jun 2018 21:15:35 +0800 Subject: [PATCH] MDL-36754 output: Support token pluginfiles in userpic --- lib/outputcomponents.php | 8 +++++++- lib/outputrenderers.php | 1 + lib/upgrade.txt | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index db773a63e25..dc90aea8997 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -207,6 +207,11 @@ class user_picture implements renderable { public $includefullname = false; /** + * @var bool Include user authentication token. + */ + public $includetoken = false; + + /** * User picture constructor. * * @param stdClass $user user record with at least id, picture, imagealt, firstname and lastname set. @@ -403,7 +408,8 @@ class user_picture implements renderable { $path .= $page->theme->name.'/'; } // Set the image URL to the URL for the uploaded file and return. - $url = moodle_url::make_pluginfile_url($contextid, 'user', 'icon', NULL, $path, $filename); + $url = moodle_url::make_pluginfile_url( + $contextid, 'user', 'icon', null, $path, $filename, false, $this->includetoken); $url->param('rev', $this->user->picture); return $url; } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 600e4b3017c..10b589d366d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2503,6 +2503,7 @@ class core_renderer extends renderer_base { * - class = image class attribute (default 'userpicture') * - visibletoscreenreaders=true (whether to be visible to screen readers) * - includefullname=false (whether to include the user's full name together with the user picture) + * - includetoken = false * @return string HTML fragment */ public function user_picture(stdClass $user, array $options = null) { diff --git a/lib/upgrade.txt b/lib/upgrade.txt index a8aebdfc56b..e9a5c7e1efd 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -9,6 +9,8 @@ information provided here is intended especially for developers. * The following picture functions have been updated to support use of the new token-based file serving: - print_group_picture - get_group_picture_url +* The `user_picture` class has a new public `$includetoken` property which can be set to make use of the new token-based + file serving. * Custom AJAX handlers for the form autocomplete fields can now optionally return string in their processResults() callback. If a string is returned, it is displayed instead of the list of suggested items. This can be used, for example, to inform the user that there are too many items matching the current search criteria. -- 2.11.4.GIT