Skip to content

Commit

Permalink
MDL-65658 mod_forum: Group images links and titles groups
Browse files Browse the repository at this point in the history
After a change in Moodle 3.6 some links & titles went missing.
Here I am adding them back & incresing the output image to 100x100px
  • Loading branch information
Chocolate-lightning committed May 31, 2019
1 parent 29c3951 commit c939a04
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 18 deletions.
1 change: 1 addition & 0 deletions lang/en/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,4 @@
$string['usercount'] = 'User count';
$string['usercounttotal'] = 'User count ({$a})';
$string['usergroupmembership'] = 'Selected user\'s membership:';
$string['memberofgroup'] = 'Group member of: {$a}';
17 changes: 14 additions & 3 deletions mod/forum/classes/local/exporters/author.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,26 @@ protected function get_other_values(renderer_base $output) {
$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);
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/classes/local/exporters/discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function get_other_values(renderer_base $output) {
];

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;
}
Expand Down
12 changes: 12 additions & 0 deletions mod/forum/classes/local/factories/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@ public function get_author_profile_image_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.
*
Expand Down
3 changes: 2 additions & 1 deletion mod/forum/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@
margin: 5px 0;
}

.discussion-list .userpicture {
.discussion-list .userpicture,
.discussion-list .grouppicture {
height: 35px;
width: 35px;
}
Expand Down
19 changes: 14 additions & 5 deletions mod/forum/templates/discussion_list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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}}
Expand Down Expand Up @@ -220,6 +228,7 @@
class="rounded-circle userpicture"
src="{{latestpostauthor.urls.profileimage}}"
alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
title="{{latestpostauthor.fullname}}"
>
</a>
</div>
Expand Down
31 changes: 23 additions & 8 deletions mod/forum/templates/forum_discussion_post.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
src="{{{.}}}"
alt="{{#str}} pictureof, core, {{author.fullname}} {{/str}}"
aria-hidden="true"
title="{{author.fullname}}"
>
{{/urls.profileimage}}
</div>
Expand Down Expand Up @@ -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}}
Expand Down

0 comments on commit c939a04

Please sign in to comment.