Acl::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Deck\Db;
25
26
class Acl extends RelationalEntity {
27
28
	const PERMISSION_READ = 0;
29
	const PERMISSION_EDIT = 1;
30
	const PERMISSION_SHARE = 2;
31
	const PERMISSION_MANAGE = 3;
32
33
	const PERMISSION_TYPE_USER = 0;
34
	const PERMISSION_TYPE_GROUP = 1;
35
	const PERMISSION_TYPE_CIRCLE = 7;
36
37
	protected $participant;
38
	protected $type;
39
	protected $boardId;
40
	protected $permissionEdit = false;
41
	protected $permissionShare = false;
42
	protected $permissionManage = false;
43
	protected $owner = false;
44
45
	public function __construct() {
46
		$this->addType('id', 'integer');
47
		$this->addType('boardId', 'integer');
48
		$this->addType('permissionEdit', 'boolean');
49
		$this->addType('permissionShare', 'boolean');
50
		$this->addType('permissionManage', 'boolean');
51
		$this->addType('type', 'integer');
52
		$this->addType('owner', 'boolean');
53
		$this->addRelation('owner');
54
		$this->addResolvable('participant');
55
	}
56
57
	public function getPermission($permission) {
58
		switch ($permission) {
59
			case self::PERMISSION_READ:
60
				return true;
61
			case self::PERMISSION_EDIT:
62
				return $this->getPermissionEdit();
63
			case self::PERMISSION_SHARE:
64
				return $this->getPermissionShare();
65
			case self::PERMISSION_MANAGE:
66
				return $this->getPermissionManage();
67
		}
68
		return false;
69
	}
70
71
}