Skip to content

Commit

Permalink
MDL-77991 filelib: Allow groups to generate svgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Aug 3, 2023
1 parent a4b3b0d commit 9bb91ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions group/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ information provided here is intended especially for developers.
- `core_group_get_course_groups`
- `core_group_get_course_user_groups`
- `core_group_get_activity_allowed_groups`
* Groups now have access to create GeoPattern default images based upon their ID with their associated course context.
This can be done by calling the following:
moodle_url::make_pluginfile_url(
$coursecontext->id,
'group',
'generated',
$group->id,
'/',
'group.svg'
);

=== 4.2 ===
* `\core_group\visibility` class added to support new `visibility` field in group records. This holds the visibility constants
Expand Down
12 changes: 12 additions & 0 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5029,6 +5029,18 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null, $offlin
\core\session\manager::write_close(); // Unlock session during file serving.
send_stored_file($file, 60*60, 0, false, $sendfileoptions);

} else if ($filearea === 'generated') {
if ($CFG->forcelogin) {
require_login($course);
} else if ($course->id != SITEID) {
require_login($course);
}

$svg = $OUTPUT->get_generated_svg_for_id($group->id);

\core\session\manager::write_close(); // Unlock session during file serving.
send_file($svg, 'group.svg', 60 * 60, 0, true, $forcedownload);

} else {
send_file_not_found();
}
Expand Down

0 comments on commit 9bb91ce

Please sign in to comment.