1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* part-db version 0.1 |
5
|
|
|
* Copyright (C) 2005 Christoph Lechner |
6
|
|
|
* http://www.cl-projects.de/ |
7
|
|
|
* |
8
|
|
|
* part-db version 0.2+ |
9
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
10
|
|
|
* http://code.google.com/p/part-db/ |
11
|
|
|
* |
12
|
|
|
* Part-DB Version 0.4+ |
13
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
14
|
|
|
* https://github.com/jbtronics |
15
|
|
|
* |
16
|
|
|
* This program is free software; you can redistribute it and/or |
17
|
|
|
* modify it under the terms of the GNU General Public License |
18
|
|
|
* as published by the Free Software Foundation; either version 2 |
19
|
|
|
* of the License, or (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* This program is distributed in the hope that it will be useful, |
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24
|
|
|
* GNU General Public License for more details. |
25
|
|
|
* |
26
|
|
|
* You should have received a copy of the GNU General Public License |
27
|
|
|
* along with this program; if not, write to the Free Software |
28
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
namespace App\Security\Annotations; |
33
|
|
|
|
34
|
|
|
use Doctrine\Common\Annotations\Annotation; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @Annotation |
38
|
|
|
* |
39
|
|
|
* @Annotation\Target("PROPERTY") |
40
|
|
|
* |
41
|
|
|
* With these annotation you can restrict the access to certain coloumns in entities. |
42
|
|
|
* The entity which should use this class has to use ElementListener as EntityListener. |
43
|
|
|
* |
44
|
|
|
* @package App\Annotations |
45
|
|
|
*/ |
46
|
|
|
class ColumnSecurity |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* @var string The name of the edit permission |
50
|
|
|
*/ |
51
|
|
|
public $edit = "edit"; |
52
|
|
|
/** |
53
|
|
|
* @var string The name of the read permission |
54
|
|
|
*/ |
55
|
|
|
public $read = "read"; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string A prefix for all permission names (e.g. $prefix.edit, useful for Parts) |
59
|
|
|
*/ |
60
|
|
|
public $prefix = ''; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string The placeholder that should be used, when the access to the property is denied. |
64
|
|
|
*/ |
65
|
|
|
public $placeholder = null; |
66
|
|
|
|
67
|
|
|
public $subject = null; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var string The name of the property. This is used to determine the default placeholder. |
71
|
|
|
* @Annotation\Enum({"integer", "string", "object"}) |
72
|
|
|
*/ |
73
|
|
|
public $type = 'string'; |
74
|
|
|
|
75
|
|
|
public function getReadOperationName() : string |
76
|
|
|
{ |
77
|
|
|
if($this->prefix !== '') { |
78
|
|
|
return $this->prefix . '.' . $this->read; |
79
|
|
|
} |
80
|
|
|
return $this->read; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getEditOperationName() : string |
84
|
|
|
{ |
85
|
|
|
if($this->prefix !== '') { |
86
|
|
|
return $this->prefix . '.' . $this->edit; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
return $this->edit; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getPlaceholder() |
93
|
|
|
{ |
94
|
|
|
if($this->placeholder === null) |
95
|
|
|
{ |
96
|
|
|
switch($this->type) |
97
|
|
|
{ |
98
|
|
|
case 'integer': |
99
|
|
|
return 0; |
100
|
|
|
case 'string': |
101
|
|
|
return '???'; |
102
|
|
|
case 'object': |
103
|
|
|
return null; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return $this->placeholder; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
} |