[FEATURE] Backend usergroup model and repository
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Domain / Model / BackendUserGroup.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Markus Günther <mail@markus-guenther.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * This model represents a backend usergroup.
29 *
30 * @author Markus Günther <mail@markus-guenther.de>
31 *
32 * @package Extbase
33 * @subpackage Domain\Model
34 *
35 * @scope prototype
36 * @entity
37 * @api
38 */
39 class Tx_Extbase_Domain_Model_BackendUserGroup extends Tx_Extbase_DomainObject_AbstractEntity {
40
41 const FILE_OPPERATIONS = 1;
42 const FILE_UNZIP = 2;
43 const DIRECTORY_OPPERATIONS = 4;
44 const DIRECTORY_COPY = 8;
45 const DIRECTORY_REMOVE_RECURSIVELY = 16;
46
47 /**
48 * @var string
49 * @validate notEmpty
50 */
51 protected $title = '';
52
53 /**
54 * @var string
55 */
56 protected $description = '';
57
58 /**
59 * @var Tx_Extbase_Persistence_ObjectStorage<Tx_Extbase_Domain_Model_BackendUserGroup>
60 */
61 protected $subGroups;
62
63 /**
64 * @var string
65 */
66 protected $modules = '';
67
68 /**
69 * @var string
70 */
71 protected $tablesListening = '';
72
73 /**
74 * @var string
75 */
76 protected $tablesModify = '';
77
78 /**
79 * @var string
80 */
81 protected $pageTypes = '';
82
83 /**
84 * @var string
85 */
86 protected $allowedExcludeFields = '';
87
88 /**
89 * @var string
90 */
91 protected $explicitlyAllowAndDeny = '';
92
93 /**
94 * @var string
95 */
96 protected $allowedLanguages = '';
97
98 /**
99 * @var boolean
100 */
101 protected $workspacePermission = FALSE;
102
103 /**
104 * @var string
105 */
106 protected $databaseMounts = '';
107
108 /**
109 * @var integer
110 */
111 protected $fileOperationPermissions = 0;
112
113 /**
114 * @var string
115 */
116 protected $lockToDomain = '';
117
118 /**
119 * @var boolean
120 */
121 protected $hideInList = FALSE;
122
123 /**
124 * @var string
125 */
126 protected $tsConfig = '';
127
128 /**
129 * Constructs this backend usergroup
130 */
131 public function __construct() {
132 $this->subGroups = new Tx_Extbase_Persistence_ObjectStorage();
133 }
134
135 /**
136 * Setter for title
137 *
138 * @param string $title
139 * @return void
140 */
141 public function setTitle($title) {
142 $this->title = $title;
143 }
144
145 /**
146 * Getter for title
147 *
148 * @return string
149 */
150 public function getTitle() {
151 return $this->title;
152 }
153
154 /**
155 * Setter for description
156 *
157 * @param string $description
158 * @return void
159 */
160 public function setDescription($description) {
161 $this->description = $description;
162 }
163
164 /**
165 * Getter for description
166 *
167 * @return string
168 */
169 public function getDescription() {
170 return $this->description;
171 }
172
173 /**
174 * Setter for the sub groups
175 *
176 * @param Tx_Extbase_Persistence_ObjectStorage $subGroups
177 * @return void
178 */
179 public function setSubGroups(Tx_Extbase_Persistence_ObjectStorage $subGroups) {
180 $this->subGroups = $subGroups;
181 }
182
183 /**
184 * Adds a sub group to this backend user group
185 *
186 * @param Tx_Extbase_Domain_Model_BackendUserGroup $beGroup
187 * @return void
188 */
189 public function addSubGroup(Tx_Extbase_Domain_Model_BackendUserGroup $beGroup) {
190 $this->subGroups->attach($beGroup);
191 }
192
193 /**
194 * Removes sub group from this backend user group
195 *
196 * @param Tx_Extbase_Domain_Model_BackendUserGroup $groupToDelete
197 * @return void
198 */
199 public function removeSubGroup(Tx_Extbase_Domain_Model_BackendUserGroup $groupToDelete) {
200 $this->subGroups->detach($groupToDelete);
201 }
202
203 /**
204 * Remove all sub groups from this backend user group
205 *
206 * @return void
207 */
208 public function removeAllSubGroups() {
209 $subGroups = clone $this->subGroups;
210 $this->subGroups->removeAll($subGroups);
211 }
212
213 /**
214 * Getter of sub groups
215 *
216 * @return Tx_Extbase_Persistence_ObjectStorage
217 */
218 public function getSubGroups() {
219 return $this->subGroups;
220 }
221
222 /**
223 * Setter for modules
224 *
225 * @param string $modules
226 * @return void
227 */
228 public function setModules($modules) {
229 $this->modules = $modules;
230 }
231
232 /**
233 * Getter for modules
234 *
235 * @return string
236 */
237 public function getModules() {
238 return $this->modules;
239 }
240
241 /**
242 * Setter for tables listening
243 *
244 * @param string $tablesListening
245 * @return void
246 */
247 public function setTablesListening($tablesListening) {
248 $this->tablesListening = $tablesListening;
249 }
250
251 /**
252 * Getter for tables listening
253 *
254 * @return string
255 */
256 public function getTablesListening() {
257 return $this->tablesListening;
258 }
259
260 /**
261 * Setter for tables modify
262 *
263 * @param string $tablesModify
264 * @return void
265 */
266 public function setTablesModify($tablesModify) {
267 $this->tablesModify = $tablesModify;
268 }
269
270 /**
271 * Getter for tables modify
272 *
273 * @return string
274 */
275 public function getTablesModify() {
276 return $this->tablesModify;
277 }
278
279 /**
280 * Setter for page types
281 *
282 * @param string $pageTypes
283 * @return void
284 */
285 public function setPageTypes($pageTypes) {
286 $this->pageTypes = $pageTypes;
287 }
288
289 /**
290 * Getter for page types
291 *
292 * @return string
293 */
294 public function getPageTypes() {
295 return $this->pageTypes;
296 }
297
298 /**
299 * Setter for allowed exclude fields
300 *
301 * @param string $allowedExcludeFields
302 * @return void
303 */
304 public function setAllowedExcludeFields($allowedExcludeFields) {
305 $this->allowedExcludeFields = $allowedExcludeFields;
306 }
307
308 /**
309 * Getter for allowed exclude fields
310 *
311 * @return string
312 */
313 public function getAllowedExcludeFields() {
314 return $this->allowedExcludeFields;
315 }
316
317 /**
318 * Setter for explicitly allow and deny
319 *
320 * @param string $explicitlyAllowAndDeny
321 * @return void
322 */
323 public function setExplicitlyAllowAndDeny($explicitlyAllowAndDeny) {
324 $this->explicitlyAllowAndDeny = $explicitlyAllowAndDeny;
325 }
326
327 /**
328 * Getter for explicitly allow and deny
329 *
330 * @return string
331 */
332 public function getExplicitlyAllowAndDeny() {
333 return $this->explicitlyAllowAndDeny;
334 }
335
336 /**
337 * Setter for allowed languages
338 *
339 * @param string $allowedLanguages
340 * @return void
341 */
342 public function setAllowedLanguages($allowedLanguages) {
343 $this->allowedLanguages = $allowedLanguages;
344 }
345
346 /**
347 * Getter for allowed languages
348 *
349 * @return string
350 */
351 public function getAllowedLanguages() {
352 return $this->allowedLanguages;
353 }
354
355 /**
356 * Setter for workspace permission
357 *
358 * @param boolean $workspacePermission
359 * @return void
360 */
361 public function setWorkspacePermissions($workspacePermission) {
362 $this->workspacePermission = $workspacePermission;
363 }
364
365 /**
366 * Getter for workspace permission
367 *
368 * @return boolean
369 */
370 public function getWorkspacePermission() {
371 return $this->workspacePermission;
372 }
373
374 /**
375 * Setter for database mounts
376 *
377 * @param string $databaseMounts
378 * @return void
379 */
380 public function setDatabaseMounts($databaseMounts) {
381 $this->databaseMounts = $databaseMounts;
382 }
383
384 /**
385 * Getter for database mounts
386 *
387 * @return string
388 */
389 public function getDatabaseMounts() {
390 return $this->databaseMounts;
391 }
392
393 /**
394 * Getter for file operation permissions
395 *
396 * @param integer $fileOperationPermissions
397 * @return void
398 */
399 public function setFileOperationPermissions($fileOperationPermissions) {
400 $this->fileOperationPermissions = $fileOperationPermissions;
401 }
402
403 /**
404 * Getter for file operation permissions
405 *
406 * @return integer
407 */
408 public function getFileOperationPermissions() {
409 return $this->fileOperationPermissions;
410 }
411
412 /**
413 * Check if file operations like upload, copy, move, delete, rename, new and
414 * edit files is allowed.
415 *
416 * @return boolean
417 */
418 public function isFileOperationAllowed() {
419 return $this->isPermissionSet(self::FILE_OPPERATIONS);
420 }
421
422 /**
423 * Set the the bit for file operations are allowed.
424 *
425 * @param boolean
426 * @return void
427 */
428 public function setFileOperationAllowed($value) {
429 $this->setPermission(self::FILE_OPPERATIONS, $value);
430 }
431
432 /**
433 * Check if it is allowed to unzip files.
434 *
435 * @return boolean
436 */
437 public function isFileUnzipAllowed() {
438 return $this->isPermissionSet(self::FILE_UNZIP);
439 }
440
441 /**
442 * Set the the bit for unzip files are allowed.
443 *
444 * @param boolean
445 * @return void
446 */
447 public function setFileUnzipAllowed($value) {
448 $this->setPermission(self::FILE_UNZIP, $value);
449 }
450
451 /**
452 * Check if folder operations like move, delete, rename, and new are allowed.
453 *
454 * @return boolean
455 */
456 public function isDirectoryOperationAllowed() {
457 return $this->isPermissionSet(self::DIRECTORY_OPPERATIONS);
458 }
459
460 /**
461 * Set the the bit for directory operations are allowed.
462 *
463 * @param boolean
464 * @return void
465 */
466 public function setDirectoryOperationAllowed($value) {
467 $this->setPermission(self::DIRECTORY_OPPERATIONS, $value);
468 }
469
470 /**
471 * Check if it is allowed to copy folders.
472 *
473 * @return boolean
474 */
475 public function isDirectoryCopyAllowed() {
476 return $this->isPermissionSet(self::DIRECTORY_COPY);
477 }
478
479 /**
480 * Set the the bit for copy directories.
481 *
482 * @param boolean
483 * @return void
484 */
485 public function setDirectoryCopyAllowed($value) {
486 $this->setPermission(self::DIRECTORY_COPY, $value);
487 }
488
489 /**
490 * Check if it is allowed to remove folders recursively.
491 *
492 * @return boolean
493 */
494 public function isDirectoryRemoveRecursivelyAllowed() {
495 return $this->isPermissionSet(self::DIRECTORY_REMOVE_RECURSIVELY);
496 }
497
498 /**
499 * Set the the bit for remove directories recursively.
500 *
501 * @param boolean
502 * @return void
503 */
504 public function setDirectoryRemoveRecursivelyAllowed($value) {
505 $this->setPermission(self::DIRECTORY_REMOVE_RECURSIVELY, $value);
506 }
507
508 /**
509 * Setter for lock to domain
510 *
511 * @param string $lockToDomain
512 * @return void
513 */
514 public function setLockToDomain($lockToDomain) {
515 $this->lockToDomain = $lockToDomain;
516 }
517
518 /**
519 * Getter for lock to domain
520 * @return string
521 */
522 public function getLockToDomain() {
523 return $this->lockToDomain;
524 }
525
526 /**
527 * Setter for hide in list
528 *
529 * @param boolean $hideInList
530 * @return void
531 */
532 public function setHideInList($hideInList) {
533 $this->hideInList = $hideInList;
534 }
535
536 /**
537 * Getter for hide in list
538 *
539 * @return boolean
540 */
541 public function getHideInList() {
542 return $this->hideInList;
543 }
544
545 /**
546 * Setter for ts config
547 *
548 * @param string $tsConfig
549 */
550 public function setTsConfig($tsConfig) {
551 $this->tsConfig = $tsConfig;
552 }
553
554 /**
555 * Getter for ts config
556 *
557 * @return string
558 */
559 public function getTsConfig() {
560 return $this->tsConfig;
561 }
562
563 /**
564 * Helper method for checking the permissions bitwise.
565 *
566 * @param integer $permission
567 * @return boolean
568 */
569 protected function isPermissionSet($permission) {
570 return (($this->fileOperationPermissions & $permission) == $permission);
571 }
572
573 /**
574 * Helper method for settung permissions bitwise.
575 *
576 * @param integer $permission
577 * @param boolean $value
578 * @return void
579 */
580 protected function setPermission($permission, $value) {
581 if($value) {
582 $this->fileOperationPermissions |= $permission;
583 } else {
584 $this->fileOperationPermissions &= ~$permission;
585 }
586 }
587 }
588 ?>