Completed
Push — master ( 56110f...3f5174 )
by
unknown
05:31
created
assets/lib/MODxAPI/modUsers.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      */
409 409
     public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
410 410
     {
411
-        if (!$uid = $this->modx->getLoginUserID('web')) {
411
+        if ( ! $uid = $this->modx->getLoginUserID('web')) {
412 412
             return;
413 413
         }
414 414
         $params = array(
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      */
504 504
     protected function setAutoLoginCookie($cookieName, $remember = true)
505 505
     {
506
-        if (!empty($cookieName)) {
506
+        if ( ! empty($cookieName)) {
507 507
             $secure = $this->isSecure();
508 508
             $cookieValue = array(md5($this->get('username')), $this->get('password'), $this->get('sessionid'));
509 509
             $cookieValue = implode('|', $cookieValue);
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
      */
567 567
     public function setUserGroups($userID = 0, $groupIds = array())
568 568
     {
569
-        if (!is_array($groupIds)) return $this;
569
+        if ( ! is_array($groupIds)) return $this;
570 570
         if ($this->newDoc && $userID == 0) {
571 571
             $this->groupIds = $groupIds;
572 572
         } else {
Please login to merge, or discard this patch.
Braces   +98 added lines, -94 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,18 +383,18 @@  discard block
 block discarded – undo
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);
393 395
                 if ($this->edit($id) && null !== $this->getID() && $this->get('password') == $cookie[1] && $this->get('sessionid') == $cookie[2] && $this->testAuth($this->getID(),
394 396
                         $cookie[1], true)
395
-                ) {
397
+                ) {
396 398
                     $flag = $this->authUser($this->getID(), $fulltime, $cookieName, $fire_events);
397 399
 
398 400
                 }
@@ -406,9 +408,9 @@  discard block
 block discarded – undo
406 408
      * @param string $cookieName
407 409
      * @param null $fire_events
408 410
      */
409
-    public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
410
-    {
411
-        if (!$uid = $this->modx->getLoginUserID('web')) {
411
+    public function logOut($cookieName = 'WebLoginPE', $fire_events = null)
412
+    {
413
+        if (!$uid = $this->modx->getLoginUserID('web')) {
412 414
             return;
413 415
         }
414 416
         $params = array(
@@ -433,11 +435,11 @@  discard block
 block discarded – undo
433 435
      *
434 436
      * remeber может быть числом в секундах
435 437
      */
436
-    protected function SessionHandler($directive, $cookieName, $remember = true)
437
-    {
438
-        switch ($directive) {
438
+    protected function SessionHandler($directive, $cookieName, $remember = true)
439
+    {
440
+        switch ($directive) {
439 441
             case 'start':
440
-                if ($this->getID()) {
442
+                if ($this->getID()) {
441 443
                     $_SESSION['webShortname'] = $this->get('username');
442 444
                     $_SESSION['webFullname'] = $this->get('fullname');
443 445
                     $_SESSION['webEmail'] = $this->get('email');
@@ -451,13 +453,13 @@  discard block
 block discarded – undo
451 453
                     $_SESSION['webUsrConfigSet'] = array();
452 454
                     $_SESSION['webUserGroupNames'] = $this->getUserGroups();
453 455
                     $_SESSION['webDocgroups'] = $this->getDocumentGroups();
454
-                    if ($remember) {
456
+                    if ($remember) {
455 457
                         $this->setAutoLoginCookie($cookieName, $remember);
456 458
                     }
457 459
                 }
458 460
                 break;
459 461
             case 'destroy':
460
-                if (isset($_SESSION['mgrValidated'])) {
462
+                if (isset($_SESSION['mgrValidated'])) {
461 463
                     unset($_SESSION['webShortname']);
462 464
                     unset($_SESSION['webFullname']);
463 465
                     unset($_SESSION['webEmail']);
@@ -473,8 +475,8 @@  discard block
 block discarded – undo
473 475
                     unset($_SESSION['webDocgroups']);
474 476
 
475 477
                     setcookie($cookieName, '', time() - 60, '/');
476
-                } else {
477
-                    if (isset($_COOKIE[session_name()])) {
478
+                } else {
479
+                    if (isset($_COOKIE[session_name()])) {
478 480
                         setcookie(session_name(), '', time() - 60, '/');
479 481
                     }
480 482
                     setcookie($cookieName, '', time() - 60, '/');
@@ -489,8 +491,8 @@  discard block
 block discarded – undo
489 491
     /**
490 492
      * @return bool
491 493
      */
492
-    public function isSecure()
493
-    {
494
+    public function isSecure()
495
+    {
494 496
         $out = $this->modxConfig('server_protocol') == 'http' ? false : true;
495 497
 
496 498
         return $out;
@@ -501,9 +503,9 @@  discard block
 block discarded – undo
501 503
      * @param bool $remember
502 504
      * @return $this
503 505
      */
504
-    protected function setAutoLoginCookie($cookieName, $remember = true)
505
-    {
506
-        if (!empty($cookieName)) {
506
+    protected function setAutoLoginCookie($cookieName, $remember = true)
507
+    {
508
+        if (!empty($cookieName)) {
507 509
             $secure = $this->isSecure();
508 510
             $cookieValue = array(md5($this->get('username')), $this->get('password'), $this->get('sessionid'));
509 511
             $cookieValue = implode('|', $cookieValue);
@@ -518,11 +520,11 @@  discard block
 block discarded – undo
518 520
      * @param int $userID
519 521
      * @return array
520 522
      */
521
-    public function getDocumentGroups($userID = 0)
522
-    {
523
+    public function getDocumentGroups($userID = 0)
524
+    {
523 525
         $out = array();
524 526
         $user = $this->switchObject($userID);
525
-        if (null !== $user->getID()) {
527
+        if (null !== $user->getID()) {
526 528
             $web_groups = $this->modx->getFullTableName('web_groups');
527 529
             $webgroup_access = $this->modx->getFullTableName('webgroup_access');
528 530
 
@@ -541,11 +543,11 @@  discard block
 block discarded – undo
541 543
      * @param int $userID
542 544
      * @return array
543 545
      */
544
-    public function getUserGroups($userID = 0)
545
-    {
546
+    public function getUserGroups($userID = 0)
547
+    {
546 548
         $out = array();
547 549
         $user = $this->switchObject($userID);
548
-        if (null !== $user->getID()) {
550
+        if (null !== $user->getID()) {
549 551
             $web_groups = $this->makeTable('web_groups');
550 552
             $webgroup_names = $this->makeTable('webgroup_names');
551 553
 
@@ -564,15 +566,17 @@  discard block
 block discarded – undo
564 566
      * @param array $groupIds
565 567
      * @return $this
566 568
      */
567
-    public function setUserGroups($userID = 0, $groupIds = array())
568
-    {
569
-        if (!is_array($groupIds)) return $this;
570
-        if ($this->newDoc && $userID == 0) {
569
+    public function setUserGroups($userID = 0, $groupIds = array())
570
+    {
571
+        if (!is_array($groupIds)) {
572
+            return $this;
573
+        }
574
+        if ($this->newDoc && $userID == 0) {
571 575
             $this->groupIds = $groupIds;
572
-        } else {
576
+        } else {
573 577
             $user = $this->switchObject($userID);
574
-            if ($uid = $user->getID()) {
575
-                foreach ($groupIds as $gid) {
578
+            if ($uid = $user->getID()) {
579
+                foreach ($groupIds as $gid) {
576 580
                     $this->query("REPLACE INTO {$this->makeTable('web_groups')} (`webgroup`, `webuser`) VALUES ('{$gid}', '{$uid}')");
577 581
                 }
578 582
             }
Please login to merge, or discard this patch.