See Release Notes
Long Term Support Release
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 * Mock handler for site policies 19 * 20 * @package core_privacy 21 * @copyright 2018 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Mock handler for site policies 29 * 30 * @package core_privacy 31 * @copyright 2018 Marina Glancy 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class mock_sitepolicy_handler extends \core_privacy\local\sitepolicy\handler { 35 36 /** 37 * Returns URL to redirect user to when user needs to agree to site policy 38 * 39 * This is a regular interactive page for web users. It should have normal Moodle header/footers, it should 40 * allow user to view policies and accept them. 41 * 42 * @param bool $forguests 43 * @return moodle_url|null (returns null if site policy is not defined) 44 */ 45 public static function get_redirect_url($forguests = false) { 46 return 'http://example.com/policy.php'; 47 } 48 49 /** 50 * Returns URL of the site policy that needs to be displayed to the user (inside iframe or to use in WS such as mobile app) 51 * 52 * This page should not have any header/footer, it does not also have any buttons/checkboxes. The caller needs to implement 53 * the "Accept" button and call {@link self::accept()} on completion. 54 * 55 * @param bool $forguests 56 * @return moodle_url|null 57 */ 58 public static function get_embed_url($forguests = false) { 59 return 'http://example.com/view.htm'; 60 } 61 62 /** 63 * Accept site policy for the current user 64 * 65 * @return bool - false if sitepolicy not defined, user is not logged in or user has already agreed to site policy; 66 * true - if we have successfully marked the user as agreed to the site policy 67 */ 68 public static function accept() { 69 global $USER, $DB; 70 // Accepts policy on behalf of the current user. We set it to 2 here to check that this callback was called. 71 $USER->policyagreed = 2; 72 if (!isguestuser()) { 73 $DB->update_record('user', ['policyagreed' => 2, 'id' => $USER->id]); 74 } 75 return true; 76 } 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body