-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathConstants.php
More file actions
268 lines (232 loc) Β· 6.92 KB
/
Constants.php
File metadata and controls
268 lines (232 loc) Β· 6.92 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Forms;
use OCP\Share\IShare;
class Constants {
/**
* Used AppConfig Keys
*/
public const CONFIG_KEY_ALLOWPERMITALL = 'allowPermitAll';
public const CONFIG_KEY_ALLOWPUBLICLINK = 'allowPublicLink';
public const CONFIG_KEY_ALLOWSHOWTOALL = 'allowShowToAll';
public const CONFIG_KEY_CREATIONALLOWEDGROUPS = 'creationAllowedGroups';
public const CONFIG_KEY_RESTRICTCREATION = 'restrictCreation';
public const CONFIG_KEYS = [
self::CONFIG_KEY_ALLOWPERMITALL,
self::CONFIG_KEY_ALLOWPUBLICLINK,
self::CONFIG_KEY_ALLOWSHOWTOALL,
self::CONFIG_KEY_CREATIONALLOWEDGROUPS,
self::CONFIG_KEY_RESTRICTCREATION
];
/**
* Maximum String lengths, the database is set to store.
*/
public const MAX_STRING_LENGTHS = [
'formTitle' => 256,
'formDescription' => 8192,
'submissionMessage' => 2048,
'questionText' => 2048,
'questionDescription' => 4096,
'optionText' => 1024,
'answerText' => 4096,
];
/**
* State flags of a form
*/
public const FORM_STATE_ACTIVE = 0;
public const FORM_STATE_CLOSED = 1;
public const FORM_STATE_ARCHIVED = 2;
/**
* Access flags of a form
*/
public const FORM_ACCESS_NOPUBLICSHARE = 0;
public const FORM_ACCESS_PERMITALLUSERS = 1;
public const FORM_ACCESS_SHOWTOALLUSERS = 2;
/** @deprecated 5.0.0 still needed for Migrations */
public const FORM_ACCESS_LEGACYLINK = 3;
public const FORM_ACCESS_ARRAY_PERMIT = [
self::FORM_ACCESS_PERMITALLUSERS,
];
public const FORM_ACCESS_ARRAY_SHOWN = [
self::FORM_ACCESS_SHOWTOALLUSERS,
];
/**
* !! Keep in sync with src/models/AnswerTypes.js !!
*/
// Available AnswerTypes
public const ANSWER_TYPE_COLOR = 'color';
public const ANSWER_TYPE_DATE = 'date';
public const ANSWER_TYPE_DATETIME = 'datetime';
public const ANSWER_TYPE_DROPDOWN = 'dropdown';
public const ANSWER_TYPE_FILE = 'file';
public const ANSWER_TYPE_GRID = 'grid';
public const ANSWER_TYPE_LINEARSCALE = 'linearscale';
public const ANSWER_TYPE_LONG = 'long';
public const ANSWER_TYPE_MULTIPLE = 'multiple';
public const ANSWER_TYPE_MULTIPLEUNIQUE = 'multiple_unique';
public const ANSWER_TYPE_SECTION = 'section';
public const ANSWER_TYPE_SHORT = 'short';
public const ANSWER_TYPE_TIME = 'time';
public const ANSWER_GRID_TYPE_CHECKBOX = 'checkbox';
public const ANSWER_GRID_TYPE_NUMBER = 'number';
public const ANSWER_GRID_TYPE_RADIO = 'radio';
// All AnswerTypes
public const ANSWER_TYPES = [
self::ANSWER_TYPE_COLOR,
self::ANSWER_TYPE_DATE,
self::ANSWER_TYPE_DATETIME,
self::ANSWER_TYPE_DROPDOWN,
self::ANSWER_TYPE_FILE,
self::ANSWER_TYPE_GRID,
self::ANSWER_TYPE_LINEARSCALE,
self::ANSWER_TYPE_LONG,
self::ANSWER_TYPE_MULTIPLE,
self::ANSWER_TYPE_MULTIPLEUNIQUE,
self::ANSWER_TYPE_SECTION,
self::ANSWER_TYPE_SHORT,
self::ANSWER_TYPE_TIME,
];
// AnswerTypes, that need/have predefined Options
public const ANSWER_TYPES_PREDEFINED = [
self::ANSWER_TYPE_DROPDOWN,
self::ANSWER_TYPE_LINEARSCALE,
self::ANSWER_TYPE_MULTIPLE,
self::ANSWER_TYPE_MULTIPLEUNIQUE,
];
// AnswerTypes for date/time questions
public const ANSWER_TYPES_DATETIME = [
self::ANSWER_TYPE_DATE,
self::ANSWER_TYPE_DATETIME,
self::ANSWER_TYPE_TIME
];
// Formats for AnswerTypes date/datetime/time
public const ANSWER_PHPDATETIME_FORMAT = [
self::ANSWER_TYPE_DATE => 'Y-m-d',
self::ANSWER_TYPE_DATETIME => 'Y-m-d H:i',
self::ANSWER_TYPE_TIME => 'H:i'
];
/**
* !! Keep in sync with src/models/ValidationTypes.js !!
*/
// Allowed short input types
public const SHORT_INPUT_TYPES = [
'phone',
'email',
'regex',
'number'
];
// This are allowed extra settings
public const EXTRA_SETTINGS_DROPDOWN = [
'allowOtherAnswer' => ['boolean'],
'shuffleOptions' => ['boolean'],
];
public const EXTRA_SETTINGS_MULTIPLE = [
'allowOtherAnswer' => ['boolean'],
'optionsLimitMax' => ['integer'],
'optionsLimitMin' => ['integer'],
'shuffleOptions' => ['boolean'],
];
public const EXTRA_SETTINGS_SHORT = [
'validationType' => ['string'],
'validationRegex' => ['string'],
];
public const EXTRA_SETTINGS_FILE = [
'allowedFileTypes' => ['array'],
'allowedFileExtensions' => ['array'],
'maxAllowedFilesCount' => ['integer'],
'maxFileSize' => ['integer'],
];
public const EXTRA_SETTINGS_DATE = [
'dateMax' => ['integer', 'NULL'],
'dateMin' => ['integer', 'NULL'],
'dateRange' => ['boolean', 'NULL'],
];
public const EXTRA_SETTINGS_TIME = [
'timeMax' => ['string', 'NULL'],
'timeMin' => ['string', 'NULL'],
'timeRange' => ['boolean', 'NULL'],
];
// should be in sync with FileTypes.js
public const EXTRA_SETTINGS_ALLOWED_FILE_TYPES = [
'image',
'x-office/document',
'x-office/presentation',
'x-office/spreadsheet',
];
public const EXTRA_SETTINGS_LINEARSCALE = [
'optionsLowest' => ['integer', 'NULL'],
'optionsHighest' => ['integer', 'NULL'],
'optionsLabelLowest' => ['string', 'NULL'],
'optionsLabelHighest' => ['string', 'NULL'],
];
public const EXTRA_SETTINGS_GRID = [
'columns' => ['array'],
'questionType' => ['string'],
'rows' => ['array'],
];
public const EXTRA_SETTINGS_GRID_QUESTION_TYPE = [
self::ANSWER_GRID_TYPE_CHECKBOX,
self::ANSWER_GRID_TYPE_NUMBER,
self::ANSWER_GRID_TYPE_RADIO,
];
public const FILENAME_INVALID_CHARS = [
"\n",
'/',
'\\',
':',
'*',
'?',
'"',
'<',
'>',
'|',
];
/**
* !! Keep in sync with src/mixins/ShareTypes.js !!
*/
public const SHARE_TYPES_USED = [
IShare::TYPE_CIRCLE,
IShare::TYPE_GROUP,
IShare::TYPE_LINK,
IShare::TYPE_USER,
];
/**
* !! Keep in sync with src/mixins/PermissionTypes.js !!
* Permission values equal the route names, thus making it easy on frontend to evaluate.
*/
// Define Form Permissions
public const PERMISSION_EDIT = 'edit';
public const PERMISSION_RESULTS = 'results';
public const PERMISSION_RESULTS_DELETE = 'results_delete';
public const PERMISSION_SUBMIT = 'submit';
/** Special internal permissions to allow embedding a form (share) into external websites */
public const PERMISSION_EMBED = 'embed';
public const PERMISSION_ALL = [
self::PERMISSION_EDIT,
self::PERMISSION_EMBED,
self::PERMISSION_RESULTS,
self::PERMISSION_RESULTS_DELETE,
self::PERMISSION_SUBMIT,
];
/**
* !! Keep in sync with src/FormsEmptyContent.vue !!
* InitialStates for emptyContent to render as...
*/
public const EMPTY_EXPIRED = 'expired';
public const EMPTY_NOTFOUND = 'notfound';
/**
* Constants related to extra settings for questions
*/
public const QUESTION_EXTRASETTINGS_OTHER_PREFIX = 'system-other-answer:';
public const SUPPORTED_EXPORT_FORMATS = [
'csv' => 'text/csv',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
];
public const DEFAULT_FILE_FORMAT = 'csv';
public const UNSUBMITTED_FILES_FOLDER = self::FILES_FOLDER . '/unsubmitted';
public const FILES_FOLDER = 'Forms';
}