From 3b1eba069e18fcd56032a6d7f0a4e29bdde9dc2a Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 18 Jul 2017 17:11:59 +0800 Subject: [PATCH] MDL-59528 core: Add option to display fullname beside user picture --- lib/outputcomponents.php | 5 +++++ lib/outputrenderers.php | 6 ++++++ lib/upgrade.txt | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index a1be437ba48..e237ba5a9aa 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -201,6 +201,11 @@ class user_picture implements renderable { */ public $visibletoscreenreaders = true; + /** + * @var bool Whether to include the fullname in the user picture link. + */ + public $includefullname = false; + /** * User picture constructor. * diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 139e6f9d3db..08e917b6d62 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2368,6 +2368,7 @@ class core_renderer extends renderer_base { * - alttext=true (add image alt attribute) * - 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) * @return string HTML fragment */ public function user_picture(stdClass $user, array $options = null) { @@ -2425,6 +2426,11 @@ class core_renderer extends renderer_base { // get the image html output fisrt $output = html_writer::empty_tag('img', $attributes); + // Show fullname together with the picture when desired. + if ($userpicture->includefullname) { + $output .= fullname($userpicture->user); + } + // then wrap it in link if needed if (!$userpicture->link) { return $output; diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 58881aff840..ef21b435245 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -24,6 +24,7 @@ information provided here is intended especially for developers. used to perform implicit validation of submitted values - without the need to explicitly add the validation rules to every form. The method should accept a single parameter with the submitted value. It should return a string with the eventual validation error, or an empty value if the validation passes. +* New user_picture attribute $includefullname to determine whether to include the user's full name with the user's picture. === 3.3.1 ===