MDL-63501 mod_scorm: Add support for removal of context users
[moodle.git] / group / classes / output / group_details.php
blob11d4a62e07823c2160ac5a15f16486c0830d65c0
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
18 * Group details page.
20 * @package core_group
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();
27 use renderable;
28 use renderer_base;
29 use stdClass;
30 use templatable;
31 use context_course;
32 use moodle_url;
34 /**
35 * Group details page class.
37 * @package core_group
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. */
44 protected $group;
46 /**
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);
55 /**
56 * Export the data.
58 * @param renderer_base $output
59 * @return stdClass
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,
66 'pluginfile.php',
67 $context->id,
68 'group',
69 'description',
70 $this->group->id);
72 $descriptionformat = $this->group->descriptionformat ?? FORMAT_MOODLE;
73 $options = [
74 'overflowdiv' => true,
75 'context' => $context
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);
88 return $data;
89 } else {
90 return;