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 * Provides the {@link tool_policy\policy_version} persistent. 19 * 20 * @package tool_policy 21 * @copyright 2018 Sara Arjona (sara@moodle.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace tool_policy; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use core\persistent; 30 31 /** 32 * Persistent model representing a single policy document version. 33 * 34 * @copyright 2018 Sara Arjona (sara@moodle.com) 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class policy_version extends persistent { 38 39 /** @var string Table name this persistent is mapped to. */ 40 const TABLE = 'tool_policy_versions'; 41 42 /** @var int Site policy document. */ 43 const TYPE_SITE = 0; 44 45 /** @var int Privacy policy document. */ 46 const TYPE_PRIVACY = 1; 47 48 /** @var int Third party policy document. */ 49 const TYPE_THIRD_PARTY = 2; 50 51 /** @var int Other policy document. */ 52 const TYPE_OTHER = 99; 53 54 /** @var int Policy applies to all users. */ 55 const AUDIENCE_ALL = 0; 56 57 /** @var int Policy applies to logged in users only. */ 58 const AUDIENCE_LOGGEDIN = 1; 59 60 /** @var int Policy applies to guests only. */ 61 const AUDIENCE_GUESTS = 2; 62 63 /** @var int Policy version is a draft. */ 64 const STATUS_DRAFT = 0; 65 66 /** @var int Policy version is the active one. */ 67 const STATUS_ACTIVE = 1; 68 69 /** @var int Policy version has been archived. */ 70 const STATUS_ARCHIVED = 2; 71 72 /** @var int Policy to be accepted together with others on the consent page. */ 73 const AGREEMENTSTYLE_CONSENTPAGE = 0; 74 75 /** @var int Policy to be accepted on its own page before reaching the consent page. */ 76 const AGREEMENTSTYLE_OWNPAGE = 1; 77 78 /** @var int Users must agree to the policy in order to use the site. */ 79 const AGREEMENT_COMPULSORY = 0; 80 81 /** @var int Users may or may not agree to the policy. */ 82 const AGREEMENT_OPTIONAL = 1; 83 84 /** 85 * Return the definition of the properties of this model. 86 * 87 * @return array 88 */ 89 protected static function define_properties() { 90 return [ 91 'name' => [ 92 'type' => PARAM_TEXT, 93 'default' => '', 94 ], 95 'type' => [ 96 'type' => PARAM_INT, 97 'choices' => [ 98 self::TYPE_SITE, 99 self::TYPE_PRIVACY, 100 self::TYPE_THIRD_PARTY, 101 self::TYPE_OTHER, 102 ], 103 'default' => self::TYPE_SITE, 104 ], 105 'audience' => [ 106 'type' => PARAM_INT, 107 'choices' => [ 108 self::AUDIENCE_ALL, 109 self::AUDIENCE_LOGGEDIN, 110 self::AUDIENCE_GUESTS, 111 ], 112 'default' => self::AUDIENCE_ALL, 113 ], 114 'archived' => [ 115 'type' => PARAM_BOOL, 116 'default' => false, 117 ], 118 'policyid' => [ 119 'type' => PARAM_INT, 120 ], 121 'agreementstyle' => [ 122 'type' => PARAM_INT, 123 'choices' => [ 124 self::AGREEMENTSTYLE_CONSENTPAGE, 125 self::AGREEMENTSTYLE_OWNPAGE, 126 ], 127 'default' => self::AGREEMENTSTYLE_CONSENTPAGE, 128 ], 129 'optional' => [ 130 'type' => PARAM_INT, 131 'choices' => [ 132 self::AGREEMENT_OPTIONAL, 133 self::AGREEMENT_COMPULSORY, 134 ], 135 'default' => self::AGREEMENT_COMPULSORY, 136 ], 137 'revision' => [ 138 'type' => PARAM_TEXT, 139 'default' => '', 140 ], 141 'summary' => [ 142 'type' => PARAM_RAW, 143 'default' => '', 144 ], 145 'summaryformat' => [ 146 'type' => PARAM_INT, 147 'default' => FORMAT_HTML, 148 'choices' => [ 149 FORMAT_PLAIN, 150 FORMAT_HTML, 151 FORMAT_MOODLE, 152 FORMAT_MARKDOWN, 153 ], 154 ], 155 'content' => [ 156 'type' => PARAM_RAW, 157 'default' => '', 158 ], 159 'contentformat' => [ 160 'type' => PARAM_INT, 161 'default' => FORMAT_HTML, 162 'choices' => [ 163 FORMAT_PLAIN, 164 FORMAT_HTML, 165 FORMAT_MOODLE, 166 FORMAT_MARKDOWN, 167 ], 168 ], 169 ]; 170 } 171 172 /** 173 * Hook to execute after an update. 174 * 175 * @param bool $result Whether or not the update was successful (but it always is) 176 */ 177 protected function after_update($result) { 178 179 $optcache = \cache::make('tool_policy', 'policy_optional'); 180 $optcache->delete($this->raw_get('id')); 181 } 182 183 /** 184 * Hook to execute after an update. 185 * 186 * @param bool $result Whether or not the update was successful (but it always is) 187 */ 188 protected function after_delete($result) { 189 190 $optcache = \cache::make('tool_policy', 'policy_optional'); 191 $optcache->delete($this->raw_get('id')); 192 } 193 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body