MDL-65658 mod_forum: Group images links and titles groups
authorMathew May <mathewm@hotmail.co.nz>
Tue, 21 May 2019 05:41:46 +0000 (13:41 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Fri, 31 May 2019 00:14:20 +0000 (08:14 +0800)
After a change in Moodle 3.6 some links & titles went missing.
Here I am adding them back & incresing the output image to 100x100px

lang/en/group.php
mod/forum/classes/local/exporters/author.php
mod/forum/classes/local/exporters/discussion.php
mod/forum/classes/local/factories/url.php
mod/forum/styles.css
mod/forum/templates/discussion_list.mustache
mod/forum/templates/forum_discussion_post.mustache

index 9d448ec..9f32f85 100644 (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}';
index 7ac4822..7beb5d5 100644 (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);
index 16d682a..a008de4 100644 (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;
                     }
index ab0fc75..cfb6b4b 100644 (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.
      *
index c7f31dd..6343e1d 100644 (file)
     margin: 5px 0;
 }
 
-.discussion-list .userpicture {
+.discussion-list .userpicture,
+.discussion-list .grouppicture {
     height: 35px;
     width: 35px;
 }
index 60e3704..fbb2744 100644 (file)
                                                 class="rounded-circle userpicture"
                                                 src="{{urls.profileimage}}"
                                                 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
+                                                title="{{fullname}}"
                                             >
                                         </div>
                                         <div class="align-middle p-2">
                                 {{/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}}
                                                     class="rounded-circle userpicture"
                                                     src="{{latestpostauthor.urls.profileimage}}"
                                                     alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
+                                                    title="{{latestpostauthor.fullname}}"
                                                 >
                                             </a>
                                         </div>
index e5a8e1d..bf8c39f 100644 (file)
@@ -58,6 +58,7 @@
                                     src="{{{.}}}"
                                     alt="{{#str}} pictureof, core, {{author.fullname}} {{/str}}"
                                     aria-hidden="true"
+                                    title="{{author.fullname}}"
                                 >
                             {{/urls.profileimage}}
                         </div>
                     {{#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}}