1 | <?php |
||
67 | class User { |
||
68 | use |
||
69 | Accessor, |
||
70 | Singleton, |
||
71 | User_data, |
||
72 | User_group, |
||
73 | User_management, |
||
74 | User_permission, |
||
75 | User_profile; |
||
76 | /** |
||
77 | * Id of system guest user |
||
78 | */ |
||
79 | const GUEST_ID = 1; |
||
80 | /** |
||
81 | * Id of first, primary system administrator |
||
82 | */ |
||
83 | const ROOT_ID = 2; |
||
84 | /** |
||
85 | * Id of system group for administrators |
||
86 | */ |
||
87 | const ADMIN_GROUP_ID = 1; |
||
88 | /** |
||
89 | * Id of system group for users |
||
90 | */ |
||
91 | const USER_GROUP_ID = 2; |
||
92 | /** |
||
93 | * Status of active user |
||
94 | */ |
||
95 | const STATUS_ACTIVE = 1; |
||
96 | /** |
||
97 | * Status of inactive user |
||
98 | */ |
||
99 | const STATUS_INACTIVE = 0; |
||
100 | /** |
||
101 | * Status of not activated user |
||
102 | */ |
||
103 | const STATUS_NOT_ACTIVATED = -1; |
||
104 | /** |
||
105 | * @var Cache\Prefix |
||
106 | */ |
||
107 | protected $cache; |
||
108 | /** |
||
109 | * Returns database index |
||
110 | * |
||
111 | * @return int |
||
112 | */ |
||
113 | 12 | protected function cdb () { |
|
126 | /** |
||
127 | * Check number of sign in attempts (is used by system) |
||
128 | * |
||
129 | * @param string $login_hash Hash (sha224) from login (hash from lowercase string) |
||
130 | * |
||
131 | * @return int Number of attempts |
||
1 ignored issue
–
show
|
|||
132 | */ |
||
133 | function get_sign_in_attempts_count ($login_hash) { |
||
151 | /** |
||
152 | * Process sign in result (is used by system) |
||
153 | * |
||
154 | * @param bool $success |
||
155 | * @param string $login_hash Hash (sha224) from login (hash from lowercase string) |
||
156 | */ |
||
157 | 2 | function sign_in_result ($success, $login_hash) { |
|
196 | /** |
||
197 | * Get data item of current user |
||
198 | * |
||
199 | * @param string|string[] $item |
||
200 | * |
||
201 | * @return false|int|mixed[]|string|User\Properties If <i>$item</i> is integer - cs\User\Properties object will be returned |
||
202 | */ |
||
203 | 10 | function __get ($item) { |
|
204 | 10 | if ($item == 'id') { |
|
205 | 10 | return Session::instance()->get_user(); |
|
206 | } |
||
207 | 2 | return $this->get($item); |
|
208 | } |
||
209 | /** |
||
210 | * Set data item of current user |
||
211 | * |
||
212 | * @param array|int|string $item Item-value array may be specified for setting several items at once |
||
213 | * @param mixed|null $value |
||
214 | * |
||
215 | * @return bool |
||
1 ignored issue
–
show
|
|||
216 | */ |
||
217 | function __set ($item, $value = null) { |
||
220 | /** |
||
221 | * Is admin |
||
222 | * |
||
223 | * Proxy to \cs\Session::instance()->admin() for convenience |
||
224 | * |
||
225 | * @return bool |
||
226 | */ |
||
227 | 4 | function admin () { |
|
230 | /** |
||
231 | * Is user |
||
232 | * |
||
233 | * Proxy to \cs\Session::instance()->user() for convenience |
||
234 | * |
||
235 | * @return bool |
||
236 | */ |
||
237 | function user () { |
||
240 | /** |
||
241 | * Is guest |
||
242 | * |
||
243 | * Proxy to \cs\Session::instance()->guest() for convenience |
||
244 | * |
||
245 | * @return bool |
||
246 | */ |
||
247 | 4 | function guest () { |
|
250 | } |
||
251 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.