@@ -501,7 +501,7 @@ |
||
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
504 | - * @param $cookieName |
|
504 | + * @param string $cookieName |
|
505 | 505 | * @param bool $remember |
506 | 506 | * @return $this |
507 | 507 | */ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $this->close(); |
96 | 96 | $this->newDoc = false; |
97 | 97 | |
98 | - if (!$find = $this->findUser($id)) { |
|
98 | + if ( ! $find = $this->findUser($id)) { |
|
99 | 99 | $this->id = null; |
100 | 100 | } else { |
101 | 101 | $result = $this->query(" |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function set($key, $value) |
124 | 124 | { |
125 | - if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
125 | + if (is_scalar($value) && is_scalar($key) && ! empty($key)) { |
|
126 | 126 | switch ($key) { |
127 | 127 | case 'password': |
128 | 128 | $this->givenPassword = $value; |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
165 | - if (!$this->checkUnique('web_users', 'username')) { |
|
165 | + if ( ! $this->checkUnique('web_users', 'username')) { |
|
166 | 166 | $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'), |
167 | 167 | true) . '</pre>'; |
168 | 168 | |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
172 | - if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) { |
|
172 | + if ( ! $this->checkUnique('web_user_attributes', 'email', 'internalKey')) { |
|
173 | 173 | $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>'; |
174 | 174 | |
175 | 175 | return false; |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | $fld = $this->toArray(); |
179 | 179 | foreach ($this->default_field['user'] as $key => $value) { |
180 | 180 | $tmp = $this->get($key); |
181 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
181 | + if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) { |
|
182 | 182 | $this->field[$key] = $value; |
183 | 183 | } |
184 | 184 | $this->Uset($key, 'user'); |
185 | 185 | unset($fld[$key]); |
186 | 186 | } |
187 | - if (!empty($this->set['user'])) { |
|
187 | + if ( ! empty($this->set['user'])) { |
|
188 | 188 | if ($this->newDoc) { |
189 | 189 | $SQL = "INSERT into {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']); |
190 | 190 | } else { |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | |
201 | 201 | foreach ($this->default_field['attribute'] as $key => $value) { |
202 | 202 | $tmp = $this->get($key); |
203 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
203 | + if ($this->newDoc && ( ! is_int($tmp) && $tmp == '')) { |
|
204 | 204 | $this->field[$key] = $value; |
205 | 205 | } |
206 | 206 | $this->Uset($key, 'attribute'); |
207 | 207 | unset($fld[$key]); |
208 | 208 | } |
209 | - if (!empty($this->set['attribute'])) { |
|
209 | + if ( ! empty($this->set['attribute'])) { |
|
210 | 210 | if ($this->newDoc) { |
211 | 211 | $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute'); |
212 | 212 | $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET " . implode(', ', |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | unset($fld['id']); |
221 | 221 | foreach ($fld as $key => $value) { |
222 | - if ($value == '' || !$this->isChanged($key)) { |
|
222 | + if ($value == '' || ! $this->isChanged($key)) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}'"); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $this->query("INSERT into {$this->makeTable('web_user_settings')} SET `webuser` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';"); |
230 | 230 | } |
231 | 231 | } |
232 | - if (!$this->newDoc && $this->givenPassword) { |
|
232 | + if ( ! $this->newDoc && $this->givenPassword) { |
|
233 | 233 | $this->invokeEvent('OnWebChangePassword', array( |
234 | 234 | 'userObj' => $this, |
235 | 235 | 'userid' => $this->id, |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $b = $tmp->get('blocked'); |
330 | 330 | $bu = $tmp->get('blockeduntil'); |
331 | 331 | $ba = $tmp->get('blockedafter'); |
332 | - $flag = (($b && !$bu && !$ba) || ($bu && $now < $bu) || ($ba && $now > $ba)); |
|
332 | + $flag = (($b && ! $bu && ! $ba) || ($bu && $now < $bu) || ($ba && $now > $ba)); |
|
333 | 333 | unset($tmp); |
334 | 334 | |
335 | 335 | return $flag; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | $flag = $pluginFlag = false; |
353 | 353 | if ( |
354 | - (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id))) |
|
354 | + (null !== $tmp->getID()) && ( ! $blocker || ($blocker && ! $tmp->checkBlock($id))) |
|
355 | 355 | ) { |
356 | 356 | $eventResult = $this->getInvokeEventResult('OnWebAuthentication', array( |
357 | 357 | 'userObj' => $this, |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | } else { |
368 | 368 | $pluginFlag = (bool)$eventResult; |
369 | 369 | } |
370 | - if (!$pluginFlag) { |
|
370 | + if ( ! $pluginFlag) { |
|
371 | 371 | $flag = ($tmp->get('password') == $tmp->getPassword($password)); |
372 | 372 | } |
373 | 373 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | && null !== $this->getID() |
396 | 396 | && $this->get('password') == $cookie[1] |
397 | 397 | && $this->get('sessionid') == $cookie[2] |
398 | - && !$this->checkBlock($this->getID()) |
|
398 | + && ! $this->checkBlock($this->getID()) |
|
399 | 399 | ) { |
400 | 400 | $flag = $this->authUser($this->getID(), $fulltime, $cookieName, $fire_events); |
401 | 401 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function logOut($cookieName = 'WebLoginPE', $fire_events = null) |
414 | 414 | { |
415 | - if (!$uid = $this->modx->getLoginUserID('web')) { |
|
415 | + if ( ! $uid = $this->modx->getLoginUserID('web')) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | $params = array( |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function setAutoLoginCookie($cookieName, $remember = true) |
509 | 509 | { |
510 | - if (!empty($cookieName) && $this->getID()) { |
|
510 | + if ( ! empty($cookieName) && $this->getID()) { |
|
511 | 511 | $secure = $this->isSecure(); |
512 | 512 | $remember = is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember; |
513 | 513 | $cookieValue = array(md5($this->get('username')), $this->get('password'), $this->get('sessionid'), $remember); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | public function setUserGroups($userID = 0, $groupIds = array()) |
573 | 573 | { |
574 | - if (!is_array($groupIds)) return $this; |
|
574 | + if ( ! is_array($groupIds)) return $this; |
|
575 | 575 | if ($this->newDoc && $userID == 0) { |
576 | 576 | $this->groupIds = $groupIds; |
577 | 577 | } else { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * Class modUsers |
6 | 6 | */ |
7 | -class modUsers extends MODxAPI |
|
8 | -{ |
|
7 | +class modUsers extends MODxAPI |
|
8 | +{ |
|
9 | 9 | /** |
10 | 10 | * @var array |
11 | 11 | */ |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @param $key |
56 | 56 | * @return bool |
57 | 57 | */ |
58 | - public function issetField($key) |
|
59 | - { |
|
58 | + public function issetField($key) |
|
59 | + { |
|
60 | 60 | return (array_key_exists($key, $this->default_field['user']) || array_key_exists($key, |
61 | 61 | $this->default_field['attribute']) || in_array($key, $this->default_field['hidden'])); |
62 | 62 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param string $data |
66 | 66 | * @return string|false |
67 | 67 | */ |
68 | - protected function findUser($data) |
|
69 | - { |
|
70 | - switch (true) { |
|
68 | + protected function findUser($data) |
|
69 | + { |
|
70 | + switch (true) { |
|
71 | 71 | case (is_int($data) || ((int)$data > 0 && (string)intval($data) === $data)): |
72 | 72 | $find = 'attribute.internalKey'; |
73 | 73 | break; |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | * @param $id |
89 | 89 | * @return $this |
90 | 90 | */ |
91 | - public function edit($id) |
|
92 | - { |
|
91 | + public function edit($id) |
|
92 | + { |
|
93 | 93 | $id = is_scalar($id) ? trim($id) : ''; |
94 | - if ($this->getID() != $id) { |
|
94 | + if ($this->getID() != $id) { |
|
95 | 95 | $this->close(); |
96 | 96 | $this->newDoc = false; |
97 | 97 | |
98 | - if (!$find = $this->findUser($id)) { |
|
98 | + if (!$find = $this->findUser($id)) { |
|
99 | 99 | $this->id = null; |
100 | - } else { |
|
100 | + } else { |
|
101 | 101 | $result = $this->query(" |
102 | 102 | SELECT * from {$this->makeTable('web_user_attributes')} as attribute |
103 | 103 | LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @param $value |
121 | 121 | * @return $this |
122 | 122 | */ |
123 | - public function set($key, $value) |
|
124 | - { |
|
125 | - if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
126 | - switch ($key) { |
|
123 | + public function set($key, $value) |
|
124 | + { |
|
125 | + if (is_scalar($value) && is_scalar($key) && !empty($key)) { |
|
126 | + switch ($key) { |
|
127 | 127 | case 'password': |
128 | 128 | $this->givenPassword = $value; |
129 | 129 | $value = $this->getPassword($value); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param $pass |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - public function getPassword($pass) |
|
147 | - { |
|
146 | + public function getPassword($pass) |
|
147 | + { |
|
148 | 148 | return md5($pass); |
149 | 149 | } |
150 | 150 | |
@@ -153,83 +153,83 @@ discard block |
||
153 | 153 | * @param bool $clearCache |
154 | 154 | * @return bool|int|null|void |
155 | 155 | */ |
156 | - public function save($fire_events = false, $clearCache = false) |
|
157 | - { |
|
158 | - if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') { |
|
156 | + public function save($fire_events = false, $clearCache = false) |
|
157 | + { |
|
158 | + if ($this->get('email') == '' || $this->get('username') == '' || $this->get('password') == '') { |
|
159 | 159 | $this->log['EmptyPKField'] = 'Email, username or password is empty <pre>' . print_r($this->toArray(), |
160 | 160 | true) . '</pre>'; |
161 | 161 | |
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
165 | - if (!$this->checkUnique('web_users', 'username')) { |
|
165 | + if (!$this->checkUnique('web_users', 'username')) { |
|
166 | 166 | $this->log['UniqueUsername'] = 'username not unique <pre>' . print_r($this->get('username'), |
167 | 167 | true) . '</pre>'; |
168 | 168 | |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
172 | - if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) { |
|
172 | + if (!$this->checkUnique('web_user_attributes', 'email', 'internalKey')) { |
|
173 | 173 | $this->log['UniqueEmail'] = 'Email not unique <pre>' . print_r($this->get('email'), true) . '</pre>'; |
174 | 174 | |
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | $this->set('sessionid', ''); |
178 | 178 | $fld = $this->toArray(); |
179 | - foreach ($this->default_field['user'] as $key => $value) { |
|
179 | + foreach ($this->default_field['user'] as $key => $value) { |
|
180 | 180 | $tmp = $this->get($key); |
181 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
181 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
182 | 182 | $this->field[$key] = $value; |
183 | 183 | } |
184 | 184 | $this->Uset($key, 'user'); |
185 | 185 | unset($fld[$key]); |
186 | 186 | } |
187 | - if (!empty($this->set['user'])) { |
|
188 | - if ($this->newDoc) { |
|
187 | + if (!empty($this->set['user'])) { |
|
188 | + if ($this->newDoc) { |
|
189 | 189 | $SQL = "INSERT into {$this->makeTable('web_users')} SET " . implode(', ', $this->set['user']); |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $SQL = "UPDATE {$this->makeTable('web_users')} SET " . implode(', ', |
192 | 192 | $this->set['user']) . " WHERE id = " . $this->id; |
193 | 193 | } |
194 | 194 | $this->query($SQL); |
195 | 195 | } |
196 | 196 | |
197 | - if ($this->newDoc) { |
|
197 | + if ($this->newDoc) { |
|
198 | 198 | $this->id = $this->modx->db->getInsertId(); |
199 | 199 | } |
200 | 200 | |
201 | - foreach ($this->default_field['attribute'] as $key => $value) { |
|
201 | + foreach ($this->default_field['attribute'] as $key => $value) { |
|
202 | 202 | $tmp = $this->get($key); |
203 | - if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
203 | + if ($this->newDoc && (!is_int($tmp) && $tmp == '')) { |
|
204 | 204 | $this->field[$key] = $value; |
205 | 205 | } |
206 | 206 | $this->Uset($key, 'attribute'); |
207 | 207 | unset($fld[$key]); |
208 | 208 | } |
209 | - if (!empty($this->set['attribute'])) { |
|
210 | - if ($this->newDoc) { |
|
209 | + if (!empty($this->set['attribute'])) { |
|
210 | + if ($this->newDoc) { |
|
211 | 211 | $this->set('internalKey', $this->id)->Uset('internalKey', 'attribute'); |
212 | 212 | $SQL = "INSERT into {$this->makeTable('web_user_attributes')} SET " . implode(', ', |
213 | 213 | $this->set['attribute']); |
214 | - } else { |
|
214 | + } else { |
|
215 | 215 | $SQL = "UPDATE {$this->makeTable('web_user_attributes')} SET " . implode(', ', |
216 | 216 | $this->set['attribute']) . " WHERE internalKey = " . $this->getID(); |
217 | 217 | } |
218 | 218 | $this->query($SQL); |
219 | 219 | } |
220 | 220 | unset($fld['id']); |
221 | - foreach ($fld as $key => $value) { |
|
222 | - if ($value == '' || !$this->isChanged($key)) { |
|
221 | + foreach ($fld as $key => $value) { |
|
222 | + if ($value == '' || !$this->isChanged($key)) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | $result = $this->query("SELECT `setting_value` FROM {$this->makeTable('web_user_settings')} WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}'"); |
226 | - if ($this->modx->db->getRecordCount($result) > 0) { |
|
226 | + if ($this->modx->db->getRecordCount($result) > 0) { |
|
227 | 227 | $this->query("UPDATE {$this->makeTable('web_user_settings')} SET `setting_value` = '{$value}' WHERE `webuser` = '{$this->id}' AND `setting_name` = '{$key}';"); |
228 | - } else { |
|
228 | + } else { |
|
229 | 229 | $this->query("INSERT into {$this->makeTable('web_user_settings')} SET `webuser` = {$this->id},`setting_name` = '{$key}',`setting_value` = '{$value}';"); |
230 | 230 | } |
231 | 231 | } |
232 | - if (!$this->newDoc && $this->givenPassword) { |
|
232 | + if (!$this->newDoc && $this->givenPassword) { |
|
233 | 233 | $this->invokeEvent('OnWebChangePassword', array( |
234 | 234 | 'userObj' => $this, |
235 | 235 | 'userid' => $this->id, |
@@ -240,7 +240,9 @@ discard block |
||
240 | 240 | ), $fire_events); |
241 | 241 | } |
242 | 242 | |
243 | - if ($this->groupIds) $this->setUserGroups($this->id, $this->groupIds); |
|
243 | + if ($this->groupIds) { |
|
244 | + $this->setUserGroups($this->id, $this->groupIds); |
|
245 | + } |
|
244 | 246 | |
245 | 247 | $this->invokeEvent('OnWebSaveUser', array( |
246 | 248 | 'userObj' => $this, |
@@ -249,7 +251,7 @@ discard block |
||
249 | 251 | 'user' => $this->toArray() |
250 | 252 | ), $fire_events); |
251 | 253 | |
252 | - if ($clearCache) { |
|
254 | + if ($clearCache) { |
|
253 | 255 | $this->clearCache($fire_events); |
254 | 256 | } |
255 | 257 | |
@@ -261,9 +263,9 @@ discard block |
||
261 | 263 | * @param bool $fire_events |
262 | 264 | * @return bool|null|void |
263 | 265 | */ |
264 | - public function delete($ids, $fire_events = false) |
|
265 | - { |
|
266 | - if ($this->edit($ids)) { |
|
266 | + public function delete($ids, $fire_events = false) |
|
267 | + { |
|
268 | + if ($this->edit($ids)) { |
|
267 | 269 | $flag = $this->query(" |
268 | 270 | DELETE user,attribute FROM {$this->makeTable('web_user_attributes')} as attribute |
269 | 271 | LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey |
@@ -277,7 +279,7 @@ discard block |
||
277 | 279 | 'username' => $this->get('username'), |
278 | 280 | 'timestamp' => time() |
279 | 281 | ), $fire_events); |
280 | - } else { |
|
282 | + } else { |
|
281 | 283 | $flag = false; |
282 | 284 | } |
283 | 285 | $this->close(); |
@@ -292,13 +294,13 @@ discard block |
||
292 | 294 | * @param bool $fire_events |
293 | 295 | * @return bool |
294 | 296 | */ |
295 | - public function authUser($id = 0, $fulltime = true, $cookieName = 'WebLoginPE', $fire_events = false) |
|
296 | - { |
|
297 | + public function authUser($id = 0, $fulltime = true, $cookieName = 'WebLoginPE', $fire_events = false) |
|
298 | + { |
|
297 | 299 | $flag = false; |
298 | - if (null === $this->getID() && $id) { |
|
300 | + if (null === $this->getID() && $id) { |
|
299 | 301 | $this->edit($id); |
300 | 302 | } |
301 | - if (null !== $this->getID()) { |
|
303 | + if (null !== $this->getID()) { |
|
302 | 304 | $flag = true; |
303 | 305 | $this->save(false); |
304 | 306 | $this->SessionHandler('start', $cookieName, $fulltime); |
@@ -318,10 +320,10 @@ discard block |
||
318 | 320 | * @param int $id |
319 | 321 | * @return bool |
320 | 322 | */ |
321 | - public function checkBlock($id = 0) |
|
322 | - { |
|
323 | + public function checkBlock($id = 0) |
|
324 | + { |
|
323 | 325 | $tmp = clone $this; |
324 | - if ($id && $tmp->getID() != $id) { |
|
326 | + if ($id && $tmp->getID() != $id) { |
|
325 | 327 | $tmp->edit($id); |
326 | 328 | } |
327 | 329 | $now = time(); |
@@ -342,17 +344,17 @@ discard block |
||
342 | 344 | * @param bool $fire_events |
343 | 345 | * @return bool |
344 | 346 | */ |
345 | - public function testAuth($id, $password, $blocker, $fire_events = false) |
|
346 | - { |
|
347 | + public function testAuth($id, $password, $blocker, $fire_events = false) |
|
348 | + { |
|
347 | 349 | $tmp = clone $this; |
348 | - if ($id && $tmp->getID() != $id) { |
|
350 | + if ($id && $tmp->getID() != $id) { |
|
349 | 351 | $tmp->edit($id); |
350 | 352 | } |
351 | 353 | |
352 | 354 | $flag = $pluginFlag = false; |
353 | 355 | if ( |
354 | 356 | (null !== $tmp->getID()) && (!$blocker || ($blocker && !$tmp->checkBlock($id))) |
355 | - ) { |
|
357 | + ) { |
|
356 | 358 | $eventResult = $this->getInvokeEventResult('OnWebAuthentication', array( |
357 | 359 | 'userObj' => $this, |
358 | 360 | 'userid' => $tmp->getID(), |
@@ -360,14 +362,14 @@ discard block |
||
360 | 362 | 'userpassword' => $password, |
361 | 363 | 'savedpassword' => $tmp->get('password') |
362 | 364 | ), $fire_events); |
363 | - if (is_array($eventResult)) { |
|
364 | - foreach ($eventResult as $result) { |
|
365 | + if (is_array($eventResult)) { |
|
366 | + foreach ($eventResult as $result) { |
|
365 | 367 | $pluginFlag = (bool)$result; |
366 | 368 | } |
367 | - } else { |
|
369 | + } else { |
|
368 | 370 | $pluginFlag = (bool)$eventResult; |
369 | 371 | } |
370 | - if (!$pluginFlag) { |
|
372 | + if (!$pluginFlag) { |
|
371 | 373 | $flag = ($tmp->get('password') == $tmp->getPassword($password)); |
372 | 374 | } |
373 | 375 | } |
@@ -381,12 +383,12 @@ discard block |
||
381 | 383 | * @param string $cookieName |
382 | 384 | * @return bool |
383 | 385 | */ |
384 | - public function AutoLogin($fulltime = true, $cookieName = 'WebLoginPE', $fire_events = null) |
|
385 | - { |
|
386 | + public function AutoLogin($fulltime = true, $cookieName = 'WebLoginPE', $fire_events = null) |
|
387 | + { |
|
386 | 388 | $flag = false; |
387 | - if (isset($_COOKIE[$cookieName])) { |
|
389 | + if (isset($_COOKIE[$cookieName])) { |
|
388 | 390 | $cookie = explode('|', $_COOKIE[$cookieName], 3); |
389 | - if (isset($cookie[0], $cookie[1], $cookie[2]) && strlen($cookie[0]) == 32 && strlen($cookie[1]) == 32) { |
|
391 | + if (isset($cookie[0], $cookie[1], $cookie[2]) && strlen($cookie[0]) == 32 && strlen($cookie[1]) == 32) { |
|
390 | 392 | $this->close(); |
391 | 393 | $q = $this->modx->db->query("SELECT id FROM " . $this->makeTable('web_users') . " WHERE md5(username)='{$this->escape($cookie[0])}'"); |
392 | 394 | $id = $this->modx->db->getValue($q); |
@@ -396,7 +398,7 @@ discard block |
||
396 | 398 | && $this->get('password') == $cookie[1] |
397 | 399 | && $this->get('sessionid') == $cookie[2] |
398 | 400 | && !$this->checkBlock($this->getID()) |
399 | - ) { |
|
401 | + ) { |
|
400 | 402 | $flag = $this->authUser($this->getID(), $fulltime, $cookieName, $fire_events); |
401 | 403 | |
402 | 404 | } |
@@ -410,9 +412,9 @@ discard block |
||
410 | 412 | * @param string $cookieName |
411 | 413 | * @param null $fire_events |
412 | 414 | */ |
413 | - public function logOut($cookieName = 'WebLoginPE', $fire_events = null) |
|
414 | - { |
|
415 | - if (!$uid = $this->modx->getLoginUserID('web')) { |
|
415 | + public function logOut($cookieName = 'WebLoginPE', $fire_events = null) |
|
416 | + { |
|
417 | + if (!$uid = $this->modx->getLoginUserID('web')) { |
|
416 | 418 | return; |
417 | 419 | } |
418 | 420 | $params = array( |
@@ -437,11 +439,11 @@ discard block |
||
437 | 439 | * |
438 | 440 | * remeber может быть числом в секундах |
439 | 441 | */ |
440 | - protected function SessionHandler($directive, $cookieName, $remember = true) |
|
441 | - { |
|
442 | - switch ($directive) { |
|
442 | + protected function SessionHandler($directive, $cookieName, $remember = true) |
|
443 | + { |
|
444 | + switch ($directive) { |
|
443 | 445 | case 'start': |
444 | - if ($this->getID()) { |
|
446 | + if ($this->getID()) { |
|
445 | 447 | $_SESSION['webShortname'] = $this->get('username'); |
446 | 448 | $_SESSION['webFullname'] = $this->get('fullname'); |
447 | 449 | $_SESSION['webEmail'] = $this->get('email'); |
@@ -455,13 +457,13 @@ discard block |
||
455 | 457 | $_SESSION['webUsrConfigSet'] = array(); |
456 | 458 | $_SESSION['webUserGroupNames'] = $this->getUserGroups(); |
457 | 459 | $_SESSION['webDocgroups'] = $this->getDocumentGroups(); |
458 | - if ($remember) { |
|
460 | + if ($remember) { |
|
459 | 461 | $this->setAutoLoginCookie($cookieName, $remember); |
460 | 462 | } |
461 | 463 | } |
462 | 464 | break; |
463 | 465 | case 'destroy': |
464 | - if (isset($_SESSION['mgrValidated'])) { |
|
466 | + if (isset($_SESSION['mgrValidated'])) { |
|
465 | 467 | unset($_SESSION['webShortname']); |
466 | 468 | unset($_SESSION['webFullname']); |
467 | 469 | unset($_SESSION['webEmail']); |
@@ -477,8 +479,8 @@ discard block |
||
477 | 479 | unset($_SESSION['webDocgroups']); |
478 | 480 | |
479 | 481 | setcookie($cookieName, '', time() - 60, '/'); |
480 | - } else { |
|
481 | - if (isset($_COOKIE[session_name()])) { |
|
482 | + } else { |
|
483 | + if (isset($_COOKIE[session_name()])) { |
|
482 | 484 | setcookie(session_name(), '', time() - 60, '/'); |
483 | 485 | } |
484 | 486 | setcookie($cookieName, '', time() - 60, '/'); |
@@ -493,8 +495,8 @@ discard block |
||
493 | 495 | /** |
494 | 496 | * @return bool |
495 | 497 | */ |
496 | - public function isSecure() |
|
497 | - { |
|
498 | + public function isSecure() |
|
499 | + { |
|
498 | 500 | $out = $this->modxConfig('server_protocol') == 'http' ? false : true; |
499 | 501 | |
500 | 502 | return $out; |
@@ -505,9 +507,9 @@ discard block |
||
505 | 507 | * @param bool $remember |
506 | 508 | * @return $this |
507 | 509 | */ |
508 | - public function setAutoLoginCookie($cookieName, $remember = true) |
|
509 | - { |
|
510 | - if (!empty($cookieName) && $this->getID()) { |
|
510 | + public function setAutoLoginCookie($cookieName, $remember = true) |
|
511 | + { |
|
512 | + if (!empty($cookieName) && $this->getID()) { |
|
511 | 513 | $secure = $this->isSecure(); |
512 | 514 | $remember = is_bool($remember) ? (60 * 60 * 24 * 365 * 5) : (int)$remember; |
513 | 515 | $cookieValue = array(md5($this->get('username')), $this->get('password'), $this->get('sessionid'), $remember); |
@@ -523,11 +525,11 @@ discard block |
||
523 | 525 | * @param int $userID |
524 | 526 | * @return array |
525 | 527 | */ |
526 | - public function getDocumentGroups($userID = 0) |
|
527 | - { |
|
528 | + public function getDocumentGroups($userID = 0) |
|
529 | + { |
|
528 | 530 | $out = array(); |
529 | 531 | $user = $this->switchObject($userID); |
530 | - if (null !== $user->getID()) { |
|
532 | + if (null !== $user->getID()) { |
|
531 | 533 | $web_groups = $this->modx->getFullTableName('web_groups'); |
532 | 534 | $webgroup_access = $this->modx->getFullTableName('webgroup_access'); |
533 | 535 | |
@@ -546,11 +548,11 @@ discard block |
||
546 | 548 | * @param int $userID |
547 | 549 | * @return array |
548 | 550 | */ |
549 | - public function getUserGroups($userID = 0) |
|
550 | - { |
|
551 | + public function getUserGroups($userID = 0) |
|
552 | + { |
|
551 | 553 | $out = array(); |
552 | 554 | $user = $this->switchObject($userID); |
553 | - if (null !== $user->getID()) { |
|
555 | + if (null !== $user->getID()) { |
|
554 | 556 | $web_groups = $this->makeTable('web_groups'); |
555 | 557 | $webgroup_names = $this->makeTable('webgroup_names'); |
556 | 558 | |
@@ -569,15 +571,17 @@ discard block |
||
569 | 571 | * @param array $groupIds |
570 | 572 | * @return $this |
571 | 573 | */ |
572 | - public function setUserGroups($userID = 0, $groupIds = array()) |
|
573 | - { |
|
574 | - if (!is_array($groupIds)) return $this; |
|
575 | - if ($this->newDoc && $userID == 0) { |
|
574 | + public function setUserGroups($userID = 0, $groupIds = array()) |
|
575 | + { |
|
576 | + if (!is_array($groupIds)) { |
|
577 | + return $this; |
|
578 | + } |
|
579 | + if ($this->newDoc && $userID == 0) { |
|
576 | 580 | $this->groupIds = $groupIds; |
577 | - } else { |
|
581 | + } else { |
|
578 | 582 | $user = $this->switchObject($userID); |
579 | - if ($uid = $user->getID()) { |
|
580 | - foreach ($groupIds as $gid) { |
|
583 | + if ($uid = $user->getID()) { |
|
584 | + foreach ($groupIds as $gid) { |
|
581 | 585 | $this->query("REPLACE INTO {$this->makeTable('web_groups')} (`webgroup`, `webuser`) VALUES ('{$gid}', '{$uid}')"); |
582 | 586 | } |
583 | 587 | } |