@@ -18,7 +18,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,15 +551,15 @@ discard block |
||
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 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Auth; |
3 | -if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
|
3 | +if (isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
|
4 | 4 | { |
5 | 5 | require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php'); |
6 | 6 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | $this->ldapObj = $data; |
22 | 22 | $this->server = \LDAP\LDAPServer::getInstance(); |
23 | - if(!is_object($data)) |
|
23 | + if (!is_object($data)) |
|
24 | 24 | { |
25 | 25 | throw new \Exception('Unable to setup LDAPGroup!'); |
26 | 26 | } |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | { |
46 | 46 | $rawMembers = $this->getField('member'); |
47 | 47 | $fieldName = 'member'; |
48 | - if($rawMembers === false) |
|
48 | + if ($rawMembers === false) |
|
49 | 49 | { |
50 | 50 | $rawMembers = $this->getField('uniqueMember'); |
51 | 51 | $fieldName = 'uniqueMember'; |
52 | 52 | } |
53 | - if($rawMembers === false) |
|
53 | + if ($rawMembers === false) |
|
54 | 54 | { |
55 | 55 | $rawMembers = $this->getField('memberUid'); |
56 | 56 | $fieldName = 'memberUid'; |
57 | 57 | } |
58 | - if(!isset($rawMembers['count'])) |
|
58 | + if (!isset($rawMembers['count'])) |
|
59 | 59 | { |
60 | 60 | $rawMembers['count'] = count($rawMembers); |
61 | 61 | } |
@@ -65,23 +65,23 @@ discard block |
||
65 | 65 | private function getIDFromDN($dn) |
66 | 66 | { |
67 | 67 | $split = explode(',', $dn); |
68 | - if(strncmp('cn=', $split[0], 3) === 0) |
|
68 | + if (strncmp('cn=', $split[0], 3) === 0) |
|
69 | 69 | { |
70 | 70 | return substr($split[0], 3); |
71 | 71 | } |
72 | 72 | return substr($split[0], 4); |
73 | 73 | } |
74 | 74 | |
75 | - public function getMemberUids($recursive=true) |
|
75 | + public function getMemberUids($recursive = true) |
|
76 | 76 | { |
77 | 77 | $members = array(); |
78 | 78 | $rawMembers = $this->getMembersField(); |
79 | - for($i = 0; $i < $rawMembers['count']; $i++) |
|
79 | + for ($i = 0; $i < $rawMembers['count']; $i++) |
|
80 | 80 | { |
81 | - if($recursive && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
81 | + if ($recursive && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
82 | 82 | { |
83 | 83 | $child = self::from_dn($rawMembers[$i], $this->server); |
84 | - if($child !== false) |
|
84 | + if ($child !== false) |
|
85 | 85 | { |
86 | 86 | $members = array_merge($members, $child->members()); |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | $count = count($members); |
95 | - for($i = 0; $i < $count; $i++) |
|
95 | + for ($i = 0; $i < $count; $i++) |
|
96 | 96 | { |
97 | 97 | $members[$i] = $this->getIDFromDN($members[$i]); |
98 | 98 | } |
@@ -102,36 +102,36 @@ discard block |
||
102 | 102 | private function getObjectFromDN($dn) |
103 | 103 | { |
104 | 104 | $split = explode(',', $dn); |
105 | - if(strncmp('cn=', $dn, 3) === 0) |
|
105 | + if (strncmp('cn=', $dn, 3) === 0) |
|
106 | 106 | { |
107 | - if(count($split) === 1) |
|
107 | + if (count($split) === 1) |
|
108 | 108 | { |
109 | 109 | return LDAPGroup::from_name($dn, $this->server); |
110 | 110 | } |
111 | 111 | return LDAPGroup::from_name(substr($split[0], 3), $this->server); |
112 | 112 | } |
113 | - if(count($split) === 1) |
|
113 | + if (count($split) === 1) |
|
114 | 114 | { |
115 | 115 | return LDAPUser::from_name($dn, $this->server); |
116 | 116 | } |
117 | 117 | return LDAPUser::from_name(substr($split[0], 4), $this->server); |
118 | 118 | } |
119 | 119 | |
120 | - public function members($details=false, $recursive=true, $includeGroups=true) |
|
120 | + public function members($details = false, $recursive = true, $includeGroups = true) |
|
121 | 121 | { |
122 | 122 | $members = array(); |
123 | 123 | $rawMembers = $this->getMembersField(); |
124 | - for($i = 0; $i < $rawMembers['count']; $i++) |
|
124 | + for ($i = 0; $i < $rawMembers['count']; $i++) |
|
125 | 125 | { |
126 | - if($recursive && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
126 | + if ($recursive && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
127 | 127 | { |
128 | 128 | $child = self::from_dn($rawMembers[$i], $this->server); |
129 | - if($child !== false) |
|
129 | + if ($child !== false) |
|
130 | 130 | { |
131 | 131 | $members = array_merge($members, $child->members()); |
132 | 132 | } |
133 | 133 | } |
134 | - else if($includeGroups === false && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
134 | + else if ($includeGroups === false && strncmp($rawMembers[$i], 'cn=', 3) === 0) |
|
135 | 135 | { |
136 | 136 | //Drop this member |
137 | 137 | } |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | array_push($members, $rawMembers[$i]); |
141 | 141 | } |
142 | 142 | } |
143 | - if($details === true) |
|
143 | + if ($details === true) |
|
144 | 144 | { |
145 | 145 | $details = array(); |
146 | 146 | $count = count($members); |
147 | - for($i = 0; $i < $count; $i++) |
|
147 | + for ($i = 0; $i < $count; $i++) |
|
148 | 148 | { |
149 | 149 | $details[$i] = $this->getObjectFromDN($members[$i]); |
150 | 150 | } |
@@ -154,37 +154,37 @@ discard block |
||
154 | 154 | return $members; |
155 | 155 | } |
156 | 156 | |
157 | - public function getNonMemebers($select=false) |
|
157 | + public function getNonMemebers($select = false) |
|
158 | 158 | { |
159 | 159 | $data = array(); |
160 | 160 | $groupFilter = '(&(cn=*)(!(cn='.$this->getGroupName().'))'; |
161 | 161 | $userFilter = '(&(cn=*)'; |
162 | 162 | $members = $this->members(); |
163 | 163 | $count = count($members); |
164 | - for($i = 0; $i < $count; $i++) |
|
164 | + for ($i = 0; $i < $count; $i++) |
|
165 | 165 | { |
166 | - $dnComps = explode(',',$members[$i]); |
|
167 | - if(strncmp($members[$i], "uid=", 4) == 0) |
|
166 | + $dnComps = explode(',', $members[$i]); |
|
167 | + if (strncmp($members[$i], "uid=", 4) == 0) |
|
168 | 168 | { |
169 | - $userFilter.='(!('.$dnComps[0].'))'; |
|
169 | + $userFilter .= '(!('.$dnComps[0].'))'; |
|
170 | 170 | } |
171 | 171 | else |
172 | 172 | { |
173 | - $groupFilter.='(!('.$dnComps[0].'))'; |
|
173 | + $groupFilter .= '(!('.$dnComps[0].'))'; |
|
174 | 174 | } |
175 | 175 | } |
176 | - $userFilter.=')'; |
|
177 | - $groupFilter.=')'; |
|
176 | + $userFilter .= ')'; |
|
177 | + $groupFilter .= ')'; |
|
178 | 178 | $groups = $this->server->read($this->server->group_base, $groupFilter); |
179 | 179 | $count = count($groups); |
180 | - for($i = 0; $i < $count; $i++) |
|
180 | + for ($i = 0; $i < $count; $i++) |
|
181 | 181 | { |
182 | - if($groups[$i] === false || $groups[$i] === null) continue; |
|
182 | + if ($groups[$i] === false || $groups[$i] === null) continue; |
|
183 | 183 | array_push($data, new LDAPGroup($groups[$i])); |
184 | 184 | } |
185 | 185 | $users = $this->server->read($this->server->user_base, $userFilter, false, $select); |
186 | 186 | $count = count($users); |
187 | - for($i = 0; $i < $count; $i++) |
|
187 | + for ($i = 0; $i < $count; $i++) |
|
188 | 188 | { |
189 | 189 | array_push($data, new LDAPUser($users[$i])); |
190 | 190 | } |
@@ -193,24 +193,24 @@ discard block |
||
193 | 193 | |
194 | 194 | public function clearMembers() |
195 | 195 | { |
196 | - if(isset($this->ldapObj['member'])) |
|
196 | + if (isset($this->ldapObj['member'])) |
|
197 | 197 | { |
198 | 198 | $this->ldapObj['member'] = array(); |
199 | 199 | } |
200 | - else if(isset($this->ldapObj['uniquemember'])) |
|
200 | + else if (isset($this->ldapObj['uniquemember'])) |
|
201 | 201 | { |
202 | 202 | $this->ldapObj['uniquemember'] = array(); |
203 | 203 | } |
204 | - else if(isset($this->ldapObj['memberuid'])) |
|
204 | + else if (isset($this->ldapObj['memberuid'])) |
|
205 | 205 | { |
206 | 206 | $this->ldapObj['memberuid'] = array(); |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - public function addMember($name, $isGroup=false, $flush=true) |
|
210 | + public function addMember($name, $isGroup = false, $flush = true) |
|
211 | 211 | { |
212 | 212 | $dn = false; |
213 | - if($isGroup) |
|
213 | + if ($isGroup) |
|
214 | 214 | { |
215 | 215 | $dn = 'cn='.$name.','.$this->server->group_base; |
216 | 216 | } |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | } |
221 | 221 | $propName = false; |
222 | 222 | $rawMembers = $this->getMembersField($propName); |
223 | - if(isset($rawMembers['count'])) |
|
223 | + if (isset($rawMembers['count'])) |
|
224 | 224 | { |
225 | 225 | unset($rawMembers['count']); |
226 | 226 | } |
227 | - if(in_array($dn, $rawMembers) || in_array($name, $rawMembers)) |
|
227 | + if (in_array($dn, $rawMembers) || in_array($name, $rawMembers)) |
|
228 | 228 | { |
229 | 229 | return true; |
230 | 230 | } |
231 | - if($propName === 'memberUid') |
|
231 | + if ($propName === 'memberUid') |
|
232 | 232 | { |
233 | - if($isGroup) |
|
233 | + if ($isGroup) |
|
234 | 234 | { |
235 | 235 | throw new \Exception('Unable to add a group as a child of this group type'); |
236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | $tmp = strtolower($propName); |
244 | 244 | $this->ldapObj->$tmp = $rawMembers; |
245 | - if($flush === true) |
|
245 | + if ($flush === true) |
|
246 | 246 | { |
247 | 247 | $obj = array('dn'=>$this->ldapObj->dn); |
248 | 248 | $obj[$propName] = $rawMembers; |
@@ -254,29 +254,29 @@ discard block |
||
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | - static function from_dn($dn, $data=false) |
|
257 | + static function from_dn($dn, $data = false) |
|
258 | 258 | { |
259 | - if($data === false) |
|
259 | + if ($data === false) |
|
260 | 260 | { |
261 | 261 | throw new \Exception('data must be set for LDAPGroup'); |
262 | 262 | } |
263 | 263 | $group = $data->read($dn, false, true); |
264 | - if($group === false || !isset($group[0])) |
|
264 | + if ($group === false || !isset($group[0])) |
|
265 | 265 | { |
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | return new static($group[0]); |
269 | 269 | } |
270 | 270 | |
271 | - static function from_name($name, $data=false) |
|
271 | + static function from_name($name, $data = false) |
|
272 | 272 | { |
273 | - if($data === false) |
|
273 | + if ($data === false) |
|
274 | 274 | { |
275 | 275 | throw new \Exception('data must be set for LDAPGroup'); |
276 | 276 | } |
277 | 277 | $filter = new \Data\Filter("cn eq $name"); |
278 | 278 | $group = $data->read($data->group_base, $filter); |
279 | - if($group === false || !isset($group[0])) |
|
279 | + if ($group === false || !isset($group[0])) |
|
280 | 280 | { |
281 | 281 | return false; |
282 | 282 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private function getUserFromSession() |
27 | 27 | { |
28 | - if(FlipSession::isLoggedIn()) |
|
28 | + if (FlipSession::isLoggedIn()) |
|
29 | 29 | { |
30 | 30 | return FlipSession::getUser(); |
31 | 31 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $auth = \AuthProvider::getInstance(); |
42 | 42 | $auth->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
43 | 43 | $user = FlipSession::getUser(); |
44 | - if($user === false) |
|
44 | + if ($user === false) |
|
45 | 45 | { |
46 | 46 | $data = substr($header['Authorization'], 6); |
47 | 47 | $userpass = explode(':', base64_decode($data)); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | private function getUserFromHeader($header) |
64 | 64 | { |
65 | - if(strncmp($header, 'Basic', 5) == 0) |
|
65 | + if (strncmp($header, 'Basic', 5) == 0) |
|
66 | 66 | { |
67 | 67 | return $this->getUserFromBasicAuth($header); |
68 | 68 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function call() |
73 | 73 | { |
74 | 74 | // no auth header |
75 | - if(!isset($this->headers['Authorization'])) |
|
75 | + if (!isset($this->headers['Authorization'])) |
|
76 | 76 | { |
77 | 77 | $this->app->user = $this->getUserFromSession(); |
78 | 78 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->app->user = $this->getUserFromHeader($header); |
83 | 83 | } |
84 | 84 | |
85 | - if($this->app->user === false) |
|
85 | + if ($this->app->user === false) |
|
86 | 86 | { |
87 | 87 | $this->app->getLog()->error("No user found for call"); |
88 | 88 | } |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | { |
97 | 97 | private function fix_encoded_element($key, $value, &$array, $prefix = '') |
98 | 98 | { |
99 | - if(is_array($value)) |
|
99 | + if (is_array($value)) |
|
100 | 100 | { |
101 | 101 | $array[$key] = implode(';', $value); |
102 | 102 | } |
103 | - else if($key === '_id' && is_object($value)) |
|
103 | + else if ($key === '_id' && is_object($value)) |
|
104 | 104 | { |
105 | 105 | $array[$key] = $value->{'$id'}; |
106 | 106 | } |
107 | - else if(is_object($value)) |
|
107 | + else if (is_object($value)) |
|
108 | 108 | { |
109 | 109 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
110 | 110 | } |
111 | - else if(strncmp($value, 'data:', 5) === 0) |
|
111 | + else if (strncmp($value, 'data:', 5) === 0) |
|
112 | 112 | { |
113 | 113 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
114 | 114 | } |
@@ -122,40 +122,40 @@ discard block |
||
122 | 122 | } |
123 | 123 | ob_start(); |
124 | 124 | $df = fopen("php://output", 'w'); |
125 | - if(is_array($array)) |
|
125 | + if (is_array($array)) |
|
126 | 126 | { |
127 | 127 | $first = reset($array); |
128 | 128 | $keys = FALSE; |
129 | - if(is_array($first)) |
|
129 | + if (is_array($first)) |
|
130 | 130 | { |
131 | 131 | $keys = array_keys($first); |
132 | 132 | } |
133 | - else if(is_object($first)) |
|
133 | + else if (is_object($first)) |
|
134 | 134 | { |
135 | 135 | $keys = array_keys(get_object_vars($first)); |
136 | 136 | } |
137 | 137 | fputcsv($df, $keys); |
138 | 138 | foreach ($array as $row) |
139 | 139 | { |
140 | - if(is_array($row)) |
|
140 | + if (is_array($row)) |
|
141 | 141 | { |
142 | 142 | $id = $row[$keys[0]]; |
143 | - foreach($row as $key=>$value) |
|
143 | + foreach ($row as $key=>$value) |
|
144 | 144 | { |
145 | 145 | $this->fix_encoded_element($key, $value, $row, '/'.$id); |
146 | 146 | } |
147 | 147 | fputcsv($df, $row); |
148 | 148 | } |
149 | - else if(is_object($row)) |
|
149 | + else if (is_object($row)) |
|
150 | 150 | { |
151 | 151 | $keyName = $keys[0]; |
152 | 152 | $id = $row->$keyName; |
153 | - if(is_object($id)) |
|
153 | + if (is_object($id)) |
|
154 | 154 | { |
155 | 155 | $id = $id->{'$id'}; |
156 | 156 | } |
157 | 157 | $values = get_object_vars($row); |
158 | - foreach($values as $key=>$value) |
|
158 | + foreach ($values as $key=>$value) |
|
159 | 159 | { |
160 | 160 | $this->fix_encoded_element($key, $value, $values, '/'.$id); |
161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $array = get_object_vars($array); |
169 | 169 | fputcsv($df, array_keys($array)); |
170 | - foreach($array as $key=>$value) |
|
170 | + foreach ($array as $key=>$value) |
|
171 | 171 | { |
172 | 172 | $this->fix_encoded_element($key, $value, $array); |
173 | 173 | } |
@@ -185,34 +185,34 @@ discard block |
||
185 | 185 | |
186 | 186 | public function call() |
187 | 187 | { |
188 | - if($this->app->request->isOptions()) |
|
188 | + if ($this->app->request->isOptions()) |
|
189 | 189 | { |
190 | 190 | return; |
191 | 191 | } |
192 | 192 | $params = $this->app->request->params(); |
193 | 193 | $fmt = null; |
194 | - if(isset($params['fmt'])) |
|
194 | + if (isset($params['fmt'])) |
|
195 | 195 | { |
196 | 196 | $fmt = $params['fmt']; |
197 | 197 | } |
198 | - if($fmt === null && isset($params['$format'])) |
|
198 | + if ($fmt === null && isset($params['$format'])) |
|
199 | 199 | { |
200 | 200 | $fmt = $params['$format']; |
201 | - if(strstr($fmt, 'odata.streaming=true')) |
|
201 | + if (strstr($fmt, 'odata.streaming=true')) |
|
202 | 202 | { |
203 | 203 | $this->app->response->setStatus(406); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | } |
207 | - if($fmt === null) |
|
207 | + if ($fmt === null) |
|
208 | 208 | { |
209 | 209 | $mimeType = $this->app->request->headers->get('Accept'); |
210 | - if(strstr($mimeType, 'odata.streaming=true')) |
|
210 | + if (strstr($mimeType, 'odata.streaming=true')) |
|
211 | 211 | { |
212 | 212 | $this->app->response->setStatus(406); |
213 | 213 | return; |
214 | 214 | } |
215 | - switch($mimeType) |
|
215 | + switch ($mimeType) |
|
216 | 216 | { |
217 | 217 | case 'text/csv': |
218 | 218 | $fmt = 'csv'; |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | |
233 | 233 | $this->next->call(); |
234 | 234 | |
235 | - if($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json') |
|
235 | + if ($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json') |
|
236 | 236 | { |
237 | 237 | $data = json_decode($this->app->response->getBody()); |
238 | 238 | $text = false; |
239 | - switch($this->app->fmt) |
|
239 | + switch ($this->app->fmt) |
|
240 | 240 | { |
241 | 241 | case 'data-table': |
242 | 242 | $this->app->response->headers->set('Content-Type', 'application/json'); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | $this->app->response->setBody($text); |
265 | 265 | } |
266 | - else if($this->app->response->getStatus() == 200) |
|
266 | + else if ($this->app->response->getStatus() == 200) |
|
267 | 267 | { |
268 | 268 | $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none'); |
269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | parent::__construct(); |
278 | 278 | $this->config('debug', false); |
279 | 279 | $headers = array(); |
280 | - if(php_sapi_name() !== "cli") |
|
280 | + if (php_sapi_name() !== "cli") |
|
281 | 281 | { |
282 | 282 | $headers = apache_request_headers(); |
283 | 283 | } |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | return $this->post($uri, $handler); |
298 | 298 | } |
299 | 299 | |
300 | - function get_json_body($array=false) |
|
300 | + function get_json_body($array = false) |
|
301 | 301 | { |
302 | 302 | return $this->getJsonBody($array); |
303 | 303 | } |
304 | 304 | |
305 | - function getJsonBody($array=false) |
|
305 | + function getJsonBody($array = false) |
|
306 | 306 | { |
307 | 307 | $body = $this->request->getBody(); |
308 | 308 | return json_decode($body, $array); |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | { |
6 | 6 | private $data; |
7 | 7 | |
8 | - function __construct($data=false) |
|
8 | + function __construct($data = false) |
|
9 | 9 | { |
10 | 10 | $this->data = array(); |
11 | - if($data !== false) |
|
11 | + if ($data !== false) |
|
12 | 12 | { |
13 | 13 | $this->data = $data; |
14 | - if(isset($data['extended'])) |
|
14 | + if (isset($data['extended'])) |
|
15 | 15 | { |
16 | 16 | $this->data = $data['extended']; |
17 | 17 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $uid = $this->getUid(); |
26 | 26 | $filter = new \Data\Filter("uid eq '$uid' and gid eq '$name'"); |
27 | 27 | $groups = $group_data_table->read($filter); |
28 | - if($groups === false || !isset($groups[0])) |
|
28 | + if ($groups === false || !isset($groups[0])) |
|
29 | 29 | { |
30 | 30 | return false; |
31 | 31 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | function getEmail() |
37 | 37 | { |
38 | - if(isset($this->data['mail'])) |
|
38 | + if (isset($this->data['mail'])) |
|
39 | 39 | { |
40 | 40 | return $this->data['mail']; |
41 | 41 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | function getUid() |
46 | 46 | { |
47 | - if(isset($this->data['uid'])) |
|
47 | + if (isset($this->data['uid'])) |
|
48 | 48 | { |
49 | 49 | return $this->data['uid']; |
50 | 50 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function getGroupName() |
14 | 14 | { |
15 | - if(isset($data['gid'])) |
|
15 | + if (isset($data['gid'])) |
|
16 | 16 | { |
17 | 17 | return $data['gid']; |
18 | 18 | } |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | |
22 | 22 | public function getDescription() |
23 | 23 | { |
24 | - if(isset($data['description'])) |
|
24 | + if (isset($data['description'])) |
|
25 | 25 | { |
26 | 26 | return $data['description']; |
27 | 27 | } |
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
31 | - public function getMemberUids($recursive=true) |
|
31 | + public function getMemberUids($recursive = true) |
|
32 | 32 | { |
33 | 33 | return $this->members(false, $recursive, true); |
34 | 34 | } |
35 | 35 | |
36 | - public function members($details=false, $recursive=true, $includeGroups=true) |
|
36 | + public function members($details = false, $recursive = true, $includeGroups = true) |
|
37 | 37 | { |
38 | 38 | //TODO |
39 | 39 | return array(); |
@@ -14,7 +14,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |