mirrored from git://git.moodle.org/moodle.git
/
policy_version.php
157 lines (138 loc) · 4.7 KB
/
policy_version.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the {@link tool_policy\policy_version} persistent.
*
* @package tool_policy
* @copyright 2018 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_policy;
defined('MOODLE_INTERNAL') || die();
use core\persistent;
/**
* Persistent model representing a single policy document version.
*
* @copyright 2018 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class policy_version extends persistent {
/** @var string Table name this persistent is mapped to. */
const TABLE = 'tool_policy_versions';
/** @var int Site policy document. */
const TYPE_SITE = 0;
/** @var int Privacy policy document. */
const TYPE_PRIVACY = 1;
/** @var int Third party policy document. */
const TYPE_THIRD_PARTY = 2;
/** @var int Other policy document. */
const TYPE_OTHER = 99;
/** @var int Policy applies to all users. */
const AUDIENCE_ALL = 0;
/** @var int Policy applies to logged in users only. */
const AUDIENCE_LOGGEDIN = 1;
/** @var int Policy applies to guests only. */
const AUDIENCE_GUESTS = 2;
/** @var int Policy version is a draft. */
const STATUS_DRAFT = 0;
/** @var int Policy version is the active one. */
const STATUS_ACTIVE = 1;
/** @var int Policy version has been archived. */
const STATUS_ARCHIVED = 2;
/** @var int Policy to be accepted together with others on the consent page. */
const AGREEMENTSTYLE_CONSENTPAGE = 0;
/** @var int Policy to be accepted on its own page before reaching the consent page. */
const AGREEMENTSTYLE_OWNPAGE = 1;
/**
* Return the definition of the properties of this model.
*
* @return array
*/
protected static function define_properties() {
return [
'name' => [
'type' => PARAM_TEXT,
'default' => '',
],
'type' => [
'type' => PARAM_INT,
'choices' => [
self::TYPE_SITE,
self::TYPE_PRIVACY,
self::TYPE_THIRD_PARTY,
self::TYPE_OTHER,
],
'default' => self::TYPE_SITE,
],
'audience' => [
'type' => PARAM_INT,
'choices' => [
self::AUDIENCE_ALL,
self::AUDIENCE_LOGGEDIN,
self::AUDIENCE_GUESTS,
],
'default' => self::AUDIENCE_ALL,
],
'archived' => [
'type' => PARAM_BOOL,
'default' => false,
],
'policyid' => [
'type' => PARAM_INT,
],
'agreementstyle' => [
'type' => PARAM_INT,
'choices' => [
self::AGREEMENTSTYLE_CONSENTPAGE,
self::AGREEMENTSTYLE_OWNPAGE,
],
'default' => self::AGREEMENTSTYLE_CONSENTPAGE,
],
'revision' => [
'type' => PARAM_TEXT,
'default' => '',
],
'summary' => [
'type' => PARAM_RAW,
'default' => '',
],
'summaryformat' => [
'type' => PARAM_INT,
'default' => FORMAT_HTML,
'choices' => [
FORMAT_PLAIN,
FORMAT_HTML,
FORMAT_MOODLE,
FORMAT_MARKDOWN,
],
],
'content' => [
'type' => PARAM_RAW,
'default' => '',
],
'contentformat' => [
'type' => PARAM_INT,
'default' => FORMAT_HTML,
'choices' => [
FORMAT_PLAIN,
FORMAT_HTML,
FORMAT_MOODLE,
FORMAT_MARKDOWN,
],
],
];
}
}