|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* BB's Zend Framework 2 Components |
|
4
|
|
|
* |
|
5
|
|
|
* AdminModule |
|
6
|
|
|
* |
|
7
|
|
|
* @package [MyApplication] |
|
8
|
|
|
* @package BB's Zend Framework 2 Components |
|
9
|
|
|
* @package AdminModule |
|
10
|
|
|
* @author Björn Bartels <[email protected]> |
|
11
|
|
|
* @link https://gitlab.bjoernbartels.earth/groups/zf2 |
|
12
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 |
|
13
|
|
|
* @copyright copyright (c) 2016 Björn Bartels <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Admin\Entity; |
|
17
|
|
|
|
|
18
|
|
|
use \ZfcUser\Entity\User as ZfcUser; |
|
|
|
|
|
|
19
|
|
|
use Zend\Crypt\Password\Bcrypt; |
|
20
|
|
|
|
|
21
|
|
|
class User extends ZfcUser |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* user's confirmation/activation token |
|
26
|
|
|
* |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $token; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* user's ACL role |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $aclrole; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* user's ID |
|
40
|
|
|
* |
|
41
|
|
|
* @var int |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $user_id; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Get ACL role. |
|
47
|
|
|
* |
|
48
|
|
|
* @return STRING |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getAclrole() |
|
51
|
|
|
{ |
|
52
|
|
|
if (empty($this->aclrole)) { |
|
53
|
|
|
$this->setAclrole('public'); |
|
54
|
|
|
} |
|
55
|
|
|
return $this->aclrole; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Set ACL role. |
|
60
|
|
|
* |
|
61
|
|
|
* @param STRING $aclrole |
|
62
|
|
|
* @return \Admin\Entity\User |
|
63
|
|
|
*/ |
|
64
|
|
|
public function setAclrole($aclrole) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->aclrole = $aclrole; |
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Get token string. |
|
72
|
|
|
* |
|
73
|
|
|
* @return STRING |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getToken() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->token; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Set token string. |
|
82
|
|
|
* |
|
83
|
|
|
* @param STRING $aclrole |
|
84
|
|
|
* @return \Admin\Entity\User |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setToken($token) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->token = $token; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get user-id string. |
|
94
|
|
|
* |
|
95
|
|
|
* @return STRING |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getUserId() |
|
98
|
|
|
{ |
|
99
|
|
|
if (null === $this->user_id) { |
|
100
|
|
|
$this->setUserId($this->getId()); |
|
101
|
|
|
} |
|
102
|
|
|
return $this->user_id; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Set user-id string. |
|
107
|
|
|
* |
|
108
|
|
|
* @param STRING $aclrole |
|
109
|
|
|
* @return \Admin\Entity\User |
|
110
|
|
|
*/ |
|
111
|
|
|
public function setUserId($user_id) |
|
112
|
|
|
{ |
|
113
|
|
|
$this->user_id = $user_id; |
|
114
|
|
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* set user's object property data |
|
121
|
|
|
* |
|
122
|
|
|
* @param array $data |
|
123
|
|
|
* @param boolean $forceEncryptPassword |
|
124
|
|
|
* @return \Admin\Entity\User |
|
125
|
|
|
*/ |
|
126
|
|
|
public function exchangeArray($data = array(), $forceEncryptPassword = false) |
|
127
|
|
|
{ |
|
128
|
|
|
if (isset($data['id']) && !empty($data["id"]) ) { |
|
129
|
|
|
$this->id = ($data['id']); |
|
|
|
|
|
|
130
|
|
|
$this->user_id = ($data['id']); |
|
131
|
|
|
} elseif (isset($data['user_id']) && !empty($data["user_id"]) ) { |
|
132
|
|
|
$this->id = ($data['user_id']); |
|
133
|
|
|
$this->user_id = ($data['user_id']); |
|
134
|
|
|
} |
|
135
|
|
|
$this->username = (isset($data['username'])) ? $data['username'] : $this->username; |
|
|
|
|
|
|
136
|
|
|
$this->email = (isset($data['email'])) ? $data['email'] : $this->email; |
|
|
|
|
|
|
137
|
|
|
if (isset($data['displayName']) ) { |
|
138
|
|
|
$this->display_name = $data['displayName']; |
|
|
|
|
|
|
139
|
|
|
$this->displayName = $data['displayName']; |
|
|
|
|
|
|
140
|
|
|
} elseif (isset($data['display_name']) ) { |
|
141
|
|
|
$this->display_name = $data['display_name']; |
|
142
|
|
|
$this->displayName = $data['display_name']; |
|
143
|
|
|
} |
|
144
|
|
|
if (isset($data["password"]) && $forceEncryptPassword ) { |
|
145
|
|
|
$bcrypt = new Bcrypt; |
|
146
|
|
|
$bcrypt->setCost(null); // @TODO $this->getUserService()->getOptions()->getPasswordCost()); |
|
147
|
|
|
$data["password"] = $bcrypt->create($data['password']); |
|
148
|
|
|
} |
|
149
|
|
|
$this->password = (isset($data['password'])) ? $data['password'] : $this->password; |
|
|
|
|
|
|
150
|
|
|
$this->state = (isset($data['state'])) ? $data['state'] : $this->state; |
|
|
|
|
|
|
151
|
|
|
$this->aclrole = (isset($data['aclrole'])) ? $data['aclrole'] : $this->aclrole; |
|
152
|
|
|
$this->token = (isset($data['token'])) ? $data['token'] : $this->token; |
|
153
|
|
|
|
|
154
|
|
|
return $this; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* get copy of user's object properties in an assosiative array |
|
159
|
|
|
* |
|
160
|
|
|
* @return array |
|
161
|
|
|
*/ |
|
162
|
|
|
public function __getArrayCopy() |
|
163
|
|
|
{ |
|
164
|
|
|
return array( |
|
165
|
|
|
"id" => $this->getId(), |
|
166
|
|
|
"user_id" => $this->getUserId(), |
|
167
|
|
|
"username" => $this->getUsername(), |
|
168
|
|
|
"email" => $this->getEmail(), |
|
169
|
|
|
"display_name" => $this->getDisplayName(), |
|
170
|
|
|
"displayName" => $this->getDisplayName(), |
|
171
|
|
|
"password" => $this->getPassword(), |
|
172
|
|
|
"state" => $this->getState(), |
|
173
|
|
|
"aclrole" => $this->getAclrole(), |
|
174
|
|
|
"token" => $this->getToken(), |
|
175
|
|
|
); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* get copy of user's object properties in an assosiative array |
|
180
|
|
|
* |
|
181
|
|
|
* @return array |
|
182
|
|
|
* / |
|
183
|
|
|
public function getArrayCopy() |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->__getArrayCopy(); |
|
186
|
|
|
} // collides with some magic "__get" method in ZfcUser parent ?! |
|
187
|
|
|
*/ |
|
188
|
|
|
|
|
189
|
|
|
} |
|
190
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths