@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @param string $directive ('start' or 'destroy') |
466 | 466 | * @param string $cookieName |
467 | - * @return modUsers |
|
467 | + * @return modManagers |
|
468 | 468 | * @author Raymond Irving |
469 | 469 | * @author Scotty Delicious |
470 | 470 | * |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | - * @param $cookieName |
|
534 | + * @param string $cookieName |
|
535 | 535 | * @param bool $remember |
536 | 536 | * @return $this |
537 | 537 | */ |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->close(); |
109 | 109 | $this->newDoc = false; |
110 | 110 | |
111 | - if (!$find = $this->findUser($id)) { |
|
111 | + if ( ! $find = $this->findUser($id)) { |
|
112 | 112 | $this->id = null; |
113 | 113 | } else { |
114 | 114 | $result = $this->query(" |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function set($key, $value) |
141 | 141 | { |
142 | - if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
142 | + if (is_scalar($value) && is_scalar($key) && ! empty($key)) { |
|
143 | 143 | switch ($key) { |
144 | 144 | case 'password': |
145 | 145 | $this->givenPassword = $value; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - if (!$this->checkUnique('manager_users', 'username')) { |
|
191 | + if ( ! $this->checkUnique('manager_users', 'username')) { |
|
192 | 192 | $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'), |
193 | 193 | true) . '</pre>'; |
194 | 194 | |
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | - if (!$this->checkUnique('user_attributes', 'email', 'internalKey')) { |
|
198 | + if ( ! $this->checkUnique('user_attributes', 'email', 'internalKey')) { |
|
199 | 199 | $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>'; |
200 | 200 | |
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - if(!$this->get('role')) { |
|
204 | + if ( ! $this->get('role')) { |
|
205 | 205 | $this->log['UniqueEmail'] = 'Wrong manager role <pre>' . print_r($this->get('role'), true) . '</pre>'; |
206 | 206 | } |
207 | 207 | |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | $fld = $this->toArray(); |
210 | 210 | foreach ($this->default_field['user'] as $key => $value) { |
211 | 211 | $tmp = $this->get($key); |
212 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
212 | + if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) { |
|
213 | 213 | $this->field[$key] = $value; |
214 | 214 | } |
215 | 215 | $this->Uset($key, 'user'); |
216 | 216 | unset($fld[$key]); |
217 | 217 | } |
218 | - if (!empty($this->set['user'])) { |
|
218 | + if ( ! empty($this->set['user'])) { |
|
219 | 219 | if ($this->newDoc) { |
220 | 220 | $SQL = "INSERT into {$this->makeTable('manager_users')} SET " . implode(', ', $this->set['user']); |
221 | 221 | } else { |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | |
232 | 232 | foreach ($this->default_field['attribute'] as $key => $value) { |
233 | 233 | $tmp = $this->get($key); |
234 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
234 | + if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) { |
|
235 | 235 | $this->field[$key] = $value; |
236 | 236 | } |
237 | 237 | $this->Uset($key, 'attribute'); |
238 | 238 | unset($fld[$key]); |
239 | 239 | } |
240 | - if (!empty($this->set['attribute'])) { |
|
240 | + if ( ! empty($this->set['attribute'])) { |
|
241 | 241 | if ($this->newDoc) { |
242 | 242 | $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute'); |
243 | 243 | $SQL = "INSERT into {$this->makeTable('user_attributes')} SET " . implode(', ', |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | unset($fld['id']); |
252 | 252 | foreach ($fld as $key => $value) { |
253 | - if ($value == '' || !$this->isChanged($key)) { |
|
253 | + if ($value == '' || ! $this->isChanged($key)) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}'"); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | // TODO |
264 | - if (!$this->newDoc && $this->givenPassword) { |
|
264 | + if ( ! $this->newDoc && $this->givenPassword) { |
|
265 | 265 | $this->invokeEvent('OnManagerChangePassword', array( |
266 | 266 | 'userObj' => $this, |
267 | 267 | 'userid' => $this->id, |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $b = $tmp->get('blocked'); |
368 | 368 | $bu = $tmp->get('blockeduntil'); |
369 | 369 | $ba = $tmp->get('blockedafter'); |
370 | - $flag = (($b && !$bu && !$ba) || ($bu && $now < $bu) || ($ba && $now > $ba)); |
|
370 | + $flag = (($b && ! $bu && ! $ba) || ($bu && $now < $bu) || ($ba && $now > $ba)); |
|
371 | 371 | unset($tmp); |
372 | 372 | |
373 | 373 | return $flag; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | $flag = $pluginFlag = false; |
391 | 391 | if ( |
392 | - (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id))) |
|
392 | + (null !== $tmp->getID()) && ( ! $blocker || ($blocker && ! $tmp->checkBlock($id))) |
|
393 | 393 | ) { |
394 | 394 | $_password = $tmp->get('password'); |
395 | 395 | $eventResult = $this->getInvokeEventResult('OnManagerAuthentication', array( |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | } else { |
407 | 407 | $pluginFlag = (bool)$eventResult; |
408 | 408 | } |
409 | - if (!$pluginFlag) { |
|
409 | + if ( ! $pluginFlag) { |
|
410 | 410 | $hashType = $this->getPasswordHashType($_password); |
411 | 411 | switch ($hashType) { |
412 | 412 | case 'phpass': |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | */ |
444 | 444 | public function logOut($cookieName = 'modx_remember_manager', $fire_events = null) |
445 | 445 | { |
446 | - if (!$uid = $this->modx->getLoginUserID('mgr')) { |
|
446 | + if ( ! $uid = $this->modx->getLoginUserID('mgr')) { |
|
447 | 447 | return; |
448 | 448 | } |
449 | 449 | $params = array( |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | */ |
538 | 538 | public function setAutoLoginCookie($cookieName, $remember = true) |
539 | 539 | { |
540 | - if (!empty($cookieName) && $this->getID()) { |
|
540 | + if ( ! empty($cookieName) && $this->getID()) { |
|
541 | 541 | $secure = $this->isSecure(); |
542 | 542 | $remember = is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember; |
543 | 543 | $cookieValue = $this->get('username'); |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | */ |
600 | 600 | public function setUserGroups($userID = 0, $groupIds = array()) |
601 | 601 | { |
602 | - if (!is_array($groupIds)) { |
|
602 | + if ( ! is_array($groupIds)) { |
|
603 | 603 | return $this; |
604 | 604 | } |
605 | 605 | if ($this->newDoc && $userID == 0) { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * Class modUsers |
6 | 6 | */ |
7 | -class modManagers extends MODxAPI |
|
8 | -{ |
|
7 | +class modManagers extends MODxAPI |
|
8 | +{ |
|
9 | 9 | /** |
10 | 10 | * @var array |
11 | 11 | */ |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @param bool $debug |
58 | 58 | * @throws Exception |
59 | 59 | */ |
60 | - public function __construct(DocumentParser $modx, $debug = false) |
|
61 | - { |
|
60 | + public function __construct(DocumentParser $modx, $debug = false) |
|
61 | + { |
|
62 | 62 | parent::__construct($modx, $debug); |
63 | 63 | $this->modx->loadExtension('phpass'); |
64 | 64 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param $key |
69 | 69 | * @return bool |
70 | 70 | */ |
71 | - public function issetField($key) |
|
72 | - { |
|
71 | + public function issetField($key) |
|
72 | + { |
|
73 | 73 | return (array_key_exists($key, $this->default_field['user']) || array_key_exists($key, |
74 | 74 | $this->default_field['attribute']) || in_array($key, $this->default_field['hidden'])); |
75 | 75 | } |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param string $data |
79 | 79 | * @return string|false |
80 | 80 | */ |
81 | - protected function findUser($data) |
|
82 | - { |
|
83 | - switch (true) { |
|
81 | + protected function findUser($data) |
|
82 | + { |
|
83 | + switch (true) { |
|
84 | 84 | case (is_int($data) || ((int)$data > 0 && (string)intval($data) === $data)): |
85 | 85 | $find = 'attribute.internalKey'; |
86 | 86 | break; |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param $id |
102 | 102 | * @return $this |
103 | 103 | */ |
104 | - public function edit($id) |
|
105 | - { |
|
104 | + public function edit($id) |
|
105 | + { |
|
106 | 106 | $id = is_scalar($id) ? trim($id) : ''; |
107 | - if ($this->getID() != $id) { |
|
107 | + if ($this->getID() != $id) { |
|
108 | 108 | $this->close(); |
109 | 109 | $this->newDoc = false; |
110 | 110 | |
111 | - if (!$find = $this->findUser($id)) { |
|
111 | + if (!$find = $this->findUser($id)) { |
|
112 | 112 | $this->id = null; |
113 | - } else { |
|
113 | + } else { |
|
114 | 114 | $result = $this->query(" |
115 | 115 | SELECT * from {$this->makeTable('user_attributes')} as attribute |
116 | 116 | LEFT JOIN {$this->makeTable('manager_users')} as user ON user.id=attribute.internalKey |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param $value |
138 | 138 | * @return $this |
139 | 139 | */ |
140 | - public function set($key, $value) |
|
141 | - { |
|
142 | - if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
143 | - switch ($key) { |
|
140 | + public function set($key, $value) |
|
141 | + { |
|
142 | + if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
143 | + switch ($key) { |
|
144 | 144 | case 'password': |
145 | 145 | $this->givenPassword = $value; |
146 | 146 | $value = $this->getPassword($value); |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param $pass |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public function getPassword($pass) |
|
164 | - { |
|
163 | + public function getPassword($pass) |
|
164 | + { |
|
165 | 165 | return $this->modx->phpass->HashPassword($pass); |
166 | 166 | } |
167 | 167 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @param string $name |
170 | 170 | * @return bool |
171 | 171 | */ |
172 | - public function hasPermission($name) |
|
173 | - { |
|
172 | + public function hasPermission($name) |
|
173 | + { |
|
174 | 174 | return (is_string($name) && $name && isset($this->mgrPermissions[$name])); |
175 | 175 | } |
176 | 176 | |
@@ -179,89 +179,89 @@ discard block |
||
179 | 179 | * @param bool $clearCache |
180 | 180 | * @return bool|int|null|void |
181 | 181 | */ |
182 | - public function save($fire_events = false, $clearCache = false) |
|
183 | - { |
|
184 | - if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') { |
|
182 | + public function save($fire_events = false, $clearCache = false) |
|
183 | + { |
|
184 | + if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') { |
|
185 | 185 | $this->log['EmptyPKField'] = 'Email, username or password is empty <pre>' . print_r($this->toArray(), |
186 | 186 | true) . '</pre>'; |
187 | 187 | |
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - if (!$this->checkUnique('manager_users', 'username')) { |
|
191 | + if (!$this->checkUnique('manager_users', 'username')) { |
|
192 | 192 | $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'), |
193 | 193 | true) . '</pre>'; |
194 | 194 | |
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | - if (!$this->checkUnique('user_attributes', 'email', 'internalKey')) { |
|
198 | + if (!$this->checkUnique('user_attributes', 'email', 'internalKey')) { |
|
199 | 199 | $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>'; |
200 | 200 | |
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - if(!$this->get('role')) { |
|
204 | + if(!$this->get('role')) { |
|
205 | 205 | $this->log['UniqueEmail'] = 'Wrong manager role <pre>' . print_r($this->get('role'), true) . '</pre>'; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $this->set('sessionid', ''); |
209 | 209 | $fld = $this->toArray(); |
210 | - foreach ($this->default_field['user'] as $key => $value) { |
|
210 | + foreach ($this->default_field['user'] as $key => $value) { |
|
211 | 211 | $tmp = $this->get($key); |
212 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
212 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
213 | 213 | $this->field[$key] = $value; |
214 | 214 | } |
215 | 215 | $this->Uset($key, 'user'); |
216 | 216 | unset($fld[$key]); |
217 | 217 | } |
218 | - if (!empty($this->set['user'])) { |
|
219 | - if ($this->newDoc) { |
|
218 | + if (!empty($this->set['user'])) { |
|
219 | + if ($this->newDoc) { |
|
220 | 220 | $SQL = "INSERT into {$this->makeTable('manager_users')} SET " . implode(', ', $this->set['user']); |
221 | - } else { |
|
221 | + } else { |
|
222 | 222 | $SQL = "UPDATE {$this->makeTable('manager_users')} SET " . implode(', ', |
223 | 223 | $this->set['user']) . " WHERE id = " . $this->id; |
224 | 224 | } |
225 | 225 | $this->query($SQL); |
226 | 226 | } |
227 | 227 | |
228 | - if ($this->newDoc) { |
|
228 | + if ($this->newDoc) { |
|
229 | 229 | $this->id = $this->modx->db->getInsertId(); |
230 | 230 | } |
231 | 231 | |
232 | - foreach ($this->default_field['attribute'] as $key => $value) { |
|
232 | + foreach ($this->default_field['attribute'] as $key => $value) { |
|
233 | 233 | $tmp = $this->get($key); |
234 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
234 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
235 | 235 | $this->field[$key] = $value; |
236 | 236 | } |
237 | 237 | $this->Uset($key, 'attribute'); |
238 | 238 | unset($fld[$key]); |
239 | 239 | } |
240 | - if (!empty($this->set['attribute'])) { |
|
241 | - if ($this->newDoc) { |
|
240 | + if (!empty($this->set['attribute'])) { |
|
241 | + if ($this->newDoc) { |
|
242 | 242 | $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute'); |
243 | 243 | $SQL = "INSERT into {$this->makeTable('user_attributes')} SET " . implode(', ', |
244 | 244 | $this->set['attribute']); |
245 | - } else { |
|
245 | + } else { |
|
246 | 246 | $SQL = "UPDATE {$this->makeTable('user_attributes')} SET " . implode(', ', |
247 | 247 | $this->set['attribute']) . " WHERE internalKey = " . $this->getID(); |
248 | 248 | } |
249 | 249 | $this->query($SQL); |
250 | 250 | } |
251 | 251 | unset($fld['id']); |
252 | - foreach ($fld as $key => $value) { |
|
253 | - if ($value == '' || !$this->isChanged($key)) { |
|
252 | + foreach ($fld as $key => $value) { |
|
253 | + if ($value == '' || !$this->isChanged($key)) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}'"); |
257 | - if ($this->modx->db->getRecordCount($result) > 0) { |
|
257 | + if ($this->modx->db->getRecordCount($result) > 0) { |
|
258 | 258 | $this->query("UPDATE {$this->makeTable('user_settings')} SET `setting_value` = '{$value}' WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}';"); |
259 | - } else { |
|
259 | + } else { |
|
260 | 260 | $this->query("INSERT into {$this->makeTable('user_settings')} SET `user` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';"); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | // TODO |
264 | - if (!$this->newDoc && $this->givenPassword) { |
|
264 | + if (!$this->newDoc && $this->givenPassword) { |
|
265 | 265 | $this->invokeEvent('OnManagerChangePassword', array( |
266 | 266 | 'userObj' => $this, |
267 | 267 | 'userid' => $this->id, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ), $fire_events); |
272 | 272 | } |
273 | 273 | |
274 | - if ($this->groupIds) { |
|
274 | + if ($this->groupIds) { |
|
275 | 275 | $this->setUserGroups($this->id, $this->groupIds); |
276 | 276 | } |
277 | 277 | // TODO |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | "userroleid" => $this->get('role') |
288 | 288 | ), $fire_events); |
289 | 289 | |
290 | - if ($clearCache) { |
|
290 | + if ($clearCache) { |
|
291 | 291 | $this->clearCache($fire_events); |
292 | 292 | } |
293 | 293 | |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | * @param bool $fire_events |
300 | 300 | * @return bool|null|void |
301 | 301 | */ |
302 | - public function delete($ids, $fire_events = false) |
|
303 | - { |
|
304 | - if ($this->edit($ids)) { |
|
302 | + public function delete($ids, $fire_events = false) |
|
303 | + { |
|
304 | + if ($this->edit($ids)) { |
|
305 | 305 | $flag = $this->query(" |
306 | 306 | DELETE user,attribute FROM {$this->makeTable('user_attributes')} as attribute |
307 | 307 | LEFT JOIN {$this->makeTable('manager_users')} as user ON user.id=attribute.internalKey |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | 'username' => $this->get('username'), |
316 | 316 | 'timestamp' => time() |
317 | 317 | ), $fire_events); |
318 | - } else { |
|
318 | + } else { |
|
319 | 319 | $flag = false; |
320 | 320 | } |
321 | 321 | $this->close(); |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | * @param bool $fire_events |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function authUser($id = 0, $fulltime = true, $cookieName = 'modx_remember_manager', $fire_events = false) |
|
334 | - { |
|
333 | + public function authUser($id = 0, $fulltime = true, $cookieName = 'modx_remember_manager', $fire_events = false) |
|
334 | + { |
|
335 | 335 | $flag = false; |
336 | - if (null === $this->getID() && $id) { |
|
336 | + if (null === $this->getID() && $id) { |
|
337 | 337 | $this->edit($id); |
338 | 338 | } |
339 | - if (null !== $this->getID()) { |
|
339 | + if (null !== $this->getID()) { |
|
340 | 340 | $flag = true; |
341 | 341 | $this->save(false); |
342 | 342 | $this->SessionHandler('start', $cookieName, $fulltime); |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | * @param int $id |
357 | 357 | * @return bool |
358 | 358 | */ |
359 | - public function checkBlock($id = 0) |
|
360 | - { |
|
359 | + public function checkBlock($id = 0) |
|
360 | + { |
|
361 | 361 | $tmp = clone $this; |
362 | - if ($id && $tmp->getID() != $id) { |
|
362 | + if ($id && $tmp->getID() != $id) { |
|
363 | 363 | $tmp->edit($id); |
364 | 364 | } |
365 | 365 | $now = time(); |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | * @param bool $fire_events |
381 | 381 | * @return bool |
382 | 382 | */ |
383 | - public function testAuth($id, $password, $blocker, $fire_events = false) |
|
384 | - { |
|
383 | + public function testAuth($id, $password, $blocker, $fire_events = false) |
|
384 | + { |
|
385 | 385 | $tmp = clone $this; |
386 | - if ($id && $tmp->getID() != $id) { |
|
386 | + if ($id && $tmp->getID() != $id) { |
|
387 | 387 | $tmp->edit($id); |
388 | 388 | } |
389 | 389 | |
390 | 390 | $flag = $pluginFlag = false; |
391 | 391 | if ( |
392 | 392 | (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id))) |
393 | - ) { |
|
393 | + ) { |
|
394 | 394 | $_password = $tmp->get('password'); |
395 | 395 | $eventResult = $this->getInvokeEventResult('OnManagerAuthentication', array( |
396 | 396 | 'userObj' => $this, |
@@ -399,16 +399,16 @@ discard block |
||
399 | 399 | 'userpassword' => $password, |
400 | 400 | 'savedpassword' => $_password |
401 | 401 | ), $fire_events); |
402 | - if (is_array($eventResult)) { |
|
403 | - foreach ($eventResult as $result) { |
|
402 | + if (is_array($eventResult)) { |
|
403 | + foreach ($eventResult as $result) { |
|
404 | 404 | $pluginFlag = (bool)$result; |
405 | 405 | } |
406 | - } else { |
|
406 | + } else { |
|
407 | 407 | $pluginFlag = (bool)$eventResult; |
408 | 408 | } |
409 | - if (!$pluginFlag) { |
|
409 | + if (!$pluginFlag) { |
|
410 | 410 | $hashType = $this->getPasswordHashType($_password); |
411 | - switch ($hashType) { |
|
411 | + switch ($hashType) { |
|
412 | 412 | case 'phpass': |
413 | 413 | $flag = $this->modx->phpass->CheckPassword($password, $_password); |
414 | 414 | break; |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | case 'v1': |
419 | 419 | $algorithm = \APIhelpers::getkey($this->modx->config, 'pwd_hash_algo', 'UNCRYPT'); |
420 | 420 | $userAlgorithm = $this->getPasswordHashAlgorithm($_password); |
421 | - if ($algorithm !== $userAlgorithm) { |
|
421 | + if ($algorithm !== $userAlgorithm) { |
|
422 | 422 | $algorithm = $userAlgorithm; |
423 | 423 | } |
424 | 424 | $flag = $_password == $this->makeHash($password, $tmp->getID(), $algorithm); |
425 | 425 | break; |
426 | 426 | } |
427 | - if ($flag && $hashType == 'md5' || $hashType == 'v1') { |
|
427 | + if ($flag && $hashType == 'md5' || $hashType == 'v1') { |
|
428 | 428 | $tmp->set('password', $password)->save(); |
429 | - if ($id == $this->getID()) { |
|
429 | + if ($id == $this->getID()) { |
|
430 | 430 | $this->field['password'] = $tmp->get('password'); |
431 | 431 | } |
432 | 432 | } |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | * @param string $cookieName |
442 | 442 | * @param null $fire_events |
443 | 443 | */ |
444 | - public function logOut($cookieName = 'modx_remember_manager', $fire_events = null) |
|
445 | - { |
|
446 | - if (!$uid = $this->modx->getLoginUserID('mgr')) { |
|
444 | + public function logOut($cookieName = 'modx_remember_manager', $fire_events = null) |
|
445 | + { |
|
446 | + if (!$uid = $this->modx->getLoginUserID('mgr')) { |
|
447 | 447 | return; |
448 | 448 | } |
449 | 449 | $params = array( |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | * |
471 | 471 | * remeber может быть числом в секундах |
472 | 472 | */ |
473 | - protected function SessionHandler($directive, $cookieName, $remember = true) |
|
474 | - { |
|
475 | - switch ($directive) { |
|
473 | + protected function SessionHandler($directive, $cookieName, $remember = true) |
|
474 | + { |
|
475 | + switch ($directive) { |
|
476 | 476 | case 'start': |
477 | - if ($this->getID()) { |
|
477 | + if ($this->getID()) { |
|
478 | 478 | $_SESSION['usertype'] = 'manager'; |
479 | 479 | $_SESSION['mgrShortname'] = $this->get('username'); |
480 | 480 | $_SESSION['mgrFullname'] = $this->get('fullname'); |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | $_SESSION['mgrRole'] = $this->get('role'); |
488 | 488 | $_SESSION['mgrPermissions'] = $this->mgrPermissions; |
489 | 489 | $_SESSION['mgrDocgroups'] = $this->getDocumentGroups(); |
490 | - if ($remember) { |
|
490 | + if ($remember) { |
|
491 | 491 | $this->setAutoLoginCookie($cookieName, $remember); |
492 | 492 | } |
493 | 493 | } |
494 | 494 | break; |
495 | 495 | case 'destroy': |
496 | - if (isset($_SESSION['webValidated'])) { |
|
496 | + if (isset($_SESSION['webValidated'])) { |
|
497 | 497 | unset($_SESSION['usertype']); |
498 | 498 | unset($_SESSION['webShortname']); |
499 | 499 | unset($_SESSION['mgrFullname']); |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | unset($_SESSION['mgrPermissions']); |
508 | 508 | |
509 | 509 | setcookie($cookieName, '', time() - 60, '/'); |
510 | - } else { |
|
511 | - if (isset($_COOKIE[session_name()])) { |
|
510 | + } else { |
|
511 | + if (isset($_COOKIE[session_name()])) { |
|
512 | 512 | setcookie(session_name(), '', time() - 60, '/'); |
513 | 513 | } |
514 | 514 | setcookie($cookieName, '', time() - 60, '/'); |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | /** |
524 | 524 | * @return bool |
525 | 525 | */ |
526 | - public function isSecure() |
|
527 | - { |
|
526 | + public function isSecure() |
|
527 | + { |
|
528 | 528 | $out = $this->modxConfig('server_protocol') == 'http' ? false : true; |
529 | 529 | |
530 | 530 | return $out; |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | * @param bool $remember |
536 | 536 | * @return $this |
537 | 537 | */ |
538 | - public function setAutoLoginCookie($cookieName, $remember = true) |
|
539 | - { |
|
540 | - if (!empty($cookieName) && $this->getID()) { |
|
538 | + public function setAutoLoginCookie($cookieName, $remember = true) |
|
539 | + { |
|
540 | + if (!empty($cookieName) && $this->getID()) { |
|
541 | 541 | $secure = $this->isSecure(); |
542 | 542 | $remember = is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember; |
543 | 543 | $cookieValue = $this->get('username'); |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | * @param int $userID |
553 | 553 | * @return array |
554 | 554 | */ |
555 | - public function getDocumentGroups($userID = 0) |
|
556 | - { |
|
555 | + public function getDocumentGroups($userID = 0) |
|
556 | + { |
|
557 | 557 | $out = array(); |
558 | 558 | $user = $this->switchObject($userID); |
559 | - if (null !== $user->getID()) { |
|
559 | + if (null !== $user->getID()) { |
|
560 | 560 | $member_groups = $this->modx->getFullTableName('member_groups'); |
561 | 561 | $membergroup_access = $this->modx->getFullTableName('membergroup_access'); |
562 | 562 | |
@@ -574,11 +574,11 @@ discard block |
||
574 | 574 | * @param int $userID |
575 | 575 | * @return array |
576 | 576 | */ |
577 | - public function getUserGroups($userID = 0) |
|
578 | - { |
|
577 | + public function getUserGroups($userID = 0) |
|
578 | + { |
|
579 | 579 | $out = array(); |
580 | 580 | $user = $this->switchObject($userID); |
581 | - if (null !== $user->getID()) { |
|
581 | + if (null !== $user->getID()) { |
|
582 | 582 | $member_groups = $this->makeTable('member_groups'); |
583 | 583 | $membergroup_names = $this->makeTable('membergroup_names'); |
584 | 584 | |
@@ -597,17 +597,17 @@ discard block |
||
597 | 597 | * @param array $groupIds |
598 | 598 | * @return $this |
599 | 599 | */ |
600 | - public function setUserGroups($userID = 0, $groupIds = array()) |
|
601 | - { |
|
602 | - if (!is_array($groupIds)) { |
|
600 | + public function setUserGroups($userID = 0, $groupIds = array()) |
|
601 | + { |
|
602 | + if (!is_array($groupIds)) { |
|
603 | 603 | return $this; |
604 | 604 | } |
605 | - if ($this->newDoc && $userID == 0) { |
|
605 | + if ($this->newDoc && $userID == 0) { |
|
606 | 606 | $this->groupIds = $groupIds; |
607 | - } else { |
|
607 | + } else { |
|
608 | 608 | $user = $this->switchObject($userID); |
609 | - if ($uid = $user->getID()) { |
|
610 | - foreach ($groupIds as $gid) { |
|
609 | + if ($uid = $user->getID()) { |
|
610 | + foreach ($groupIds as $gid) { |
|
611 | 611 | $this->query("REPLACE INTO {$this->makeTable('member_groups')} (`user_group`, `member`) VALUES ('{$gid}', '{$uid}')"); |
612 | 612 | } |
613 | 613 | } |
@@ -622,14 +622,14 @@ discard block |
||
622 | 622 | * @param string $pass |
623 | 623 | * @return string |
624 | 624 | */ |
625 | - public function getPasswordHashType($pass) |
|
626 | - { |
|
625 | + public function getPasswordHashType($pass) |
|
626 | + { |
|
627 | 627 | $out = 'unknown'; |
628 | - if (substr($pass, 0, 1) === '$') { |
|
628 | + if (substr($pass, 0, 1) === '$') { |
|
629 | 629 | $out = 'phpass'; |
630 | - } elseif (strpos($pass, '>') !== false) { |
|
630 | + } elseif (strpos($pass, '>') !== false) { |
|
631 | 631 | $out = 'v1'; |
632 | - } elseif (strlen($pass) === 32) { |
|
632 | + } elseif (strlen($pass) === 32) { |
|
633 | 633 | $out = 'md5'; |
634 | 634 | } |
635 | 635 | |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @param string $pass |
641 | 641 | * @return string |
642 | 642 | */ |
643 | - public function getPasswordHashAlgorithm($pass) |
|
644 | - { |
|
643 | + public function getPasswordHashAlgorithm($pass) |
|
644 | + { |
|
645 | 645 | $pointer = strpos($pass, '>'); |
646 | 646 | $out = $pointer === false ? 'NOSALT' : substr($pass, 0, $pointer); |
647 | 647 | |
@@ -654,11 +654,11 @@ discard block |
||
654 | 654 | * @param string $algorithm |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public function makeHash($pass, $seed, $algorithm) |
|
658 | - { |
|
657 | + public function makeHash($pass, $seed, $algorithm) |
|
658 | + { |
|
659 | 659 | $salt = md5($pass . $seed); |
660 | 660 | |
661 | - switch ($algorithm) { |
|
661 | + switch ($algorithm) { |
|
662 | 662 | case 'BLOWFISH_Y': |
663 | 663 | $salt = '$2y$07$' . substr($salt, 0, 22); |
664 | 664 | break; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | if ($this->newDoc) { |
220 | 220 | $SQL = "INSERT into {$this->makeTable('manager_users')} SET " . implode(', ', $this->set['user']); |
221 | 221 | } else { |
222 | - $SQL = "UPDATE {$this->makeTable('manager_users')} SET " . implode(', ', |
|
222 | + $SQL = "update {$this->makeTable('manager_users')} SET " . implode(', ', |
|
223 | 223 | $this->set['user']) . " WHERE id = " . $this->id; |
224 | 224 | } |
225 | 225 | $this->query($SQL); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $SQL = "INSERT into {$this->makeTable('user_attributes')} SET " . implode(', ', |
244 | 244 | $this->set['attribute']); |
245 | 245 | } else { |
246 | - $SQL = "UPDATE {$this->makeTable('user_attributes')} SET " . implode(', ', |
|
246 | + $SQL = "update {$this->makeTable('user_attributes')} SET " . implode(', ', |
|
247 | 247 | $this->set['attribute']) . " WHERE internalKey = " . $this->getID(); |
248 | 248 | } |
249 | 249 | $this->query($SQL); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}'"); |
257 | 257 | if ($this->modx->db->getRecordCount($result) > 0) { |
258 | - $this->query("UPDATE {$this->makeTable('user_settings')} SET `setting_value` = '{$value}' WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}';"); |
|
258 | + $this->query("update {$this->makeTable('user_settings')} SET `setting_value` = '{$value}' WHERE `user` = '{$this->id}' AND `setting_name` = '{$key}';"); |
|
259 | 259 | } else { |
260 | 260 | $this->query("INSERT into {$this->makeTable('user_settings')} SET `user` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';"); |
261 | 261 | } |