@@ -8,15 +8,15 @@ discard block |
||
| 8 | 8 | private $ldapObj; |
| 9 | 9 | private $server; |
| 10 | 10 | |
| 11 | - public function __construct($data=false) |
|
| 11 | + public function __construct($data = false) |
|
| 12 | 12 | { |
| 13 | 13 | $this->server = \LDAP\LDAPServer::getInstance(); |
| 14 | - if($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 14 | + if ($data !== false && !isset($data['dn']) && !isset($data['extended'])) |
|
| 15 | 15 | { |
| 16 | 16 | //Generic user object |
| 17 | 17 | $filter = new \Data\Filter('mail eq '.$data['mail']); |
| 18 | 18 | $users = $this->server->read($this->server->user_base, $filter); |
| 19 | - if($users === false || !isset($users[0])) |
|
| 19 | + if ($users === false || !isset($users[0])) |
|
| 20 | 20 | { |
| 21 | 21 | throw new \Exception('No such LDAP User!'); |
| 22 | 22 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | else |
| 26 | 26 | { |
| 27 | - if(isset($data['extended'])) |
|
| 27 | + if (isset($data['extended'])) |
|
| 28 | 28 | { |
| 29 | 29 | $this->ldapObj = $data['extended']; |
| 30 | 30 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | private function check_child_group($array) |
| 39 | 39 | { |
| 40 | 40 | $res = false; |
| 41 | - for($i = 0; $i < $array['count']; $i++) |
|
| 41 | + for ($i = 0; $i < $array['count']; $i++) |
|
| 42 | 42 | { |
| 43 | - if(strpos($array[$i], $this->server->group_base) !== false) |
|
| 43 | + if (strpos($array[$i], $this->server->group_base) !== false) |
|
| 44 | 44 | { |
| 45 | 45 | $dn = explode(',', $array[$i]); |
| 46 | 46 | $res = $this->isInGroupNamed(substr($dn[0], 3)); |
| 47 | - if($res) return $res; |
|
| 47 | + if ($res) return $res; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $res; |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private function isInListOrChild($listName, $group, $dn) |
| 54 | 54 | { |
| 55 | - if(!isset($group[$listName])) |
|
| 55 | + if (!isset($group[$listName])) |
|
| 56 | 56 | { |
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | - if(in_array($dn, $group[$listName])) |
|
| 59 | + if (in_array($dn, $group[$listName])) |
|
| 60 | 60 | { |
| 61 | 61 | return true; |
| 62 | 62 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $filter = new \Data\Filter('cn eq '.$name); |
| 69 | 69 | $group = $this->server->read($this->server->group_base, $filter); |
| 70 | - if(!empty($group)) |
|
| 70 | + if (!empty($group)) |
|
| 71 | 71 | { |
| 72 | 72 | $group = $group[0]; |
| 73 | 73 | $dn = $this->ldapObj->dn; |
| 74 | 74 | $uid = $this->ldapObj->uid[0]; |
| 75 | 75 | $ret = $this->isInListOrChild('member', $group, $dn); |
| 76 | - if($ret === false) |
|
| 76 | + if ($ret === false) |
|
| 77 | 77 | { |
| 78 | 78 | $ret = $this->isInListOrChild('uniquemember', $group, $dn); |
| 79 | 79 | } |
| 80 | - if($ret === false && isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 80 | + if ($ret === false && isset($group['memberUid']) && in_array($uid, $group['memberUid'])) |
|
| 81 | 81 | { |
| 82 | 82 | return true; |
| 83 | 83 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function getOrganization() |
| 120 | 120 | { |
| 121 | 121 | $org = $this->getFieldSingleValue('o'); |
| 122 | - if($org === false) |
|
| 122 | + if ($org === false) |
|
| 123 | 123 | { |
| 124 | 124 | return 'Volunteer'; |
| 125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function getTitles() |
| 130 | 130 | { |
| 131 | 131 | $titles = $this->getField('title'); |
| 132 | - if(isset($titles['count'])) |
|
| 132 | + if (isset($titles['count'])) |
|
| 133 | 133 | { |
| 134 | 134 | unset($titles['count']); |
| 135 | 135 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | public function getOrganizationUnits() |
| 175 | 175 | { |
| 176 | 176 | $units = $this->getField('ou'); |
| 177 | - if(isset($units['count'])) |
|
| 177 | + if (isset($units['count'])) |
|
| 178 | 178 | { |
| 179 | 179 | unset($units['count']); |
| 180 | 180 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | public function getLoginProviders() |
| 185 | 185 | { |
| 186 | 186 | $hosts = $this->getField('host'); |
| 187 | - if(isset($hosts['count'])) |
|
| 187 | + if (isset($hosts['count'])) |
|
| 188 | 188 | { |
| 189 | 189 | unset($hosts['count']); |
| 190 | 190 | } |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $res = array(); |
| 197 | 197 | $groups = $this->server->read($this->server->group_base); |
| 198 | - if(!empty($groups)) |
|
| 198 | + if (!empty($groups)) |
|
| 199 | 199 | { |
| 200 | 200 | $count = count($groups); |
| 201 | - for($i = 0; $i < $count; $i++) |
|
| 201 | + for ($i = 0; $i < $count; $i++) |
|
| 202 | 202 | { |
| 203 | - if($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 203 | + if ($this->isInGroupNamed($groups[$i]['cn'][0])) |
|
| 204 | 204 | { |
| 205 | 205 | array_push($res, new LDAPGroup($groups[$i])); |
| 206 | 206 | } |
@@ -220,23 +220,23 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | private function generateLDAPPass($pass) |
| 222 | 222 | { |
| 223 | - mt_srand((double)microtime()*1000000); |
|
| 223 | + mt_srand((double)microtime() * 1000000); |
|
| 224 | 224 | $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); |
| 225 | - $hash = base64_encode(pack('H*',sha1($pass.$salt)).$salt); |
|
| 225 | + $hash = base64_encode(pack('H*', sha1($pass.$salt)).$salt); |
|
| 226 | 226 | return '{SSHA}'.$hash; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | public function setPass($password) |
| 230 | 230 | { |
| 231 | - if(!is_object($this->ldapObj)) |
|
| 231 | + if (!is_object($this->ldapObj)) |
|
| 232 | 232 | { |
| 233 | - return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 233 | + return $this->setFieldLocal('userPassword', $this->generateLDAPPass($password)); |
|
| 234 | 234 | } |
| 235 | 235 | else |
| 236 | 236 | { |
| 237 | 237 | $obj = array('dn'=>$this->ldapObj->dn); |
| 238 | 238 | $obj['userPassword'] = $this->generateLDAPPass($password); |
| 239 | - if(isset($this->ldapObj->uniqueidentifier)) |
|
| 239 | + if (isset($this->ldapObj->uniqueidentifier)) |
|
| 240 | 240 | { |
| 241 | 241 | $obj['uniqueIdentifier'] = null; |
| 242 | 242 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | public function validate_password($password) |
| 252 | 252 | { |
| 253 | - if($this->server->bind($this->ldapObj->dn, $password)) |
|
| 253 | + if ($this->server->bind($this->ldapObj->dn, $password)) |
|
| 254 | 254 | { |
| 255 | 255 | return true; |
| 256 | 256 | } |
@@ -259,37 +259,37 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | public function validate_reset_hash($hash) |
| 261 | 261 | { |
| 262 | - if(isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 262 | + if (isset($this->ldapObj->uniqueidentifier) && strcmp($this->ldapObj->uniqueidentifier[0], $hash) === 0) |
|
| 263 | 263 | { |
| 264 | 264 | return true; |
| 265 | 265 | } |
| 266 | 266 | return false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - static function from_name($name, $data=false) |
|
| 269 | + static function from_name($name, $data = false) |
|
| 270 | 270 | { |
| 271 | - if($data === false) |
|
| 271 | + if ($data === false) |
|
| 272 | 272 | { |
| 273 | 273 | throw new \Exception('data must be set for LDAPUser'); |
| 274 | 274 | } |
| 275 | 275 | $filter = new \Data\Filter("uid eq $name"); |
| 276 | 276 | $user = $data->read($data->user_base, $filter); |
| 277 | - if($user === false || !isset($user[0])) |
|
| 277 | + if ($user === false || !isset($user[0])) |
|
| 278 | 278 | { |
| 279 | 279 | return false; |
| 280 | 280 | } |
| 281 | 281 | return new static($user[0]); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - static function from_dn($dn, $data=false) |
|
| 284 | + static function from_dn($dn, $data = false) |
|
| 285 | 285 | { |
| 286 | - if($data === false) |
|
| 286 | + if ($data === false) |
|
| 287 | 287 | { |
| 288 | 288 | throw new \Exception('data must be set for LDAPUser'); |
| 289 | 289 | } |
| 290 | 290 | $filter = new \Data\Filter("dn eq $dn"); |
| 291 | 291 | $user = $data->read($data->user_base, $filter); |
| 292 | - if($user === false || !isset($user[0])) |
|
| 292 | + if ($user === false || !isset($user[0])) |
|
| 293 | 293 | { |
| 294 | 294 | return false; |
| 295 | 295 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | public function setUid($uid) |
| 320 | 320 | { |
| 321 | - if(!is_object($this->ldapObj)) |
|
| 321 | + if (!is_object($this->ldapObj)) |
|
| 322 | 322 | { |
| 323 | 323 | return $this->setFieldLocal('uid', $uid); |
| 324 | 324 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | public function setTitles($titles) |
| 368 | 368 | { |
| 369 | - if(!is_array($titles)) |
|
| 369 | + if (!is_array($titles)) |
|
| 370 | 370 | { |
| 371 | 371 | $titles = array($titles); |
| 372 | 372 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | public function setOrganizationUnits($ous) |
| 377 | 377 | { |
| 378 | - if(!is_array($ous)) |
|
| 378 | + if (!is_array($ous)) |
|
| 379 | 379 | { |
| 380 | 380 | $ous = array($ous); |
| 381 | 381 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | public function flushUser() |
| 386 | 386 | { |
| 387 | - if(is_object($this->ldapObj)) |
|
| 387 | + if (is_object($this->ldapObj)) |
|
| 388 | 388 | { |
| 389 | 389 | //In this mode we are always up to date |
| 390 | 390 | return true; |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | $obj = $this->ldapObj; |
| 393 | 393 | $obj['objectClass'] = array('top', 'inetOrgPerson', 'extensibleObject'); |
| 394 | 394 | $obj['dn'] = 'uid='.$this->ldapObj['uid'].','.$this->server->user_base; |
| 395 | - if(!isset($obj['sn'])) |
|
| 395 | + if (!isset($obj['sn'])) |
|
| 396 | 396 | { |
| 397 | 397 | $obj['sn'] = $obj['uid']; |
| 398 | 398 | } |
| 399 | - if(!isset($obj['cn'])) |
|
| 399 | + if (!isset($obj['cn'])) |
|
| 400 | 400 | { |
| 401 | 401 | $obj['cn'] = $obj['uid']; |
| 402 | 402 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $ldapObj = $this->server->read($ldap->user_base, new \Data\Filter('uid eq '.$this->getUid())); |
| 414 | 414 | $ldapObj = $ldapObj[0]; |
| 415 | 415 | $hash = false; |
| 416 | - if(isset($ldapObj->userpassword)) |
|
| 416 | + if (isset($ldapObj->userpassword)) |
|
| 417 | 417 | { |
| 418 | 418 | $hash = hash('sha512', $ldapObj->dn.';'.$ldapObj->userpassword[0].';'.$ldapObj->mail[0]); |
| 419 | 419 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | $obj = array('dn'=>$this->ldapObj->dn); |
| 425 | 425 | $obj['uniqueIdentifier'] = $hash; |
| 426 | - if($this->server->update($obj) === false) |
|
| 426 | + if ($this->server->update($obj) === false) |
|
| 427 | 427 | { |
| 428 | 428 | throw new \Exception('Unable to create hash in LDAP object!'); |
| 429 | 429 | } |
@@ -128,26 +128,26 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -602,99 +602,99 @@ discard block |
||
| 602 | 602 | $auth = \AuthProvider::getInstance(); |
| 603 | 603 | $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator'); |
| 604 | 604 | $ldap->get_and_bind_server(true); |
| 605 | - if(isset($data->oldpass) && isset($data->password)) |
|
| 605 | + if (isset($data->oldpass) && isset($data->password)) |
|
| 606 | 606 | { |
| 607 | 607 | $this->change_pass($data->oldpass, $data->password); |
| 608 | 608 | unset($data->oldpass); |
| 609 | 609 | unset($data->password); |
| 610 | 610 | } |
| 611 | - else if(isset($data->hash) && isset($data->password)) |
|
| 611 | + else if (isset($data->hash) && isset($data->password)) |
|
| 612 | 612 | { |
| 613 | 613 | $this->change_pass($data->hash, $data->password, true); |
| 614 | 614 | return; |
| 615 | 615 | } |
| 616 | - if(isset($data->displayName)) |
|
| 616 | + if (isset($data->displayName)) |
|
| 617 | 617 | { |
| 618 | 618 | $this->setDisplayName($data->displayName); |
| 619 | 619 | unset($data->displayName); |
| 620 | 620 | } |
| 621 | - if(isset($data->givenName)) |
|
| 621 | + if (isset($data->givenName)) |
|
| 622 | 622 | { |
| 623 | 623 | $this->setGivenName($data->givenName); |
| 624 | 624 | unset($data->givenName); |
| 625 | 625 | } |
| 626 | - if(isset($data->jpegPhoto)) |
|
| 626 | + if (isset($data->jpegPhoto)) |
|
| 627 | 627 | { |
| 628 | 628 | $this->setPhoto(base64_decode($data->jpegPhoto)); |
| 629 | 629 | unset($data->jpegPhoto); |
| 630 | 630 | } |
| 631 | - if(isset($data->mail)) |
|
| 631 | + if (isset($data->mail)) |
|
| 632 | 632 | { |
| 633 | - if($data->mail !== $this->getEmail()) |
|
| 633 | + if ($data->mail !== $this->getEmail()) |
|
| 634 | 634 | { |
| 635 | 635 | throw new \Exception('Unable to change email!'); |
| 636 | 636 | } |
| 637 | 637 | unset($data->mail); |
| 638 | 638 | } |
| 639 | - if(isset($data->uid)) |
|
| 639 | + if (isset($data->uid)) |
|
| 640 | 640 | { |
| 641 | - if($data->uid !== $this->getUid()) |
|
| 641 | + if ($data->uid !== $this->getUid()) |
|
| 642 | 642 | { |
| 643 | 643 | throw new \Exception('Unable to change uid!'); |
| 644 | 644 | } |
| 645 | 645 | unset($data->uid); |
| 646 | 646 | } |
| 647 | - if(isset($data->mobile)) |
|
| 647 | + if (isset($data->mobile)) |
|
| 648 | 648 | { |
| 649 | 649 | $this->setPhoneNumber($data->mobile); |
| 650 | 650 | unset($data->mobile); |
| 651 | 651 | } |
| 652 | - if(isset($data->o)) |
|
| 652 | + if (isset($data->o)) |
|
| 653 | 653 | { |
| 654 | 654 | $this->setOrganization($data->o); |
| 655 | 655 | unset($data->o); |
| 656 | 656 | } |
| 657 | - if(isset($data->title)) |
|
| 657 | + if (isset($data->title)) |
|
| 658 | 658 | { |
| 659 | 659 | $this->setTitles($data->title); |
| 660 | 660 | unset($data->title); |
| 661 | 661 | } |
| 662 | - if(isset($data->st)) |
|
| 662 | + if (isset($data->st)) |
|
| 663 | 663 | { |
| 664 | 664 | $this->setState($data->st); |
| 665 | 665 | unset($data->st); |
| 666 | 666 | } |
| 667 | - if(isset($data->l)) |
|
| 667 | + if (isset($data->l)) |
|
| 668 | 668 | { |
| 669 | 669 | $this->setCity($data->l); |
| 670 | 670 | unset($data->l); |
| 671 | 671 | } |
| 672 | - if(isset($data->sn)) |
|
| 672 | + if (isset($data->sn)) |
|
| 673 | 673 | { |
| 674 | 674 | $this->setLastName($data->sn); |
| 675 | 675 | unset($data->sn); |
| 676 | 676 | } |
| 677 | - if(isset($data->cn)) |
|
| 677 | + if (isset($data->cn)) |
|
| 678 | 678 | { |
| 679 | 679 | $this->setNickName($data->cn); |
| 680 | 680 | unset($data->cn); |
| 681 | 681 | } |
| 682 | - if(isset($data->postalAddress)) |
|
| 682 | + if (isset($data->postalAddress)) |
|
| 683 | 683 | { |
| 684 | 684 | $this->setAddress($data->postalAddress); |
| 685 | 685 | unset($data->postalAddress); |
| 686 | 686 | } |
| 687 | - if(isset($data->postalCode)) |
|
| 687 | + if (isset($data->postalCode)) |
|
| 688 | 688 | { |
| 689 | 689 | $this->setPostalCode($data->postalCode); |
| 690 | 690 | unset($data->postalCode); |
| 691 | 691 | } |
| 692 | - if(isset($data->c)) |
|
| 692 | + if (isset($data->c)) |
|
| 693 | 693 | { |
| 694 | 694 | $this->setCountry($data->c); |
| 695 | 695 | unset($data->c); |
| 696 | 696 | } |
| 697 | - if(isset($data->ou)) |
|
| 697 | + if (isset($data->ou)) |
|
| 698 | 698 | { |
| 699 | 699 | $this->setOrganizationUnits($data->ou); |
| 700 | 700 | unset($data->ou); |
@@ -749,13 +749,13 @@ discard block |
||
| 749 | 749 | public function getVcard() |
| 750 | 750 | { |
| 751 | 751 | $ret = "BEGIN:VCARD\nVERSION:2.1\n"; |
| 752 | - $ret.= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n"; |
|
| 753 | - $ret.= 'FN:'.$this->getGivenName()."\n"; |
|
| 754 | - $ret.= 'TITLE:'.implode(',', $this->getTitles())."\n"; |
|
| 755 | - $ret.= "ORG: Austin Artistic Reconstruction\n"; |
|
| 756 | - $ret.= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n"; |
|
| 757 | - $ret.= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n"; |
|
| 758 | - $ret.= "END:VCARD\n"; |
|
| 752 | + $ret .= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n"; |
|
| 753 | + $ret .= 'FN:'.$this->getGivenName()."\n"; |
|
| 754 | + $ret .= 'TITLE:'.implode(',', $this->getTitles())."\n"; |
|
| 755 | + $ret .= "ORG: Austin Artistic Reconstruction\n"; |
|
| 756 | + $ret .= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n"; |
|
| 757 | + $ret .= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n"; |
|
| 758 | + $ret .= "END:VCARD\n"; |
|
| 759 | 759 | return $ret; |
| 760 | 760 | } |
| 761 | 761 | } |
@@ -6,9 +6,9 @@ discard block |
||
| 6 | 6 | protected $collection; |
| 7 | 7 | protected $namespace; |
| 8 | 8 | |
| 9 | - public function __construct($collection, $collection_name=false) |
|
| 9 | + public function __construct($collection, $collection_name = false) |
|
| 10 | 10 | { |
| 11 | - if($collection_name !== false) |
|
| 11 | + if ($collection_name !== false) |
|
| 12 | 12 | { |
| 13 | 13 | $this->namespace = $collection.'.'.$collection_name; |
| 14 | 14 | } |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function count($filter=false) |
|
| 21 | + public function count($filter = false) |
|
| 22 | 22 | { |
| 23 | 23 | $criteria = array(); |
| 24 | - if($filter !== false) |
|
| 24 | + if ($filter !== false) |
|
| 25 | 25 | { |
| 26 | - if($filter instanceof \Data\Filter) |
|
| 26 | + if ($filter instanceof \Data\Filter) |
|
| 27 | 27 | { |
| 28 | 28 | $criteria = $filter->to_mongo_filter(); |
| 29 | 29 | } |
@@ -37,44 +37,44 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private function getCriteriaFromFilter($filter) |
| 39 | 39 | { |
| 40 | - if($filter === false) |
|
| 40 | + if ($filter === false) |
|
| 41 | 41 | { |
| 42 | 42 | return array(); |
| 43 | 43 | } |
| 44 | - if(is_array($filter)) |
|
| 44 | + if (is_array($filter)) |
|
| 45 | 45 | { |
| 46 | 46 | return $filter; |
| 47 | 47 | } |
| 48 | 48 | return $filter->to_mongo_filter(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
| 51 | + public function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
| 52 | 52 | { |
| 53 | 53 | $fields = array(); |
| 54 | 54 | $criteria = $this->getCriteriaFromFilter($filter); |
| 55 | - if($select !== false) |
|
| 55 | + if ($select !== false) |
|
| 56 | 56 | { |
| 57 | 57 | $fields = array_fill_keys($select, 1); |
| 58 | 58 | } |
| 59 | - $cursor = $this->collection->find($criteria, $fields); |
|
| 60 | - if($params !== false && isset($params['fields'])) |
|
| 59 | + $cursor = $this->collection->find($criteria, $fields); |
|
| 60 | + if ($params !== false && isset($params['fields'])) |
|
| 61 | 61 | { |
| 62 | 62 | $cursor->fields($params['fields']); |
| 63 | 63 | } |
| 64 | - if($sort !== false) |
|
| 64 | + if ($sort !== false) |
|
| 65 | 65 | { |
| 66 | 66 | $cursor->sort($sort); |
| 67 | 67 | } |
| 68 | - if($skip !== false) |
|
| 68 | + if ($skip !== false) |
|
| 69 | 69 | { |
| 70 | 70 | $cursor->skip($skip); |
| 71 | 71 | } |
| 72 | - if($count !== false) |
|
| 72 | + if ($count !== false) |
|
| 73 | 73 | { |
| 74 | 74 | $cursor->limit($count); |
| 75 | 75 | } |
| 76 | - $ret = array(); |
|
| 77 | - foreach($cursor as $doc) |
|
| 76 | + $ret = array(); |
|
| 77 | + foreach ($cursor as $doc) |
|
| 78 | 78 | { |
| 79 | 79 | array_push($ret, $doc); |
| 80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function create($data) |
| 85 | 85 | { |
| 86 | 86 | $res = $this->collection->insert($data); |
| 87 | - if($res === false || $res['err'] !== null) |
|
| 87 | + if ($res === false || $res['err'] !== null) |
|
| 88 | 88 | { |
| 89 | 89 | return false; |
| 90 | 90 | } |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | public function update($filter, $data) |
| 95 | 95 | { |
| 96 | 96 | $criteria = $this->getCriteriaFromFilter($filter); |
| 97 | - if(isset($data['_id'])) |
|
| 97 | + if (isset($data['_id'])) |
|
| 98 | 98 | { |
| 99 | 99 | unset($data['_id']); |
| 100 | 100 | } |
| 101 | 101 | $res = $this->collection->update($criteria, array('$set' => $data)); |
| 102 | - if($res === false || $res['err'] !== null) |
|
| 102 | + if ($res === false || $res['err'] !== null) |
|
| 103 | 103 | { |
| 104 | 104 | return false; |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $criteria = $this->getCriteriaFromFilter($filter); |
| 112 | 112 | $res = $this->collection->remove($criteria); |
| 113 | - if($res === false || $res['err'] !== null) |
|
| 113 | + if ($res === false || $res['err'] !== null) |
|
| 114 | 114 | { |
| 115 | 115 | return false; |
| 116 | 116 | } |
@@ -9,11 +9,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 || strlen($fieldValue) === 0) |
|
| 151 | + if ($fieldValue === null || 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 |
||
| 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 | } |
@@ -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 | } |