MDL-65658 mod_forum: Group images links and titles groups
[moodle.git] / mod / forum / classes / local / exporters / author.php
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);