Differences Between: [Versions 310 and 311] [Versions 311 and 402] [Versions 311 and 403]
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. 13 // 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/>. 16 17 /** 18 * Render a page containing a simple form which reposts to self via JS. 19 * 20 * The purpose of this form is to resend a cross-site request to self, which allows the browsers to include the Moodle 21 * session cookie alongside the original POST data, allowing LTI flows to function despite browsers blocking 22 * cross-site cookies. 23 * 24 * @copyright 2021 Cengage 25 * @package mod_lti 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 namespace mod_lti\output; 29 30 defined('MOODLE_INTERNAL') || die; 31 32 require_once($CFG->dirroot.'/mod/lti/locallib.php'); 33 34 use renderable; 35 use templatable; 36 use renderer_base; 37 use stdClass; 38 39 /** 40 * Render a page containing a simple form which reposts to self via JS. 41 * 42 * The purpose of this form is to resend a cross-site request to self, which allows the browsers to include the Moodle 43 * session cookie alongside the original POST data, allowing LTI flows to function despite browsers blocking 44 * cross-site cookies. 45 * 46 * @copyright 2021 Cengage 47 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 48 */ 49 class repost_crosssite_page implements renderable, templatable { 50 51 /** 52 * Constructor 53 * 54 * @param string $url moodle URL to repost to 55 * @param array $post the POST params to be re-posted 56 */ 57 public function __construct(string $url, array $post) { 58 $this->params = array_map(function($k) use ($post) { 59 return ["key" => $k, "value" => $post[$k]]; 60 }, array_keys($post)); 61 $this->url = $url; 62 } 63 64 /** 65 * Export this data so it can be used as the context for a mustache template. 66 * 67 * @param renderer_base $output The renderer 68 * @return stdClass Data to be used by the template 69 */ 70 public function export_for_template(renderer_base $output) { 71 $renderdata = new stdClass(); 72 $renderdata->url = $this->url; 73 $renderdata->params = $this->params; 74 return $renderdata; 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body