MDL-65658 mod_forum: Group images links and titles groups

After a change in Moodle 3.6 some links & titles went missing.
Here I am adding them back & incresing the output image to 100x100px
This commit is contained in:
Mathew May 2019-05-21 13:41:46 +08:00
parent 29c395187f
commit c939a043bf
7 changed files with 67 additions and 18 deletions

View File

@ -196,3 +196,4 @@ $string['toomanygroups'] = 'Insufficient users to populate this number of groups
$string['usercount'] = 'User count';
$string['usercounttotal'] = 'User count ({$a})';
$string['usergroupmembership'] = 'Selected user\'s membership:';
$string['memberofgroup'] = 'Group member of: {$a}';

View File

@ -140,15 +140,26 @@ class author extends exporter {
$author = $this->author;
$authorcontextid = $this->authorcontextid;
$urlfactory = $this->related['urlfactory'];
$context = $this->related['context'];
if ($this->canview) {
$groups = array_map(function($group) {
$imageurl = get_group_picture_url($group, $group->courseid);
$groups = array_map(function($group) use ($urlfactory, $context) {
$imageurl = null;
$groupurl = null;
if (!$group->hidepicture) {
$imageurl = get_group_picture_url($group, $group->courseid, true);
}
if (course_can_view_participants($context)) {
$groupurl = $urlfactory->get_author_group_url($group);
}
return [
'id' => $group->id,
'name' => $group->name,
'urls' => [
'image' => $imageurl ? $imageurl->out(false) : null
'image' => $imageurl ? $imageurl->out(false) : null,
'group' => $groupurl ? $groupurl->out(false) : null
]
];
}, $this->authorgroups);

View File

@ -179,7 +179,7 @@ class discussion extends exporter {
];
if (!$group->hidepicture) {
$url = get_group_picture_url($group, $forum->get_course_id());
$url = get_group_picture_url($group, $forum->get_course_id(), true);
if (!empty($url)) {
$groupdata['urls']['picture'] = $url;
}

View File

@ -427,6 +427,18 @@ class url {
return $userpicture->get_url($PAGE);
}
/**
* Get the url to view an author's group.
*
* @param \stdClass $group The group
* @return moodle_url
*/
public function get_author_group_url(\stdClass $group) : moodle_url {
return new moodle_url('/user/index.php', [
'id' => $group->courseid,
'group' => $group->id
]);
}
/**
* Get the url to mark a discussion as read.
*

View File

@ -216,7 +216,8 @@
margin: 5px 0;
}
.discussion-list .userpicture {
.discussion-list .userpicture,
.discussion-list .grouppicture {
height: 35px;
width: 35px;
}

View File

@ -155,6 +155,7 @@
class="rounded-circle userpicture"
src="{{urls.profileimage}}"
alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
title="{{fullname}}"
>
</div>
<div class="align-middle p-2">
@ -164,21 +165,28 @@
{{/firstpostauthor}}
</td>
{{#forum.state.groupmode}}
<td scope="col" class="group">
<td scope="col" class="group align-middle">
{{#discussion.group}}
{{#urls.picture}}
{{#urls.userlist}}
<a href="{{{urls.userlist}}}">
<img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
<a href="{{{urls.userlist}}}" role="button" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>
<img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
aria-hidden="true"
class="border rounded h-auto rounded-circle grouppicture"
src="{{{urls.picture}}}"
title="{{name}}">
</a>
{{/urls.userlist}}
{{^urls.userlist}}
<img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
<img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
class="border rounded h-auto rounded-circle grouppicture"
src="{{{urls.picture}}}"
title="{{name}}">
{{/urls.userlist}}
{{/urls.picture}}
{{^urls.picture}}
{{#urls.userlist}}
<a href="{{{urls.userlist}}}">{{name}}</a>
<a href="{{{urls.userlist}}}" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>{{name}}</a>
{{/urls.userlist}}
{{^urls.userlist}}
{{name}}
@ -220,6 +228,7 @@
class="rounded-circle userpicture"
src="{{latestpostauthor.urls.profileimage}}"
alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
title="{{latestpostauthor.fullname}}"
>
</a>
</div>

View File

@ -58,6 +58,7 @@
src="{{{.}}}"
alt="{{#str}} pictureof, core, {{author.fullname}} {{/str}}"
aria-hidden="true"
title="{{author.fullname}}"
>
{{/urls.profileimage}}
</div>
@ -94,14 +95,28 @@
{{#author}}
<div class="mr-2 author-groups-container" style="width: 45px; flex-shrink: 0">
{{#groups}}
{{#urls.image}}
<img
class="rounded-circle w-100"
src="{{{.}}}"
alt="{{#str}} pictureof, core, {{name}} {{/str}}"
aria-hidden="true"
>
{{/urls.image}}
{{#urls.group}}
{{#urls.image}}
<a href="{{urls.group}}" role="button" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>
<img
class="rounded-circle w-100"
src="{{{.}}}"
alt="{{#str}} pictureof, core, {{name}} {{/str}}"
aria-hidden="true"
title="{{name}}"
>
</a>
{{/urls.image}}
{{/urls.group}}
{{^urls.group}}
{{#urls.image}}
<img class="rounded-circle w-100"
src="{{{.}}}"
alt="{{#str}} pictureof, core, {{name}} {{/str}}"
title="{{name}}"
>
{{/urls.image}}
{{/urls.group}}
{{/groups}}
</div>
{{/author}}