MDL-73708 course: Return geo pattern generated course images via WS

This commit is contained in:
Juan Leyva
2023-03-22 17:39:07 -03:00
committed by Rodrigo Mady
parent 794f107e88
commit 27be439eb7
10 changed files with 143 additions and 15 deletions
+13 -1
View File
@@ -4364,7 +4364,7 @@ class curl_cache {
* @todo MDL-31088 file serving improments
*/
function file_pluginfile($relativepath, $forcedownload, $preview = null, $offline = false, $embed = false) {
global $DB, $CFG, $USER;
global $DB, $CFG, $USER, $OUTPUT;
// relative path must start with '/'
if (!$relativepath) {
throw new \moodle_exception('invalidargorconf');
@@ -4917,6 +4917,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, $forcedownload, $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($course->id);
\core\session\manager::write_close(); // Unlock session during file serving.
send_file($svg, 'course.svg', 60 * 60, 0, true, $forcedownload);
} else {
send_file_not_found();
}