Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 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 /** @var array POST params. */ 52 protected $params; 53 54 /** @var string URL to repost to. */ 55 protected string $url; 56 57 /** 58 * Constructor 59 * 60 * @param string $url moodle URL to repost to 61 * @param array $post the POST params to be re-posted 62 */ 63 public function __construct(string $url, array $post) { 64 $this->params = array_map(function($k) use ($post) { 65 return ["key" => $k, "value" => $post[$k]]; 66 }, array_keys($post)); 67 $this->url = $url; 68 } 69 70 /** 71 * Export this data so it can be used as the context for a mustache template. 72 * 73 * @param renderer_base $output The renderer 74 * @return stdClass Data to be used by the template 75 */ 76 public function export_for_template(renderer_base $output) { 77 $renderdata = new stdClass(); 78 $renderdata->url = $this->url; 79 $renderdata->params = $this->params; 80 return $renderdata; 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body