2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
21 * @copyright 2017 Adrian Greeve <adrian@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 namespace core_group\output
;
25 defined('MOODLE_INTERNAL') ||
die();
35 * Group details page class.
38 * @copyright 2017 Adrian Greeve <adrian@moodle.com>
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 class group_details
implements renderable
, templatable
{
43 /** @var stdClass $group An object with the group information. */
47 * group_details constructor.
49 * @param int $groupid Group ID to show details of.
51 public function __construct($groupid) {
52 $this->group
= groups_get_group($groupid, '*', MUST_EXIST
);
58 * @param renderer_base $output
61 public function export_for_template(renderer_base
$output) {
63 if (!empty($this->group
->description
) ||
(!empty($this->group
->picture
) && empty($this->group
->hidepicture
))) {
64 $context = context_course
::instance($this->group
->courseid
);
65 $description = file_rewrite_pluginfile_urls($this->group
->description
,
72 $descriptionformat = $this->group
->descriptionformat ?? FORMAT_MOODLE
;
74 'overflowdiv' => true,
78 $data = new stdClass();
79 $data->name
= format_string($this->group
->name
, true, ['context' => $context]);
80 $data->pictureurl
= get_group_picture_url($this->group
, $this->group
->courseid
, true);
81 $data->description
= format_text($description, $descriptionformat, $options);
83 if (has_capability('moodle/course:managegroups', $context)) {
84 $url = new moodle_url('/group/group.php', ['id' => $this->group
->id
, 'courseid' => $this->group
->courseid
]);
85 $data->editurl
= $url->out(false);