Completed
Push — master ( 22c084...4b0ccb )
by Patrick
03:37
created
Auth/class.LDAPAuthenticator.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 namespace Auth;
15 15
 
16 16
 /** We need the FlipsideSettings class to determine how to connect to the LDAP server */
17
-if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC']))
17
+if (isset($GLOBALS['FLIPSIDE_SETTINGS_LOC']))
18 18
 {
19 19
     require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php');
20 20
 }
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
 {
34 34
     $count = count($array);
35 35
     $keys  = array_keys($orderby);
36
-    for($i = 0; $i < $count; $i++)
36
+    for ($i = 0; $i < $count; $i++)
37 37
     {
38
-        for($j = $i; $j < $count; $j++)
38
+        for ($j = $i; $j < $count; $j++)
39 39
         {
40 40
             $d = strcasecmp($array[$i][$keys[0]][0], $array[$j][$keys[0]][0]);
41
-            switch($orderby[$keys[0]])
41
+            switch ($orderby[$keys[0]])
42 42
             {
43 43
                 case 1:
44
-                    if($d > 0) swap($array, $i, $j);
44
+                    if ($d > 0) swap($array, $i, $j);
45 45
                     break;
46 46
                 case 0:
47
-                    if($d < 0) swap($array, $i, $j);
47
+                    if ($d < 0) swap($array, $i, $j);
48 48
                     break;
49 49
             }
50 50
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $this->host       = $this->getHostParam($params);
93 93
         $this->user_base  = $this->getParam($params, 'user_base');
94 94
         $this->group_base = $this->getParam($params, 'group_base');
95
-        $this->bind_dn    = $this->getParam($params, 'bind_dn',   '$ldap_auth', 'read_write_pass');
95
+        $this->bind_dn    = $this->getParam($params, 'bind_dn', '$ldap_auth', 'read_write_pass');
96 96
         $this->bind_pass  = $this->getParam($params, 'bind_pass', '$ldap_auth', 'read_write_user');
97 97
     }
98 98
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private function getHostParam($params)
109 109
     {
110
-        if(isset($params['host']))
110
+        if (isset($params['host']))
111 111
         {
112 112
             return $params['host'];
113 113
         }
114
-        if(isset(\FlipsideSettings::$ldap['proto']))
114
+        if (isset(\FlipsideSettings::$ldap['proto']))
115 115
         {
116 116
             return \FlipsideSettings::$ldap['proto'].'://'.\FlipsideSettings::$ldap['host'];
117 117
         }
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @SuppressWarnings("StaticAccess")
132 132
      */
133
-    private function getParam($params, $paramName, $settingsLocation='$ldap', $settingsName=false)
133
+    private function getParam($params, $paramName, $settingsLocation = '$ldap', $settingsName = false)
134 134
     {
135
-        if($settingsName === false)
135
+        if ($settingsName === false)
136 136
         {
137 137
             $settingsName = $paramName;
138 138
         }
139
-        if(isset($params[$paramName]))
139
+        if (isset($params[$paramName]))
140 140
         {
141 141
             return $params[$paramName];
142 142
         }
143
-        if($settingsLocation === '$ldap')
143
+        if ($settingsLocation === '$ldap')
144 144
         {
145 145
             return \FlipsideSettings::$ldap[$settingsName];
146 146
         }
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @SuppressWarnings("StaticAccess")
158 158
      */
159
-    public function get_and_bind_server($bind_write=false)
159
+    public function get_and_bind_server($bind_write = false)
160 160
     {
161 161
         $server = \LDAP\LDAPServer::getInstance();
162 162
         $server->user_base = $this->user_base;
163 163
         $server->group_base = $this->group_base;
164 164
         $server->connect($this->host);
165
-        if($bind_write === false)
165
+        if ($bind_write === false)
166 166
         {
167 167
             $ret = $server->bind();
168 168
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         {
171 171
             $ret = $server->bind($this->bind_dn, $this->bind_pass);
172 172
         }
173
-        if($ret === false)
173
+        if ($ret === false)
174 174
         {
175 175
             return false;
176 176
         }
@@ -188,20 +188,20 @@  discard block
 block discarded – undo
188 188
     public function login($username, $password)
189 189
     {
190 190
         $server = $this->get_and_bind_server();
191
-        if($server === false)
191
+        if ($server === false)
192 192
         {
193 193
             return false;
194 194
         }
195 195
         $filter = new \Data\Filter("uid eq $username or mail eq $username");
196 196
         $user = $server->read($this->user_base, $filter);
197
-        if($user === false || count($user) === 0)
197
+        if ($user === false || count($user) === 0)
198 198
         {
199 199
             return false;
200 200
         }
201 201
         $user = $user[0];
202 202
         $server->unbind();
203 203
         $ret = $server->bind($user->dn, $password);
204
-        if($ret !== false)
204
+        if ($ret !== false)
205 205
         {
206 206
             return array('res'=>true, 'extended'=>$user); 
207 207
         }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function isLoggedIn($data)
219 219
     {
220
-        if(isset($data['res']))
220
+        if (isset($data['res']))
221 221
         {
222 222
             return $data['res'];
223 223
         }
@@ -239,35 +239,35 @@  discard block
 block discarded – undo
239 239
     public function getGroupByName($name)
240 240
     {
241 241
         $server = $this->get_and_bind_server();
242
-        if($server === false)
242
+        if ($server === false)
243 243
         {
244 244
             return false;
245 245
         }
246 246
         return LDAPGroup::from_name($name, $server);
247 247
     }
248 248
 
249
-    public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
249
+    public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
250 250
     {
251 251
         $server = $this->get_and_bind_server();
252
-        if($server === false)
252
+        if ($server === false)
253 253
         {
254 254
             return false;
255 255
         }
256
-        if($filter === false)
256
+        if ($filter === false)
257 257
         {
258 258
             $filter = new \Data\Filter('cn eq *');
259 259
         }
260 260
         $groups = $server->read($this->group_base, $filter);
261
-        if($groups === false)
261
+        if ($groups === false)
262 262
         {
263 263
             return false;
264 264
         }
265 265
         $this->processFilteringParams($groups, $select, $top, $skip, $orderby);
266 266
         $count = count($groups);
267
-        for($i = 0; $i < $count; $i++)
267
+        for ($i = 0; $i < $count; $i++)
268 268
         {
269 269
             $groups[$i] = new LDAPGroup($groups[$i]);
270
-            if($select !== false)
270
+            if ($select !== false)
271 271
             {
272 272
                 $groups[$i] = json_decode(json_encode($groups[$i]), true);
273 273
                 $groups[$i] = array_intersect_key($groups[$i], array_flip($select));
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     public function getActiveUserCount()
280 280
     {
281 281
         $server = $this->get_and_bind_server();
282
-        if($server === false)
282
+        if ($server === false)
283 283
         {
284 284
             return false;
285 285
         }
@@ -288,50 +288,50 @@  discard block
 block discarded – undo
288 288
 
289 289
     private function processFilteringParams(&$data, &$select, $top, $skip, $orderby)
290 290
     {
291
-        if($orderby !== false)
291
+        if ($orderby !== false)
292 292
         {
293 293
             sort_array($data, $orderby);
294 294
         }
295
-        if($select !== false)
295
+        if ($select !== false)
296 296
         {
297 297
             $select = array_flip($select);
298 298
         }
299
-        if($skip !== false && $top !== false)
299
+        if ($skip !== false && $top !== false)
300 300
         {
301 301
             $data = array_slice($data, $skip, $top);
302 302
         }
303
-        else if($top !== false)
303
+        else if ($top !== false)
304 304
         {
305 305
             $data = array_slice($data, 0, $top);
306 306
         }
307
-        else if($skip !== false)
307
+        else if ($skip !== false)
308 308
         {
309 309
             $data = array_slice($data, $skip);
310 310
         }
311 311
     }
312 312
 
313
-    public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
313
+    public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
314 314
     {
315 315
         $server = $this->get_and_bind_server();
316
-        if($server === false)
316
+        if ($server === false)
317 317
         {
318 318
             return false;
319 319
         }
320
-        if($filter === false)
320
+        if ($filter === false)
321 321
         {
322 322
             $filter = new \Data\Filter('cn eq *');
323 323
         }
324 324
         $users = $server->read($this->user_base, $filter, false, $select);
325
-        if($users === false)
325
+        if ($users === false)
326 326
         {
327 327
             return false;
328 328
         }
329 329
         $this->processFilteringParams($users, $select, $top, $skip, $orderby);
330 330
         $count = count($users);
331
-        for($i = 0; $i < $count; $i++)
331
+        for ($i = 0; $i < $count; $i++)
332 332
         {
333 333
             $tmp = new LDAPUser($users[$i]);
334
-            if($select !== false)
334
+            if ($select !== false)
335 335
             {
336 336
                 $tmp = $tmp->jsonSerialize();
337 337
                 $tmp = array_intersect_key($tmp, $select);
@@ -349,36 +349,36 @@  discard block
 block discarded – undo
349 349
         $email = $user->getEmail();
350 350
         $new_user->setEmail($email);
351 351
         $pass = $user->getPassword();
352
-        if($pass !== false)
352
+        if ($pass !== false)
353 353
         {
354 354
             $new_user->setPass($pass);
355 355
         }
356 356
         $sn = $user->getLastName();
357
-        if($sn !== false)
357
+        if ($sn !== false)
358 358
         {
359 359
             $new_user->setLastName($sn);
360 360
         }
361 361
         $givenName = $user->getGivenName();
362
-        if($givenName !== false)
362
+        if ($givenName !== false)
363 363
         {
364 364
             $new_user->setGivenName($givenName);
365 365
         }
366 366
         $hosts = $user->getLoginProviders();
367
-        if($hosts !== false)
367
+        if ($hosts !== false)
368 368
         {
369 369
             $count = count($hosts);
370
-            for($i = 0; $i < $count; $i++)
370
+            for ($i = 0; $i < $count; $i++)
371 371
             {
372 372
                 $new_user->addLoginProvider($hosts[$i]);
373 373
             }
374 374
         }
375 375
         $ret = $new_user->flushUser();
376
-        if($ret)
376
+        if ($ret)
377 377
         {
378 378
             $user->delete();
379 379
         }
380 380
         $users = $this->getUsersByFilter(new \Data\Filter('mail eq '.$email));
381
-        if($users === false || !isset($users[0]))
381
+        if ($users === false || !isset($users[0]))
382 382
         {
383 383
             throw new \Exception('Error creating user!');
384 384
         }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     public function getUserByResetHash($hash)
389 389
     {
390 390
         $users = $this->getUsersByFilter(new \Data\Filter("uniqueIdentifier eq $hash"));
391
-        if($users === false || !isset($users[0]))
391
+        if ($users === false || !isset($users[0]))
392 392
         {
393 393
             return false;
394 394
         }
Please login to merge, or discard this patch.
Auth/class.SQLAuthenticator.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Auth;
3 3
 
4
-if(!function_exists('password_hash') || !function_exists('password_verify')) 
4
+if (!function_exists('password_hash') || !function_exists('password_verify')) 
5 5
 {
6 6
     define('PASSWORD_BCRYPT', 1);
7 7
     define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 
10 10
     function password_hash($password, $algo = PASSWORD_DEFAULT)
11 11
     {
12
-        if(is_null($password) || is_int($password))
12
+        if (is_null($password) || is_int($password))
13 13
         {
14 14
             $password = (string)$password;
15 15
         }
16
-        if(!is_string($password))
16
+        if (!is_string($password))
17 17
         {
18 18
             trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
19 19
             return false;
20 20
         }
21
-        if(!is_int($algo))
21
+        if (!is_int($algo))
22 22
         {
23
-            trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING);
23
+            trigger_error("password_hash() expects parameter 2 to be long, ".gettype($algo)." given", E_USER_WARNING);
24 24
             return false;
25 25
         }
26 26
         $resultLength = 0;
27
-        switch($algo)
27
+        switch ($algo)
28 28
         {
29 29
             case PASSWORD_BCRYPT:
30 30
                 $cost = PASSWORD_BCRYPT_DEFAULT_COST;
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         $base64String = base64_encode($salt);
44 44
         $salt = strtr(rtrim($base64String, '='), $base64Digits, $bcrypt64Digits);
45 45
         $salt = substr($salt, 0, $requiredSaltLen);
46
-        $hash = $hashFormat . $salt;
46
+        $hash = $hashFormat.$salt;
47 47
         $ret = crypt($password, $hash);
48
-        if(!is_string($ret) || strlen($ret) != $resultLength)
48
+        if (!is_string($ret) || strlen($ret) != $resultLength)
49 49
         {
50 50
             return false;
51 51
         }
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
     function password_verify($password, $hash)
56 56
     {
57 57
         $ret = crypt($password, $hash);
58
-        if(!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13)
58
+        if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13)
59 59
         {
60 60
             return false;
61 61
         }
62 62
         $status = 0;
63 63
         $count  = strlen($ret);
64
-        for($i = 0; $i < $count; $i++)
64
+        for ($i = 0; $i < $count; $i++)
65 65
         {
66 66
             $status |= (ord($ret[$i]) ^ ord($hash[$i]));
67 67
         }
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
     {
81 81
         parent::__construct($params);
82 82
         $this->params = $params;
83
-        if($this->current)
83
+        if ($this->current)
84 84
         {
85 85
             $this->dataSet = $this->getCurrentDataSet();
86 86
         }
87
-        if($this->pending)
87
+        if ($this->pending)
88 88
         {
89 89
             $this->pendingDataSet = $this->getPendingDataSet();
90 90
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     private function getCurrentDataSet()
97 97
     {
98
-        if(isset($this->params['current_data_set']))
98
+        if (isset($this->params['current_data_set']))
99 99
         {
100 100
             return \DataSetFactory::getDataSetByName($this->params['current_data_set']);
101 101
         }
@@ -107,30 +107,30 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private function getPendingDataSet()
109 109
     {
110
-        if(isset($this->params['pending_data_set']))
110
+        if (isset($this->params['pending_data_set']))
111 111
         {
112 112
             return \DataSetFactory::getDataSetByName($this->params['pending_data_set']);
113 113
         }
114 114
         return \DataSetFactory::getDataSetByName('pending_authentication');
115 115
     }
116 116
 
117
-    private function getDataTable($name, $pending=false)
117
+    private function getDataTable($name, $pending = false)
118 118
     {
119
-         if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending]))
119
+         if (isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending]))
120 120
          {
121 121
              return $this->dataTables[$name][$pending];
122 122
          }
123 123
          $dataSet = $this->dataSet;
124
-         if($pending)
124
+         if ($pending)
125 125
          {
126 126
              $dataSet = $this->pendingDataSet;
127 127
          }
128
-         if($dataSet === null)
128
+         if ($dataSet === null)
129 129
          {
130 130
              throw new \Exception('Unable to obtain dataset for SQL Authentication!');
131 131
          }
132 132
          $dataTable = $dataSet[$name];
133
-         if(!isset($this->dataTables[$name]))
133
+         if (!isset($this->dataTables[$name]))
134 134
          {
135 135
              $this->dataTables[$name] = array();
136 136
          }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     private function getPendingUserDataTable()
142 142
     {
143
-        if(isset($this->params['pending_user_table']))
143
+        if (isset($this->params['pending_user_table']))
144 144
         {
145 145
             return $this->getDataTable($this->params['pending_user_table'], true);
146 146
         }
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function login($username, $password)
151 151
     {
152
-        if($this->current === false) return false;
152
+        if ($this->current === false) return false;
153 153
         $userDataTable = $this->getDataTable('user');
154 154
         $filter = new \Data\Filter("uid eq '$username'");
155 155
         $users = $userDataTable->read($filter);
156
-        if($users === false || !isset($users[0]))
156
+        if ($users === false || !isset($users[0]))
157 157
         {
158 158
             return false;
159 159
         }
160
-        if(password_verify($password, $users[0]['pass']))
160
+        if (password_verify($password, $users[0]['pass']))
161 161
         {
162 162
             return array('res'=>true, 'extended'=>$users[0]);
163 163
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
     public function isLoggedIn($data)
168 168
     {
169
-        if(isset($data['res']))
169
+        if (isset($data['res']))
170 170
         {
171 171
             return $data['res'];
172 172
         }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
     public function getUser($data)
177 177
     {
178
-        if(isset($this->params['current_data_set']))
178
+        if (isset($this->params['current_data_set']))
179 179
         {
180 180
             $data['current_data_set'] = $this->params['current_data_set'];
181 181
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $groupDataTable = $this->getDataTable('group');
188 188
         $filter = new \Data\Filter("gid eq '$name'");
189 189
         $groups = $groupDataTable->read($filter);
190
-        if($groups === false || !isset($groups[0]))
190
+        if ($groups === false || !isset($groups[0]))
191 191
         {
192 192
             return false;
193 193
         }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $userDataTable = $this->getDataTable('user');
200 200
         $filter = new \Data\Filter("uid eq '$name'");
201 201
         $users = $userDataTable->read($filter);
202
-        if($users === false || !isset($users[0]))
202
+        if ($users === false || !isset($users[0]))
203 203
         {
204 204
             return false;
205 205
         }
@@ -215,33 +215,33 @@  discard block
 block discarded – undo
215 215
     private function convertDataToClass($dataTableName, $className, $filter, $select, $top, $skip, $orderby)
216 216
     {
217 217
         $data = $this->getDataByFilter($dataTableName, $filter, $select, $top, $skip, $orderby);
218
-        if($data === false)
218
+        if ($data === false)
219 219
         {
220 220
             return false;
221 221
         }
222 222
         $count = count($data);
223
-        for($i = 0; $i < $count; $i++)
223
+        for ($i = 0; $i < $count; $i++)
224 224
         {
225 225
             $data[$i] = new $className($groups[$i]);
226 226
         }
227 227
         return $data;
228 228
     }
229 229
 
230
-    public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
230
+    public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
231 231
     {
232 232
         return $this->convertDataToClass('group', 'SQLGroup', $filter, $select, $top, $skip, $orderby);
233 233
     }
234 234
 
235
-    public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
235
+    public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
236 236
     {
237 237
         return $this->convertDataToClass('group', 'SQLUser', $filter, $select, $top, $skip, $orderby);
238 238
     }
239 239
 
240 240
     public function getPendingUserCount()
241 241
     {
242
-        if($this->pending === false) return 0;
242
+        if ($this->pending === false) return 0;
243 243
         $dataTable = $this->getPendingUserDataTable();
244
-        if($dataTable === null) return 0;
244
+        if ($dataTable === null) return 0;
245 245
         return $dataTable->count();
246 246
     }
247 247
 
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $userDataTable = $this->getPendingUserDataTable();
251 251
         $fieldData = $filter->to_mongo_filter();
252
-        $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData,' ').'")');
252
+        $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData, ' ').'")');
253 253
         $users = $userDataTable->read($firstFilter, $select, $top, $skip, $orderby);
254
-        if($users === false)
254
+        if ($users === false)
255 255
         {
256 256
             return false;
257 257
         }
258 258
         $ret = array();
259 259
         $count = count($users);
260
-        for($i = 0; $i < $count; $i++)
260
+        for ($i = 0; $i < $count; $i++)
261 261
         {
262 262
             $user = new SQLPendingUser($users[$i], $userDataTable);
263 263
             $err = false;
264
-            foreach($fieldData as $field=>$data)
264
+            foreach ($fieldData as $field=>$data)
265 265
             {
266
-                if(strcasecmp($user[$field], $data) !== 0)
266
+                if (strcasecmp($user[$field], $data) !== 0)
267 267
                 {
268 268
                     $err = true; break;
269 269
                 }
270 270
             }
271
-            if(!$err)
271
+            if (!$err)
272 272
             {
273 273
                 array_push($ret, $user);
274 274
             }
@@ -276,22 +276,22 @@  discard block
 block discarded – undo
276 276
         return $ret;
277 277
     }
278 278
 
279
-    public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
279
+    public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
280 280
 
281 281
     {
282
-        if($this->pending === false) return false;
283
-        if($filter !== false && !$filter->contains('hash'))
282
+        if ($this->pending === false) return false;
283
+        if ($filter !== false && !$filter->contains('hash'))
284 284
         {
285 285
             return $this->searchPendingUsers($filter, $select, $top, $skip, $orderby);
286 286
         }
287 287
         $userDataTable = $this->getPendingUserDataTable();
288 288
         $users = $userDataTable->read($filter, $select, $top, $skip, $orderby);
289
-        if($users === false)
289
+        if ($users === false)
290 290
         {
291 291
             return false;
292 292
         }
293 293
         $count = count($users);
294
-        for($i = 0; $i < $count; $i++)
294
+        for ($i = 0; $i < $count; $i++)
295 295
         {
296 296
             $users[$i] = new SQLPendingUser($users[$i], $userDataTable);
297 297
         }
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
 
301 301
     public function createPendingUser($user)
302 302
     {
303
-        if($this->pending === false) return false;
303
+        if ($this->pending === false) return false;
304 304
         $userDataTable = $this->getPendingUserDataTable();
305
-        if(isset($user->password2))
305
+        if (isset($user->password2))
306 306
         {
307 307
             unset($user->password2);
308 308
         }
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
         $hash = hash('sha512', $json);
311 311
         $array = array('hash'=>$hash, 'data'=>$json);
312 312
         $ret = $userDataTable->create($array);
313
-        if($ret !== false)
313
+        if ($ret !== false)
314 314
         {
315 315
             $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'"));
316
-            if($users === false || !isset($users[0]))
316
+            if ($users === false || !isset($users[0]))
317 317
             {
318 318
                 throw new \Exception('Error retreiving user object after successful create!');
319 319
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     public function getTempUserByHash($hash)
326 326
     {
327 327
         $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'"));
328
-        if($users === false || !isset($users[0]))
328
+        if ($users === false || !isset($users[0]))
329 329
         {
330 330
             return false;
331 331
         }
Please login to merge, or discard this patch.
Auth/class.User.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
     public function getTitleNames()
129 129
     {
130 130
         $titles = $this->getTitles();
131
-        if($titles === false)
131
+        if ($titles === false)
132 132
         {
133 133
             return false;
134 134
         }
135
-        if(self::$titlenames === null)
135
+        if (self::$titlenames === null)
136 136
         {
137 137
             $dataSet = \DataSetFactory::getDataSetByName('profiles');
138 138
             $dataTable = $dataSet['position'];
139 139
             $titlenames = $dataTable->read();
140 140
             self::$titlenames = array();
141 141
             $count = count($titlenames);
142
-            for($i = 0; $i < $count; $i++)
142
+            for ($i = 0; $i < $count; $i++)
143 143
             {
144 144
                 self::$titlenames[$titlenames[$i]['short_name']] = $titlenames[$i];
145 145
             }
146 146
         }
147 147
         $count = count($titles);
148
-        for($i = 0; $i < $count; $i++)
148
+        for ($i = 0; $i < $count; $i++)
149 149
         {
150
-            if(isset(self::$titlenames[$titles[$i]]))
150
+            if (isset(self::$titlenames[$titles[$i]]))
151 151
             {
152 152
                 $title = self::$titlenames[$titles[$i]];
153 153
                 $titles[$i] = $title['name'];
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
     public function canLoginWith($provider)
281 281
     {
282 282
         $hosts = $this->getLoginProviders();
283
-        if($hosts === false) return false;
283
+        if ($hosts === false) return false;
284 284
         $count = count($hosts);
285
-        for($i = 0; $i < $count; $i++)
285
+        for ($i = 0; $i < $count; $i++)
286 286
         {
287
-            if(strcasecmp($hosts[$i], $provider) === 0) return true;
287
+            if (strcasecmp($hosts[$i], $provider) === 0) return true;
288 288
         }
289 289
         return false;
290 290
     }
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
      */
309 309
     public function isProfileComplete()
310 310
     {
311
-        if($this->getCountry() === false    || $this->getAddress() === false ||
311
+        if ($this->getCountry() === false || $this->getAddress() === false ||
312 312
            $this->getPostalCode() === false || $this->getCity() === false ||
313
-           $this->getState() === false      || $this->getPhoneNumber() === false)
313
+           $this->getState() === false || $this->getPhoneNumber() === false)
314 314
         {
315 315
             return false;
316 316
         }
@@ -354,17 +354,17 @@  discard block
 block discarded – undo
354 354
      *
355 355
      * @return true|false true if the user's password was changed, false otherwise
356 356
      */
357
-    public function change_pass($oldpass, $newpass, $isHash=false)
357
+    public function change_pass($oldpass, $newpass, $isHash = false)
358 358
     {
359
-        if($isHash === false && $this->validate_password($oldpass) === false)
359
+        if ($isHash === false && $this->validate_password($oldpass) === false)
360 360
         {
361 361
             throw new \Exception('Invalid Password!', 3);
362 362
         }
363
-        if($isHash === true && $this->validate_reset_hash($oldpass) === false)
363
+        if ($isHash === true && $this->validate_reset_hash($oldpass) === false)
364 364
         {
365 365
             throw new \Exception('Invalid Reset Hash!', 3);
366 366
         }
367
-        if($this->setPass($newpass) === false)
367
+        if ($this->setPass($newpass) === false)
368 368
         {
369 369
             throw new \Exception('Unable to set password!', 6);
370 370
         }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         //Make sure we are bound in write mode
598 598
         $auth = \AuthProvider::getInstance();
599 599
         $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator');
600
-        if($ldap !== false)
600
+        if ($ldap !== false)
601 601
         {
602 602
             $ldap->get_and_bind_server(true);
603 603
         }
@@ -608,14 +608,14 @@  discard block
 block discarded – undo
608 608
      */
609 609
     private function editUserPassword($data)
610 610
     {
611
-        if(isset($data->password))
611
+        if (isset($data->password))
612 612
         {
613
-            if(isset($data->oldpass))
613
+            if (isset($data->oldpass))
614 614
             {
615 615
                 $this->change_pass($data->oldpass, $data->password);
616 616
                 unset($data->oldpass);
617 617
             }
618
-            else if(isset($data->hash))
618
+            else if (isset($data->hash))
619 619
             {
620 620
                 $this->change_pass($data->hash, $data->password, true);
621 621
                 unset($data->hash);
@@ -626,22 +626,22 @@  discard block
 block discarded – undo
626 626
 
627 627
     private function editNames($data)
628 628
     {
629
-        if(isset($data->displayName))
629
+        if (isset($data->displayName))
630 630
         {
631 631
             $this->setDisplayName($data->displayName);
632 632
             unset($data->displayName);
633 633
         }
634
-        if(isset($data->givenName))
634
+        if (isset($data->givenName))
635 635
         {
636 636
             $this->setGivenName($data->givenName);
637 637
             unset($data->givenName);
638 638
         }
639
-        if(isset($data->sn))
639
+        if (isset($data->sn))
640 640
         {
641 641
             $this->setLastName($data->sn);
642 642
             unset($data->sn);
643 643
         }
644
-        if(isset($data->cn))
644
+        if (isset($data->cn))
645 645
         {
646 646
             $this->setNickName($data->cn);
647 647
             unset($data->cn);
@@ -650,17 +650,17 @@  discard block
 block discarded – undo
650 650
 
651 651
     private function checkForUnsettableElements($data)
652 652
     {
653
-        if(isset($data->mail))
653
+        if (isset($data->mail))
654 654
         {
655
-            if($data->mail !== $this->getEmail())
655
+            if ($data->mail !== $this->getEmail())
656 656
             {
657 657
                 throw new \Exception('Unable to change email!');
658 658
             }
659 659
             unset($data->mail);
660 660
         }
661
-        if(isset($data->uid))
661
+        if (isset($data->uid))
662 662
         {
663
-            if($data->uid !== $this->getUid())
663
+            if ($data->uid !== $this->getUid())
664 664
             {
665 665
                 throw new \Exception('Unable to change uid!');
666 666
             }
@@ -670,27 +670,27 @@  discard block
 block discarded – undo
670 670
 
671 671
     private function editAddressElements($data)
672 672
     {
673
-        if(isset($data->postalAddress))
673
+        if (isset($data->postalAddress))
674 674
         {
675 675
             $this->setAddress($data->postalAddress);
676 676
             unset($data->postalAddress);
677 677
         }
678
-        if(isset($data->l))
678
+        if (isset($data->l))
679 679
         {
680 680
             $this->setCity($data->l);
681 681
             unset($data->l);
682 682
         }
683
-        if(isset($data->st))
683
+        if (isset($data->st))
684 684
         {
685 685
             $this->setState($data->st);
686 686
             unset($data->st);
687 687
         }
688
-        if(isset($data->postalCode))
688
+        if (isset($data->postalCode))
689 689
         {
690 690
             $this->setPostalCode($data->postalCode);
691 691
             unset($data->postalCode);
692 692
         }
693
-        if(isset($data->c))
693
+        if (isset($data->c))
694 694
         {
695 695
             $this->setCountry($data->c);
696 696
             unset($data->c);
@@ -699,17 +699,17 @@  discard block
 block discarded – undo
699 699
 
700 700
     private function editOrganizationElements($data)
701 701
     {
702
-        if(isset($data->o))
702
+        if (isset($data->o))
703 703
         {
704 704
             $this->setOrganization($data->o);
705 705
             unset($data->o);
706 706
         }
707
-        if(isset($data->title))
707
+        if (isset($data->title))
708 708
         {
709 709
             $this->setTitles($data->title);
710 710
             unset($data->title);
711 711
         }
712
-        if(isset($data->ou))
712
+        if (isset($data->ou))
713 713
         {
714 714
             $this->setOrganizationUnits($data->ou);
715 715
             unset($data->ou);
@@ -733,12 +733,12 @@  discard block
 block discarded – undo
733 733
         $this->editAddressElements($data);
734 734
         $this->editOrganizationElements($data);
735 735
 
736
-        if(isset($data->jpegPhoto))
736
+        if (isset($data->jpegPhoto))
737 737
         {
738 738
             $this->setPhoto(base64_decode($data->jpegPhoto));
739 739
             unset($data->jpegPhoto);
740 740
         }
741
-        if(isset($data->mobile))
741
+        if (isset($data->mobile))
742 742
         {
743 743
             $this->setPhoneNumber($data->mobile);
744 744
             unset($data->mobile);
@@ -793,17 +793,17 @@  discard block
 block discarded – undo
793 793
     public function getVcard()
794 794
     {
795 795
         $ret = "BEGIN:VCARD\nVERSION:2.1\n";
796
-        $ret.= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n";
797
-        $ret.= 'FN:'.$this->getGivenName()."\n";
796
+        $ret .= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n";
797
+        $ret .= 'FN:'.$this->getGivenName()."\n";
798 798
         $titles = $this->getTitles();
799
-        if($titles !== false)
799
+        if ($titles !== false)
800 800
         {
801
-            $ret.= 'TITLE:'.implode(',', $titles)."\n";
801
+            $ret .= 'TITLE:'.implode(',', $titles)."\n";
802 802
         }
803
-        $ret.= "ORG: Austin Artistic Reconstruction\n";
804
-        $ret.= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n";
805
-        $ret.= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n";
806
-        $ret.= "END:VCARD\n";
803
+        $ret .= "ORG: Austin Artistic Reconstruction\n";
804
+        $ret .= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n";
805
+        $ret .= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n";
806
+        $ret .= "END:VCARD\n";
807 807
         return $ret;
808 808
     }
809 809
 }
Please login to merge, or discard this patch.
Auth/class.LDAPCachableObject.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
         {
10 10
             return $this->server->update($obj);
11 11
         }
12
-        catch(\Exception $ex)
12
+        catch (\Exception $ex)
13 13
         {
14 14
             $auth = \AuthProvider::getInstance();
15 15
             $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator');
16
-            if($ldap === false) return false;
16
+            if ($ldap === false) return false;
17 17
             $this->server = $ldap->get_and_bind_server(true);
18 18
             return $this->server->update($obj);
19 19
         }
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     protected function getField($fieldName)
23 23
     {
24
-        if(!is_object($this->ldapObj))
24
+        if (!is_object($this->ldapObj))
25 25
         {
26 26
             return $this->getFieldLocal($fieldName);
27 27
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
     protected function getFieldSingleValue($fieldName)
32 32
     {
33
-        if(!is_object($this->ldapObj))
33
+        if (!is_object($this->ldapObj))
34 34
         {
35 35
             return $this->getFieldLocalSingleValue($fieldName);
36 36
         }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     protected function setField($fieldName, $fieldValue)
41 41
     {
42
-        if(!is_object($this->ldapObj))
42
+        if (!is_object($this->ldapObj))
43 43
         {
44 44
             return $this->setFieldLocal($fieldName, $fieldValue);
45 45
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected function appendField($fieldName, $fieldValue)
50 50
     {
51
-        if(!is_object($this->ldapObj))
51
+        if (!is_object($this->ldapObj))
52 52
         {
53 53
             return $this->appendFieldLocal($fieldName, $fieldValue);
54 54
         }
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 
58 58
     private function getFieldLocal($fieldName)
59 59
     {
60
-        if($this->ldapObj === false)
60
+        if ($this->ldapObj === false)
61 61
         {
62 62
             return false;
63 63
         }
64
-        if(!isset($this->ldapObj[$fieldName]))
64
+        if (!isset($this->ldapObj[$fieldName]))
65 65
         {
66 66
             return false;
67 67
         }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     private function getFieldServer($fieldName)
72 72
     {
73 73
         $lowerName = strtolower($fieldName);
74
-        if(!isset($this->ldapObj->{$lowerName}))
74
+        if (!isset($this->ldapObj->{$lowerName}))
75 75
         {
76 76
             return false;
77 77
         }
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 
81 81
     private function getFieldLocalSingleValue($fieldName)
82 82
     {
83
-        if($this->ldapObj === false)
83
+        if ($this->ldapObj === false)
84 84
         {
85 85
             return false;
86 86
         }
87
-        if(!isset($this->ldapObj[$fieldName]))
87
+        if (!isset($this->ldapObj[$fieldName]))
88 88
         {
89 89
             return false;
90 90
         }
91
-        if(is_array($this->ldapObj[$fieldName]))
91
+        if (is_array($this->ldapObj[$fieldName]))
92 92
         {
93 93
             return $this->ldapObj[$fieldName][0];
94 94
         }
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
     private function getFieldServerSingleValue($fieldName)
99 99
     {
100 100
         $lowerName = strtolower($fieldName);
101
-        if(!isset($this->ldapObj->{$lowerName}))
101
+        if (!isset($this->ldapObj->{$lowerName}))
102 102
         {
103 103
             return false;
104 104
         }
105 105
         $field = $this->ldapObj->{$lowerName};
106
-        if(!isset($field[0]))
106
+        if (!isset($field[0]))
107 107
         {
108 108
             return false;
109 109
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     private function setFieldServer($fieldName, $fieldValue)
114 114
     {
115 115
         $obj = array('dn'=>$this->ldapObj->dn);
116
-        if($fieldValue !== null && strlen($fieldValue) > 0)
116
+        if ($fieldValue !== null && strlen($fieldValue) > 0)
117 117
         {
118 118
             $obj[$fieldName] = $fieldValue;
119 119
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     private function appendFieldServer($fieldName, $fieldValue)
130 130
     {
131 131
         $obj = array('dn'=>$this->ldapObj->dn);
132
-        if(isset($this->ldapObj->{$fieldName}))
132
+        if (isset($this->ldapObj->{$fieldName}))
133 133
         {
134 134
             $obj[$fieldName] = $this->ldapObj->{$fieldName};
135 135
             $obj[$fieldName][$obj[$fieldName]['count']] = $fieldValue;
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
     private function setFieldLocal($fieldName, $fieldValue)
146 146
     {
147
-        if($this->ldapObj === false)
147
+        if ($this->ldapObj === false)
148 148
         {
149 149
             $this->ldapObj = array();
150 150
         }
151
-        if($fieldValue === null || (is_string($fieldValue) && strlen($fieldValue) === 0))
151
+        if ($fieldValue === null || (is_string($fieldValue) && strlen($fieldValue) === 0))
152 152
         {
153
-            if(isset($this->ldapObj[$fieldName]))
153
+            if (isset($this->ldapObj[$fieldName]))
154 154
             {
155 155
                 unset($this->ldapObj[$fieldName]);
156 156
             }
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
     private function appendFieldLocal($fieldName, $fieldValue)
164 164
     {
165
-        if($this->ldapObj === false)
165
+        if ($this->ldapObj === false)
166 166
         {
167 167
             $this->ldapObj = array();
168 168
         }
169
-        if(!isset($this->ldapObj[$fieldName]))
169
+        if (!isset($this->ldapObj[$fieldName]))
170 170
         {
171 171
             $this->ldapObj[$fieldName] = array();
172 172
         }
Please login to merge, or discard this patch.
class.AuthProvider.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  * Require the FlipsideSettings file
20 20
  */
21
-if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC']))
21
+if (isset($GLOBALS['FLIPSIDE_SETTINGS_LOC']))
22 22
 {
23 23
     require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php');
24 24
 }
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     protected function __construct()
44 44
     {
45 45
         $this->methods = array();
46
-        if(isset(FlipsideSettings::$authProviders))
46
+        if (isset(FlipsideSettings::$authProviders))
47 47
         {
48 48
             $keys = array_keys(FlipsideSettings::$authProviders);
49 49
             $count = count($keys);
50
-            for($i = 0; $i < $count; $i++)
50
+            for ($i = 0; $i < $count; $i++)
51 51
             {
52 52
                 $class = $keys[$i];
53 53
                 array_push($this->methods, new $class(FlipsideSettings::$authProviders[$keys[$i]]));
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     public function getAuthenticator($methodName)
66 66
     {
67 67
         $count = count($this->methods);
68
-        for($i = 0; $i < $count; $i++)
68
+        for ($i = 0; $i < $count; $i++)
69 69
         {
70
-            if(strcasecmp(get_class($this->methods[$i]), $methodName) === 0)
70
+            if (strcasecmp(get_class($this->methods[$i]), $methodName) === 0)
71 71
             {
72 72
                 return $this->methods[$i];
73 73
             }
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $res = false;
91 91
         $count = count($this->methods);
92
-        for($i = 0; $i < $count; $i++)
92
+        for ($i = 0; $i < $count; $i++)
93 93
         {
94 94
             $res = $this->methods[$i]->login($username, $password);
95
-            if($res !== false)
95
+            if ($res !== false)
96 96
             {
97 97
                 return $this->methods[$i]->getUser($res);
98 98
             }
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
     {
113 113
         $res = false;
114 114
         $count = count($this->methods);
115
-        for($i = 0; $i < $count; $i++)
115
+        for ($i = 0; $i < $count; $i++)
116 116
         {
117 117
             $res = $this->methods[$i]->login($username, $password);
118
-            if($res !== false)
118
+            if ($res !== false)
119 119
             {
120 120
                 FlipSession::setVar('AuthMethod', get_class($this->methods[$i]));
121 121
                 FlipSession::setVar('AuthData', $res);
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function mergeResult(&$returnValue, $res)
165 165
     {
166
-        if($res === false)
166
+        if ($res === false)
167 167
         {
168 168
             return;
169 169
         }
170
-        if($returnValue === false)
170
+        if ($returnValue === false)
171 171
         {
172 172
             $returnValue = $res;
173 173
             return;
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
     {
190 190
         $ret = false;
191 191
         $count = count($this->methods);
192
-        for($i = 0; $i < $count; $i++)
192
+        for ($i = 0; $i < $count; $i++)
193 193
         {
194
-            if($checkField)
194
+            if ($checkField)
195 195
             {
196
-                if($this->methods[$i]->{$checkField} === $checkValue)
196
+                if ($this->methods[$i]->{$checkField} === $checkValue)
197 197
                 {
198 198
                     continue;
199 199
                 }
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
     {
218 218
         $retCount = 0;
219 219
         $count = count($this->methods);
220
-        for($i = 0; $i < $count; $i++)
220
+        for ($i = 0; $i < $count; $i++)
221 221
         {
222
-            if($checkField)
222
+            if ($checkField)
223 223
             {
224
-                if($this->methods[$i]->{$checkField} === $checkValue)
224
+                if ($this->methods[$i]->{$checkField} === $checkValue)
225 225
                 {
226 226
                     continue;
227 227
                 }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function getGroupByName($name, $methodName = false)
244 244
     {
245
-        if($methodName === false)
245
+        if ($methodName === false)
246 246
         {
247 247
             return $this->callOnEach('getGroupByName', array($name));
248 248
         }
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
      *
263 263
      * @return array|false An array of Auth\User objects or false if no users were found
264 264
      */
265
-    public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false, $methodName = false)
265
+    public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false, $methodName = false)
266 266
     {
267
-        if($methodName === false)
267
+        if ($methodName === false)
268 268
         {
269 269
             return $this->callOnEach('getUsersByFilter', array($filter, $select, $top, $skip, $orderby), 'current');
270 270
         }
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
      *
285 285
      * @return array|false An array of Auth\PendingUser objects or false if no pending users were found
286 286
      */
287
-    public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false, $methodName = false)
287
+    public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false, $methodName = false)
288 288
     {
289
-        if($methodName === false)
289
+        if ($methodName === false)
290 290
         {
291 291
             return $this->callOnEach('getPendingUsersByFilter', array($filter, $select, $top, $skip, $orderby), 'pending');
292 292
         }
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
      *
307 307
      * @return array|false An array of Auth\Group objects or false if no pending users were found
308 308
      */
309
-    public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false, $methodName = false)
309
+    public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false, $methodName = false)
310 310
     {
311
-        if($methodName === false)
311
+        if ($methodName === false)
312 312
         {
313 313
             return $this->callOnEach('getGroupsByFilter', array($filter, $select, $top, $skip, $orderby), 'current');
314 314
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      */
326 326
     public function getActiveUserCount($methodName = false)
327 327
     {
328
-        if($methodName === false)
328
+        if ($methodName === false)
329 329
         {
330 330
             return $this->addFromEach('getActiveUserCount', 'current');
331 331
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function getPendingUserCount($methodName = false)
344 344
     {
345
-        if($methodName === false)
345
+        if ($methodName === false)
346 346
         {
347 347
             return $this->addFromEach('getPendingUserCount', 'pending');
348 348
         }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      */
360 360
     public function getGroupCount($methodName = false)
361 361
     {
362
-        if($methodName === false)
362
+        if ($methodName === false)
363 363
         {
364 364
             return $this->addFromEach('getGroupCount', 'current');
365 365
         }
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
     {
380 380
         $ret = array();
381 381
         $count = count($this->methods);
382
-        for($i = 0; $i < $count; $i++)
382
+        for ($i = 0; $i < $count; $i++)
383 383
         {
384
-            if($this->methods[$i]->supplement === false) continue;
384
+            if ($this->methods[$i]->supplement === false) continue;
385 385
 
386 386
             array_push($ret, $this->methods[$i]->getSupplementLink());
387 387
         }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function impersonateUser($userArray)
400 400
     {
401
-        if(!is_object($userArray))
401
+        if (!is_object($userArray))
402 402
         {
403 403
             $user = new $userArray['class']($userArray);
404 404
         }
@@ -415,15 +415,15 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function getTempUserByHash($hash, $methodName = false)
417 417
     {
418
-        if($methodName === false)
418
+        if ($methodName === false)
419 419
         {
420 420
             $count = count($this->methods);
421
-            for($i = 0; $i < $count; $i++)
421
+            for ($i = 0; $i < $count; $i++)
422 422
             {
423
-                if($this->methods[$i]->pending === false) continue;
423
+                if ($this->methods[$i]->pending === false) continue;
424 424
 
425 425
                 $ret = $this->methods[$i]->getTempUserByHash($hash);
426
-                if($ret !== false)
426
+                if ($ret !== false)
427 427
                 {
428 428
                     return $ret;
429 429
                 }
@@ -444,15 +444,15 @@  discard block
 block discarded – undo
444 444
      */
445 445
     public function createPendingUser($user, $methodName = false)
446 446
     {
447
-        if($methodName === false)
447
+        if ($methodName === false)
448 448
         {
449 449
             $count = count($this->methods);
450
-            for($i = 0; $i < $count; $i++)
450
+            for ($i = 0; $i < $count; $i++)
451 451
             {
452
-                if($this->methods[$i]->pending === false) continue;
452
+                if ($this->methods[$i]->pending === false) continue;
453 453
 
454 454
                 $ret = $this->methods[$i]->createPendingUser($user);
455
-                if($ret !== false)
455
+                if ($ret !== false)
456 456
                 {
457 457
                     return true;
458 458
                 }
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
      */
477 477
     public function activatePendingUser($user, $methodName = false)
478 478
     {
479
-        if($methodName === false)
479
+        if ($methodName === false)
480 480
         {
481 481
             $count = count($this->methods);
482
-            for($i = 0; $i < $count; $i++)
482
+            for ($i = 0; $i < $count; $i++)
483 483
             {
484
-                if($this->methods[$i]->current === false) continue;
484
+                if ($this->methods[$i]->current === false) continue;
485 485
 
486 486
                 $ret = $this->methods[$i]->activatePendingUser($user);
487
-                if($ret !== false)
487
+                if ($ret !== false)
488 488
                 {
489 489
                     $this->impersonateUser($ret);
490 490
                     return true;
@@ -506,15 +506,15 @@  discard block
 block discarded – undo
506 506
      */
507 507
     public function getUserByResetHash($hash, $methodName = false)
508 508
     {
509
-        if($methodName === false)
509
+        if ($methodName === false)
510 510
         {
511 511
             $count = count($this->methods);
512
-            for($i = 0; $i < $count; $i++)
512
+            for ($i = 0; $i < $count; $i++)
513 513
             {
514
-                if($this->methods[$i]->current === false) continue;
514
+                if ($this->methods[$i]->current === false) continue;
515 515
 
516 516
                 $ret = $this->methods[$i]->getUserByResetHash($hash);
517
-                if($ret !== false)
517
+                if ($ret !== false)
518 518
                 {
519 519
                     return $ret;
520 520
                 }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
             return false;
523 523
         }
524 524
         $auth = $this->getAuthenticator($methodName);
525
-        if($auth === false)
525
+        if ($auth === false)
526 526
         {
527 527
             return $this->getUserByResetHash($hash, false);
528 528
         }
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
     public function getSuplementalProviderByHost($host)
540 540
     {
541 541
         $count = count($this->methods);
542
-        for($i = 0; $i < $count; $i++)
542
+        for ($i = 0; $i < $count; $i++)
543 543
         {
544
-            if($this->methods[$i]->supplement === false) continue;
544
+            if ($this->methods[$i]->supplement === false) continue;
545 545
 
546
-            if($this->methods[$i]->getHostName() === $host)
546
+            if ($this->methods[$i]->getHostName() === $host)
547 547
             {
548 548
                 return $this->methods[$i];
549 549
             }
@@ -551,32 +551,32 @@  discard block
 block discarded – undo
551 551
         return false;
552 552
     }
553 553
 
554
-    public function deletePendingUsersByFilter($filter, $methodName=false)
554
+    public function deletePendingUsersByFilter($filter, $methodName = false)
555 555
     {
556 556
         $users = $this->getPendingUsersByFilter($filter, false, false, false, false, $methodName);
557
-        if($users === false)
557
+        if ($users === false)
558 558
         {
559 559
             return false;
560 560
         }
561 561
         $count = count($users);
562
-        for($i = 0; $i < $count; $i++)
562
+        for ($i = 0; $i < $count; $i++)
563 563
         {
564 564
             $users[$i]->delete();
565 565
         }
566 566
         return true;
567 567
     }
568 568
 
569
-    public function getUserByAccessCode($key, $methodName=false)
569
+    public function getUserByAccessCode($key, $methodName = false)
570 570
     {
571
-        if($methodName === false)
571
+        if ($methodName === false)
572 572
         {
573 573
             $count = count($this->methods);
574
-            for($i = 0; $i < $count; $i++)
574
+            for ($i = 0; $i < $count; $i++)
575 575
             {
576
-                if($this->methods[$i]->current === false) continue;
576
+                if ($this->methods[$i]->current === false) continue;
577 577
 
578 578
                 $ret = $this->methods[$i]->getUserByAccessCode($key);
579
-                if($ret !== false)
579
+                if ($ret !== false)
580 580
                 {
581 581
                     return $ret;
582 582
                 }
Please login to merge, or discard this patch.
Auth/class.SQLUser.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
     private $data;
7 7
     private $auth;
8 8
 
9
-    function __construct($data=false, $auth=false)
9
+    function __construct($data = false, $auth = false)
10 10
     {
11 11
         $this->data = array();
12 12
         $this->auth = $auth;
13
-        if($data !== false)
13
+        if ($data !== false)
14 14
         {
15 15
             $this->data = $data;
16
-            if(isset($data['extended']))
16
+            if (isset($data['extended']))
17 17
             {
18 18
                 $this->data = $data['extended'];
19 19
             }
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
     function isInGroupNamed($name)
24 24
     {
25
-        if($this->auth === false)
25
+        if ($this->auth === false)
26 26
         {
27 27
             return false;
28 28
         }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $uid = $this->getUid();
32 32
         $filter = new \Data\Filter("uid eq '$uid' and gid eq '$name'");
33 33
         $groups = $group_data_table->read($filter);
34
-        if($groups === false || !isset($groups[0]))
34
+        if ($groups === false || !isset($groups[0]))
35 35
         {
36 36
             return false;
37 37
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     function getEmail()
43 43
     {
44
-        if(isset($this->data['mail']))
44
+        if (isset($this->data['mail']))
45 45
         {
46 46
              return $this->data['mail'];
47 47
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     function getUid()
52 52
     {
53
-        if(isset($this->data['uid']))
53
+        if (isset($this->data['uid']))
54 54
         {
55 55
             return $this->data['uid'];
56 56
         }
Please login to merge, or discard this patch.
Serialize/class.JSONSerializer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
     public function supportsType($type)
9 9
     {
10
-        foreach($this->types as $t)
10
+        foreach ($this->types as $t)
11 11
         {
12
-            if(strcasecmp($t, $type) === 0)
12
+            if (strcasecmp($t, $type) === 0)
13 13
             {
14 14
                 return true;
15 15
             }
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  
20 20
     public function serializeData($type, $array)
21 21
     {
22
-        if($this->supportsType($type) === false)
22
+        if ($this->supportsType($type) === false)
23 23
         {
24 24
             return null;
25 25
         }
Please login to merge, or discard this patch.
Serialize/class.CSVSerializer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@
 block discarded – undo
7 7
 
8 8
     public function serializeData($type, $array)
9 9
     {
10
-        if($this->supportsType($type) === false)
10
+        if ($this->supportsType($type) === false)
11 11
         {
12 12
             return null;
13 13
         }
14
-        if(count($array) === 0)
14
+        if (count($array) === 0)
15 15
         {
16 16
             return null;
17 17
         }
18 18
         $data = $this->getArray($array);
19 19
         ob_start();
20 20
         $df = fopen("php://output", 'w');
21
-        foreach($data as $row)
21
+        foreach ($data as $row)
22 22
         {
23 23
             fputcsv($df, $row);
24 24
         }
Please login to merge, or discard this patch.
Serialize/class.SpreadSheetSerializer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 {
6 6
     public function supportsType($type)
7 7
     {
8
-        foreach($this->types as $t)
8
+        foreach ($this->types as $t)
9 9
         {
10
-            if(strcasecmp($t, $type) === 0)
10
+            if (strcasecmp($t, $type) === 0)
11 11
             {
12 12
                 return true;
13 13
             }
@@ -18,42 +18,42 @@  discard block
 block discarded – undo
18 18
     protected function getArray(&$array)
19 19
     {
20 20
         $res = array();
21
-        if(is_object($array))
21
+        if (is_object($array))
22 22
         {
23 23
             $array = get_object_vars($array);
24 24
         }
25 25
         $first = reset($array);
26 26
         $keys = false;
27
-        if(is_array($first))
27
+        if (is_array($first))
28 28
         {
29 29
             $keys = array_keys($first);
30 30
         }
31
-        else if(is_object($first))
31
+        else if (is_object($first))
32 32
         {
33 33
             $keys = array_keys(get_object_vars($first));
34 34
         }
35 35
         $colCount = count($keys);
36 36
         $res[] = $keys;
37
-        foreach($array as $row)
37
+        foreach ($array as $row)
38 38
         {
39 39
             $tmp = array();
40
-            if(is_object($row))
40
+            if (is_object($row))
41 41
             {
42 42
                 $row = get_object_vars($row);
43 43
             }
44
-            if(!is_array($row))
44
+            if (!is_array($row))
45 45
             {
46 46
                 $row = array($row);
47 47
             }
48
-            for($j = 0; $j < $colCount; $j++)
48
+            for ($j = 0; $j < $colCount; $j++)
49 49
             {
50 50
                 $colName = $keys[$j];
51
-                if(isset($row[$colName]))
51
+                if (isset($row[$colName]))
52 52
                 {
53 53
                     $value = $row[$colName];
54
-                    if(is_object($value))
54
+                    if (is_object($value))
55 55
                     {
56
-                        switch($colName)
56
+                        switch ($colName)
57 57
                         {
58 58
                             case '_id':
59 59
                                 $value = $value->{'$id'};
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                                 break;
64 64
                         }
65 65
                     }
66
-                    else if(is_array($value))
66
+                    else if (is_array($value))
67 67
                     {
68 68
                         $value = implode(',', $value);
69 69
                     }
Please login to merge, or discard this patch.