Skip to content

Commit

Permalink
MDL-36754 output: Support token pluginfiles in userpic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Aug 13, 2018
1 parent 883f655 commit 88d8951
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ class user_picture implements renderable {
*/
public $includefullname = false;

/**
* @var bool Include user authentication token.
*/
public $includetoken = false;

/**
* User picture constructor.
*
Expand Down Expand Up @@ -403,7 +408,8 @@ public function get_url(moodle_page $page, renderer_base $renderer = null) {
$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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,7 @@ public function spacer(array $attributes = null, $br = false) {
* - 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) {
Expand Down
2 changes: 2 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 88d8951

Please sign in to comment.