@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getEmail() |
| 51 | 51 | { |
| 52 | - if(isset($this->email)) |
|
| 52 | + if (isset($this->email)) |
|
| 53 | 53 | { |
| 54 | 54 | return $this->email; |
| 55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getGivenName() |
| 65 | 65 | { |
| 66 | - if(isset($this->givenName)) |
|
| 66 | + if (isset($this->givenName)) |
|
| 67 | 67 | { |
| 68 | 68 | return $this->givenName; |
| 69 | 69 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function getLastName() |
| 79 | 79 | { |
| 80 | - if(isset($this->sn)) |
|
| 80 | + if (isset($this->sn)) |
|
| 81 | 81 | { |
| 82 | 82 | return $this->sn; |
| 83 | 83 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function getLoginProviders() |
| 106 | 106 | { |
| 107 | - if(isset($this->host)) |
|
| 107 | + if (isset($this->host)) |
|
| 108 | 108 | { |
| 109 | 109 | return $this->host; |
| 110 | 110 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function addLoginProvider($provider) |
| 122 | 122 | { |
| 123 | - if(isset($this->host)) |
|
| 123 | + if (isset($this->host)) |
|
| 124 | 124 | { |
| 125 | 125 | array_push($this->host, $provider); |
| 126 | 126 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | Burning Flipside Technology Team'); |
| 200 | 200 | $email_msg->setSubject('Burning Flipside Registration'); |
| 201 | 201 | $email_provider = \EmailProvider::getInstance(); |
| 202 | - if($email_provider->sendEmail($email_msg) === false) |
|
| 202 | + if ($email_provider->sendEmail($email_msg) === false) |
|
| 203 | 203 | { |
| 204 | 204 | throw new \Exception('Unable to send email!'); |
| 205 | 205 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Auth; |
| 3 | -if(!class_exists('Httpful\Request')) |
|
| 3 | +if (!class_exists('Httpful\Request')) |
|
| 4 | 4 | { |
| 5 | 5 | require(realpath(dirname(__FILE__)).'/../libs/httpful/bootstrap.php'); |
| 6 | 6 | } |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | private $userData; |
| 11 | 11 | private $groupData = null; |
| 12 | 12 | |
| 13 | - public function __construct($data=false) |
|
| 13 | + public function __construct($data = false) |
|
| 14 | 14 | { |
| 15 | - if($data !== false && !isset($data['extended'])) |
|
| 15 | + if ($data !== false && !isset($data['extended'])) |
|
| 16 | 16 | { |
| 17 | 17 | //Generic user object |
| 18 | 18 | //TODO get from API |
| 19 | 19 | } |
| 20 | 20 | else |
| 21 | 21 | { |
| 22 | - if(isset($data['extended'])) |
|
| 22 | + if (isset($data['extended'])) |
|
| 23 | 23 | { |
| 24 | 24 | $this->userData = $data['extended']; |
| 25 | 25 | } |
@@ -28,19 +28,19 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | function isInGroupNamed($name) |
| 30 | 30 | { |
| 31 | - if($this->groupData === null) |
|
| 31 | + if ($this->groupData === null) |
|
| 32 | 32 | { |
| 33 | 33 | $resp = \Httpful\Request::get('https://profiles.test.burningflipside.com/api/v1/users/me/groups')->authenticateWith($this->userData->uid, $this->userData->userPassword)->send(); |
| 34 | - if($resp->hasErrors()) |
|
| 34 | + if ($resp->hasErrors()) |
|
| 35 | 35 | { |
| 36 | 36 | return false; |
| 37 | 37 | } |
| 38 | 38 | $this->groupData = $resp->body; |
| 39 | 39 | } |
| 40 | 40 | $count = count($this->groupData); |
| 41 | - for($i = 0; $i < $count; $i++) |
|
| 41 | + for ($i = 0; $i < $count; $i++) |
|
| 42 | 42 | { |
| 43 | - if($this->groupData[$i]->cn === $name) |
|
| 43 | + if ($this->groupData[$i]->cn === $name) |
|
| 44 | 44 | { |
| 45 | 45 | return true; |
| 46 | 46 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | function getDisplayName() |
| 52 | 52 | { |
| 53 | - if($this->userData === null) |
|
| 53 | + if ($this->userData === null) |
|
| 54 | 54 | { |
| 55 | 55 | return parent::getDisplayName(); |
| 56 | 56 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | function getGivenName() |
| 61 | 61 | { |
| 62 | - if($this->userData === null) |
|
| 62 | + if ($this->userData === null) |
|
| 63 | 63 | { |
| 64 | 64 | return parent::getGivenName(); |
| 65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | function getEmail() |
| 70 | 70 | { |
| 71 | - if($this->userData === null) |
|
| 71 | + if ($this->userData === null) |
|
| 72 | 72 | { |
| 73 | 73 | return parent::getEmail(); |
| 74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | function getUid() |
| 79 | 79 | { |
| 80 | - if($this->userData === null) |
|
| 80 | + if ($this->userData === null) |
|
| 81 | 81 | { |
| 82 | 82 | return parent::getUid(); |
| 83 | 83 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | function getPhoneNumber() |
| 88 | 88 | { |
| 89 | - if($this->userData === null) |
|
| 89 | + if ($this->userData === null) |
|
| 90 | 90 | { |
| 91 | 91 | return parent::getPhoneNumber(); |
| 92 | 92 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | function getOrganization() |
| 97 | 97 | { |
| 98 | - if($this->userData === null) |
|
| 98 | + if ($this->userData === null) |
|
| 99 | 99 | { |
| 100 | 100 | return parent::getOrganization(); |
| 101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | function getTitles() |
| 106 | 106 | { |
| 107 | - if($this->userData === null) |
|
| 107 | + if ($this->userData === null) |
|
| 108 | 108 | { |
| 109 | 109 | return parent::getTitles(); |
| 110 | 110 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | function getState() |
| 115 | 115 | { |
| 116 | - if($this->userData === null) |
|
| 116 | + if ($this->userData === null) |
|
| 117 | 117 | { |
| 118 | 118 | return parent::getState(); |
| 119 | 119 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | function getCity() |
| 124 | 124 | { |
| 125 | - if($this->userData === null) |
|
| 125 | + if ($this->userData === null) |
|
| 126 | 126 | { |
| 127 | 127 | return parent::getCity(); |
| 128 | 128 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | function getLastName() |
| 133 | 133 | { |
| 134 | - if($this->userData === null) |
|
| 134 | + if ($this->userData === null) |
|
| 135 | 135 | { |
| 136 | 136 | return parent::getLastName(); |
| 137 | 137 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | function getNickName() |
| 142 | 142 | { |
| 143 | - if($this->userData === null) |
|
| 143 | + if ($this->userData === null) |
|
| 144 | 144 | { |
| 145 | 145 | return parent::getNickName(); |
| 146 | 146 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | function getAddress() |
| 151 | 151 | { |
| 152 | - if($this->userData === null) |
|
| 152 | + if ($this->userData === null) |
|
| 153 | 153 | { |
| 154 | 154 | return parent::getAddress(); |
| 155 | 155 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | function getPostalCode() |
| 160 | 160 | { |
| 161 | - if($this->userData === null) |
|
| 161 | + if ($this->userData === null) |
|
| 162 | 162 | { |
| 163 | 163 | return parent::getPostalCode(); |
| 164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | function getCountry() |
| 169 | 169 | { |
| 170 | - if($this->userData === null) |
|
| 170 | + if ($this->userData === null) |
|
| 171 | 171 | { |
| 172 | 172 | return parent::getCountry(); |
| 173 | 173 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | function getOrganizationUnits() |
| 178 | 178 | { |
| 179 | - if($this->userData === null) |
|
| 179 | + if ($this->userData === null) |
|
| 180 | 180 | { |
| 181 | 181 | return parent::getOrganizationUnits(); |
| 182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | function getLoginProviders() |
| 187 | 187 | { |
| 188 | - if($this->userData === null) |
|
| 188 | + if ($this->userData === null) |
|
| 189 | 189 | { |
| 190 | 190 | return parent::getLoginProviders(); |
| 191 | 191 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | return false; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function getMemberUids($recursive=true) |
|
| 26 | + public function getMemberUids($recursive = true) |
|
| 27 | 27 | { |
| 28 | 28 | return array(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function members($details=false, $recursive=true, $includeGroups=true) |
|
| 31 | + public function members($details = false, $recursive = true, $includeGroups = true) |
|
| 32 | 32 | { |
| 33 | 33 | return array(); |
| 34 | 34 | } |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | public function jsonSerialize() |
| 47 | 47 | { |
| 48 | 48 | $group = array(); |
| 49 | - try{ |
|
| 49 | + try { |
|
| 50 | 50 | $group['cn'] = $this->getGroupName(); |
| 51 | 51 | $group['description'] = $this->getDescription(); |
| 52 | 52 | $group['member'] = $this->getMemberUids(); |
| 53 | - } catch(\Exception $e) {echo $e->getMessage(); die();} |
|
| 53 | + } catch (\Exception $e) {echo $e->getMessage(); die(); } |
|
| 54 | 54 | return $group; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function getNonMembers($select=false) |
|
| 57 | + public function getNonMembers($select = false) |
|
| 58 | 58 | { |
| 59 | 59 | return array(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function addMember($name, $isGroup=false, $flush=true) |
|
| 62 | + public function addMember($name, $isGroup = false, $flush = true) |
|
| 63 | 63 | { |
| 64 | 64 | return false; |
| 65 | 65 | } |
@@ -70,24 +70,24 @@ discard block |
||
| 70 | 70 | $auth = \AuthProvider::getInstance(); |
| 71 | 71 | $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator'); |
| 72 | 72 | $ldap->get_and_bind_server(true); |
| 73 | - if(isset($group->description)) |
|
| 73 | + if (isset($group->description)) |
|
| 74 | 74 | { |
| 75 | 75 | $this->setDescription($group->description); |
| 76 | 76 | unset($group->description); |
| 77 | 77 | } |
| 78 | - if(isset($group->member)) |
|
| 78 | + if (isset($group->member)) |
|
| 79 | 79 | { |
| 80 | 80 | $this->clearMembers(); |
| 81 | 81 | $count = count($group->member); |
| 82 | - for($i = 0; $i < $count; $i++) |
|
| 82 | + for ($i = 0; $i < $count; $i++) |
|
| 83 | 83 | { |
| 84 | 84 | $isLast = false; |
| 85 | - if($i === $count - 1) |
|
| 85 | + if ($i === $count - 1) |
|
| 86 | 86 | { |
| 87 | 87 | $isLast = true; |
| 88 | 88 | } |
| 89 | - if(!isset($group->member[$i]->type)) continue; |
|
| 90 | - if($group->member[$i]->type === 'Group') |
|
| 89 | + if (!isset($group->member[$i]->type)) continue; |
|
| 90 | + if ($group->member[$i]->type === 'Group') |
|
| 91 | 91 | { |
| 92 | 92 | $this->addMember($group->member[$i]->cn, true, $isLast); |
| 93 | 93 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - static function from_name($name, $data=false) |
|
| 104 | + static function from_name($name, $data = false) |
|
| 105 | 105 | { |
| 106 | 106 | return false; |
| 107 | 107 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | function getEmail() |
| 30 | 30 | { |
| 31 | - if(is_array($this->blob->mail)) |
|
| 31 | + if (is_array($this->blob->mail)) |
|
| 32 | 32 | { |
| 33 | 33 | return $this->blob->mail[0]; |
| 34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | function getUid() |
| 39 | 39 | { |
| 40 | - if(is_array($this->blob->uid)) |
|
| 40 | + if (is_array($this->blob->uid)) |
|
| 41 | 41 | { |
| 42 | 42 | return $this->blob->uid[0]; |
| 43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | function getPassword() |
| 48 | 48 | { |
| 49 | - if(is_array($this->blob->password)) |
|
| 49 | + if (is_array($this->blob->password)) |
|
| 50 | 50 | { |
| 51 | 51 | return $this->blob->password[0]; |
| 52 | 52 | } |
@@ -264,7 +264,7 @@ |
||
| 264 | 264 | throw new \Exception('data must be set for LDAPGroup'); |
| 265 | 265 | } |
| 266 | 266 | $filter = new \Data\Filter("cn eq $name"); |
| 267 | - $group = $data->read($data->group_base, $filter); |
|
| 267 | + $group = $data->read($data->group_base, $filter); |
|
| 268 | 268 | if($group === false || !isset($group[0])) |
| 269 | 269 | { |
| 270 | 270 | return false; |
@@ -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 | } |
@@ -26,18 +26,18 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $count = count($array); |
| 28 | 28 | $keys = array_keys($orderby); |
| 29 | - for($i = 0; $i < $count; $i++) |
|
| 29 | + for ($i = 0; $i < $count; $i++) |
|
| 30 | 30 | { |
| 31 | - for($j = $i; $j < $count; $j++) |
|
| 31 | + for ($j = $i; $j < $count; $j++) |
|
| 32 | 32 | { |
| 33 | 33 | $d = strcasecmp($array[$i][$keys[0]][0], $array[$j][$keys[0]][0]); |
| 34 | - switch($orderby[$keys[0]]) |
|
| 34 | + switch ($orderby[$keys[0]]) |
|
| 35 | 35 | { |
| 36 | 36 | case 1: |
| 37 | - if($d > 0) swap($array, $i, $j); |
|
| 37 | + if ($d > 0) swap($array, $i, $j); |
|
| 38 | 38 | break; |
| 39 | 39 | case 0: |
| 40 | - if($d < 0) swap($array, $i, $j); |
|
| 40 | + if ($d < 0) swap($array, $i, $j); |
|
| 41 | 41 | break; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $this->host = $this->getHostParam($params); |
| 86 | 86 | $this->user_base = $this->getParam($params, 'user_base'); |
| 87 | 87 | $this->group_base = $this->getParam($params, 'group_base'); |
| 88 | - $this->bind_dn = $this->getParam($params, 'bind_dn', '$ldap_auth', 'read_write_pass'); |
|
| 88 | + $this->bind_dn = $this->getParam($params, 'bind_dn', '$ldap_auth', 'read_write_pass'); |
|
| 89 | 89 | $this->bind_pass = $this->getParam($params, 'bind_pass', '$ldap_auth', 'read_write_user'); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function getHostParam($params) |
| 102 | 102 | { |
| 103 | - if(isset($params['host'])) |
|
| 103 | + if (isset($params['host'])) |
|
| 104 | 104 | { |
| 105 | 105 | return $params['host']; |
| 106 | 106 | } |
| 107 | - if(isset(\FlipsideSettings::$ldap['proto'])) |
|
| 107 | + if (isset(\FlipsideSettings::$ldap['proto'])) |
|
| 108 | 108 | { |
| 109 | 109 | return \FlipsideSettings::$ldap['proto'].'://'.\FlipsideSettings::$ldap['host']; |
| 110 | 110 | } |
@@ -123,17 +123,17 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @SuppressWarnings("StaticAccess") |
| 125 | 125 | */ |
| 126 | - private function getParam($params, $paramName, $settingsLocation='$ldap', $settingsName=false) |
|
| 126 | + private function getParam($params, $paramName, $settingsLocation = '$ldap', $settingsName = false) |
|
| 127 | 127 | { |
| 128 | - if($settingsName === false) |
|
| 128 | + if ($settingsName === false) |
|
| 129 | 129 | { |
| 130 | 130 | $settingsName = $paramName; |
| 131 | 131 | } |
| 132 | - if(isset($params[$paramName])) |
|
| 132 | + if (isset($params[$paramName])) |
|
| 133 | 133 | { |
| 134 | 134 | return $params[$paramName]; |
| 135 | 135 | } |
| 136 | - if($settingsLocation === '$ldap') |
|
| 136 | + if ($settingsLocation === '$ldap') |
|
| 137 | 137 | { |
| 138 | 138 | return \FlipsideSettings::$ldap[$settingsName]; |
| 139 | 139 | } |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @SuppressWarnings("StaticAccess") |
| 151 | 151 | */ |
| 152 | - public function get_and_bind_server($bind_write=false) |
|
| 152 | + public function get_and_bind_server($bind_write = false) |
|
| 153 | 153 | { |
| 154 | 154 | $server = \LDAP\LDAPServer::getInstance(); |
| 155 | 155 | $server->user_base = $this->user_base; |
| 156 | 156 | $server->group_base = $this->group_base; |
| 157 | 157 | $server->connect($this->host); |
| 158 | - if($bind_write === false) |
|
| 158 | + if ($bind_write === false) |
|
| 159 | 159 | { |
| 160 | 160 | $ret = $server->bind(); |
| 161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $ret = $server->bind($this->bind_dn, $this->bind_pass); |
| 165 | 165 | } |
| 166 | - if($ret === false) |
|
| 166 | + if ($ret === false) |
|
| 167 | 167 | { |
| 168 | 168 | return false; |
| 169 | 169 | } |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | public function login($username, $password) |
| 182 | 182 | { |
| 183 | 183 | $server = $this->get_and_bind_server(); |
| 184 | - if($server === false) |
|
| 184 | + if ($server === false) |
|
| 185 | 185 | { |
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | $filter = new \Data\Filter("uid eq $username or mail eq $username"); |
| 189 | 189 | $user = $server->read($this->user_base, $filter); |
| 190 | - if($user === false || count($user) === 0) |
|
| 190 | + if ($user === false || count($user) === 0) |
|
| 191 | 191 | { |
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | $user = $user[0]; |
| 195 | 195 | $server->unbind(); |
| 196 | 196 | $ret = $server->bind($user->dn, $password); |
| 197 | - if($ret !== false) |
|
| 197 | + if ($ret !== false) |
|
| 198 | 198 | { |
| 199 | 199 | return array('res'=>true, 'extended'=>$user); |
| 200 | 200 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function isLoggedIn($data) |
| 212 | 212 | { |
| 213 | - if(isset($data['res'])) |
|
| 213 | + if (isset($data['res'])) |
|
| 214 | 214 | { |
| 215 | 215 | return $data['res']; |
| 216 | 216 | } |
@@ -232,35 +232,35 @@ discard block |
||
| 232 | 232 | public function getGroupByName($name) |
| 233 | 233 | { |
| 234 | 234 | $server = $this->get_and_bind_server(); |
| 235 | - if($server === false) |
|
| 235 | + if ($server === false) |
|
| 236 | 236 | { |
| 237 | 237 | return false; |
| 238 | 238 | } |
| 239 | 239 | return LDAPGroup::from_name($name, $server); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
| 242 | + public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
| 243 | 243 | { |
| 244 | 244 | $server = $this->get_and_bind_server(); |
| 245 | - if($server === false) |
|
| 245 | + if ($server === false) |
|
| 246 | 246 | { |
| 247 | 247 | return false; |
| 248 | 248 | } |
| 249 | - if($filter === false) |
|
| 249 | + if ($filter === false) |
|
| 250 | 250 | { |
| 251 | 251 | $filter = new \Data\Filter('cn eq *'); |
| 252 | 252 | } |
| 253 | 253 | $groups = $server->read($this->group_base, $filter); |
| 254 | - if($groups === false) |
|
| 254 | + if ($groups === false) |
|
| 255 | 255 | { |
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | $this->processFilteringParams($groups, $select, $top, $skip, $orderby); |
| 259 | 259 | $count = count($groups); |
| 260 | - for($i = 0; $i < $count; $i++) |
|
| 260 | + for ($i = 0; $i < $count; $i++) |
|
| 261 | 261 | { |
| 262 | 262 | $groups[$i] = new LDAPGroup($groups[$i]); |
| 263 | - if($select !== false) |
|
| 263 | + if ($select !== false) |
|
| 264 | 264 | { |
| 265 | 265 | $groups[$i] = json_decode(json_encode($groups[$i]), true); |
| 266 | 266 | $groups[$i] = array_intersect_key($groups[$i], array_flip($select)); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | public function getActiveUserCount() |
| 273 | 273 | { |
| 274 | 274 | $server = $this->get_and_bind_server(); |
| 275 | - if($server === false) |
|
| 275 | + if ($server === false) |
|
| 276 | 276 | { |
| 277 | 277 | return false; |
| 278 | 278 | } |
@@ -281,50 +281,50 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | private function processFilteringParams(&$data, &$select, $top, $skip, $orderby) |
| 283 | 283 | { |
| 284 | - if($orderby !== false) |
|
| 284 | + if ($orderby !== false) |
|
| 285 | 285 | { |
| 286 | 286 | sort_array($data, $orderby); |
| 287 | 287 | } |
| 288 | - if($select !== false) |
|
| 288 | + if ($select !== false) |
|
| 289 | 289 | { |
| 290 | 290 | $select = array_flip($select); |
| 291 | 291 | } |
| 292 | - if($skip !== false && $top !== false) |
|
| 292 | + if ($skip !== false && $top !== false) |
|
| 293 | 293 | { |
| 294 | 294 | $data = array_slice($data, $skip, $top); |
| 295 | 295 | } |
| 296 | - else if($top !== false) |
|
| 296 | + else if ($top !== false) |
|
| 297 | 297 | { |
| 298 | 298 | $data = array_slice($data, 0, $top); |
| 299 | 299 | } |
| 300 | - else if($skip !== false) |
|
| 300 | + else if ($skip !== false) |
|
| 301 | 301 | { |
| 302 | 302 | $data = array_slice($data, $skip); |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
| 306 | + public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
| 307 | 307 | { |
| 308 | 308 | $server = $this->get_and_bind_server(); |
| 309 | - if($server === false) |
|
| 309 | + if ($server === false) |
|
| 310 | 310 | { |
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | - if($filter === false) |
|
| 313 | + if ($filter === false) |
|
| 314 | 314 | { |
| 315 | 315 | $filter = new \Data\Filter('cn eq *'); |
| 316 | 316 | } |
| 317 | 317 | $users = $server->read($this->user_base, $filter, false, $select); |
| 318 | - if($users === false) |
|
| 318 | + if ($users === false) |
|
| 319 | 319 | { |
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | 322 | $this->processFilteringParams($users, $select, $top, $skip, $orderby); |
| 323 | 323 | $count = count($users); |
| 324 | - for($i = 0; $i < $count; $i++) |
|
| 324 | + for ($i = 0; $i < $count; $i++) |
|
| 325 | 325 | { |
| 326 | 326 | $tmp = new LDAPUser($users[$i]); |
| 327 | - if($select !== false) |
|
| 327 | + if ($select !== false) |
|
| 328 | 328 | { |
| 329 | 329 | $tmp = $tmp->jsonSerialize(); |
| 330 | 330 | $tmp = array_intersect_key($tmp, $select); |
@@ -342,36 +342,36 @@ discard block |
||
| 342 | 342 | $email = $user->getEmail(); |
| 343 | 343 | $new_user->setEmail($email); |
| 344 | 344 | $pass = $user->getPassword(); |
| 345 | - if($pass !== false) |
|
| 345 | + if ($pass !== false) |
|
| 346 | 346 | { |
| 347 | 347 | $new_user->setPass($pass); |
| 348 | 348 | } |
| 349 | 349 | $sn = $user->getLastName(); |
| 350 | - if($sn !== false) |
|
| 350 | + if ($sn !== false) |
|
| 351 | 351 | { |
| 352 | 352 | $new_user->setLastName($sn); |
| 353 | 353 | } |
| 354 | 354 | $givenName = $user->getGivenName(); |
| 355 | - if($givenName !== false) |
|
| 355 | + if ($givenName !== false) |
|
| 356 | 356 | { |
| 357 | 357 | $new_user->setGivenName($givenName); |
| 358 | 358 | } |
| 359 | 359 | $hosts = $user->getLoginProviders(); |
| 360 | - if($hosts !== false) |
|
| 360 | + if ($hosts !== false) |
|
| 361 | 361 | { |
| 362 | 362 | $count = count($hosts); |
| 363 | - for($i = 0; $i < $count; $i++) |
|
| 363 | + for ($i = 0; $i < $count; $i++) |
|
| 364 | 364 | { |
| 365 | 365 | $new_user->addLoginProvider($hosts[$i]); |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | $ret = $new_user->flushUser(); |
| 369 | - if($ret) |
|
| 369 | + if ($ret) |
|
| 370 | 370 | { |
| 371 | 371 | $user->delete(); |
| 372 | 372 | } |
| 373 | 373 | $users = $this->getUsersByFilter(new \Data\Filter('mail eq '.$email)); |
| 374 | - if($users === false || !isset($users[0])) |
|
| 374 | + if ($users === false || !isset($users[0])) |
|
| 375 | 375 | { |
| 376 | 376 | throw new \Exception('Error creating user!'); |
| 377 | 377 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | public function getUserByResetHash($hash) |
| 382 | 382 | { |
| 383 | 383 | $users = $this->getUsersByFilter(new \Data\Filter("uniqueIdentifier eq $hash")); |
| 384 | - if($users === false || !isset($users[0])) |
|
| 384 | + if ($users === false || !isset($users[0])) |
|
| 385 | 385 | { |
| 386 | 386 | return false; |
| 387 | 387 | } |
@@ -241,7 +241,7 @@ |
||
| 241 | 241 | $obj['userPassword'] = $this->generateLDAPPass($password); |
| 242 | 242 | if(isset($this->ldap_obj->uniqueidentifier)) |
| 243 | 243 | { |
| 244 | - $obj['uniqueIdentifier'] = null; |
|
| 244 | + $obj['uniqueIdentifier'] = null; |
|
| 245 | 245 | } |
| 246 | 246 | //Make sure we are bound in write mode |
| 247 | 247 | $auth = \AuthProvider::getInstance(); |
@@ -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 | } |
@@ -116,26 +116,26 @@ |
||
| 116 | 116 | |
| 117 | 117 | private function getDataTable($name, $pending=false) |
| 118 | 118 | { |
| 119 | - if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 120 | - { |
|
| 121 | - return $this->dataTables[$name][$pending]; |
|
| 122 | - } |
|
| 123 | - $dataSet = $this->dataSet; |
|
| 124 | - if($pending) |
|
| 125 | - { |
|
| 126 | - $dataSet = $this->pendingDataSet; |
|
| 127 | - } |
|
| 128 | - if($dataSet === null) |
|
| 129 | - { |
|
| 130 | - throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
|
| 131 | - } |
|
| 132 | - $dataTable = $dataSet[$name]; |
|
| 133 | - if(!isset($this->dataTables[$name])) |
|
| 134 | - { |
|
| 135 | - $this->dataTables[$name] = array(); |
|
| 136 | - } |
|
| 137 | - $this->dataTables[$name][$pending] = $dataTable; |
|
| 138 | - return $dataTable; |
|
| 119 | + if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 120 | + { |
|
| 121 | + return $this->dataTables[$name][$pending]; |
|
| 122 | + } |
|
| 123 | + $dataSet = $this->dataSet; |
|
| 124 | + if($pending) |
|
| 125 | + { |
|
| 126 | + $dataSet = $this->pendingDataSet; |
|
| 127 | + } |
|
| 128 | + if($dataSet === null) |
|
| 129 | + { |
|
| 130 | + throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
|
| 131 | + } |
|
| 132 | + $dataTable = $dataSet[$name]; |
|
| 133 | + if(!isset($this->dataTables[$name])) |
|
| 134 | + { |
|
| 135 | + $this->dataTables[$name] = array(); |
|
| 136 | + } |
|
| 137 | + $this->dataTables[$name][$pending] = $dataTable; |
|
| 138 | + return $dataTable; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | private function getPendingUserDataTable() |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Auth; |
| 3 | 3 | |
| 4 | -if(!function_exists('password_hash') || !function_exists('password_verify')) |
|
| 4 | +if (!function_exists('password_hash') || !function_exists('password_verify')) |
|
| 5 | 5 | { |
| 6 | 6 | define('PASSWORD_BCRYPT', 1); |
| 7 | 7 | define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); |
@@ -9,22 +9,22 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | function password_hash($password, $algo = PASSWORD_DEFAULT) |
| 11 | 11 | { |
| 12 | - if(is_null($password) || is_int($password)) |
|
| 12 | + if (is_null($password) || is_int($password)) |
|
| 13 | 13 | { |
| 14 | 14 | $password = (string)$password; |
| 15 | 15 | } |
| 16 | - if(!is_string($password)) |
|
| 16 | + if (!is_string($password)) |
|
| 17 | 17 | { |
| 18 | 18 | trigger_error("password_hash(): Password must be a string", E_USER_WARNING); |
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | - if(!is_int($algo)) |
|
| 21 | + if (!is_int($algo)) |
|
| 22 | 22 | { |
| 23 | - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); |
|
| 23 | + trigger_error("password_hash() expects parameter 2 to be long, ".gettype($algo)." given", E_USER_WARNING); |
|
| 24 | 24 | return false; |
| 25 | 25 | } |
| 26 | 26 | $resultLength = 0; |
| 27 | - switch($algo) |
|
| 27 | + switch ($algo) |
|
| 28 | 28 | { |
| 29 | 29 | case PASSWORD_BCRYPT: |
| 30 | 30 | $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | $base64String = base64_encode($salt); |
| 44 | 44 | $salt = strtr(rtrim($base64String, '='), $base64Digits, $bcrypt64Digits); |
| 45 | 45 | $salt = substr($salt, 0, $requiredSaltLen); |
| 46 | - $hash = $hashFormat . $salt; |
|
| 46 | + $hash = $hashFormat.$salt; |
|
| 47 | 47 | $ret = crypt($password, $hash); |
| 48 | - if(!is_string($ret) || strlen($ret) != $resultLength) |
|
| 48 | + if (!is_string($ret) || strlen($ret) != $resultLength) |
|
| 49 | 49 | { |
| 50 | 50 | return false; |
| 51 | 51 | } |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | function password_verify($password, $hash) |
| 56 | 56 | { |
| 57 | 57 | $ret = crypt($password, $hash); |
| 58 | - if(!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) |
|
| 58 | + if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) |
|
| 59 | 59 | { |
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | $status = 0; |
| 63 | 63 | $count = strlen($ret); |
| 64 | - for($i = 0; $i < $count; $i++) |
|
| 64 | + for ($i = 0; $i < $count; $i++) |
|
| 65 | 65 | { |
| 66 | 66 | $status |= (ord($ret[$i]) ^ ord($hash[$i])); |
| 67 | 67 | } |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | parent::__construct($params); |
| 82 | 82 | $this->params = $params; |
| 83 | - if($this->current) |
|
| 83 | + if ($this->current) |
|
| 84 | 84 | { |
| 85 | 85 | $this->dataSet = $this->getCurrentDataSet(); |
| 86 | 86 | } |
| 87 | - if($this->pending) |
|
| 87 | + if ($this->pending) |
|
| 88 | 88 | { |
| 89 | 89 | $this->pendingDataSet = $this->getPendingDataSet(); |
| 90 | 90 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private function getCurrentDataSet() |
| 97 | 97 | { |
| 98 | - if(isset($this->params['current_data_set'])) |
|
| 98 | + if (isset($this->params['current_data_set'])) |
|
| 99 | 99 | { |
| 100 | 100 | return \DataSetFactory::get_data_set($this->params['current_data_set']); |
| 101 | 101 | } |
@@ -107,30 +107,30 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | private function getPendingDataSet() |
| 109 | 109 | { |
| 110 | - if(isset($this->params['pending_data_set'])) |
|
| 110 | + if (isset($this->params['pending_data_set'])) |
|
| 111 | 111 | { |
| 112 | 112 | return \DataSetFactory::get_data_set($this->params['pending_data_set']); |
| 113 | 113 | } |
| 114 | 114 | return \DataSetFactory::get_data_set('pending_authentication'); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private function getDataTable($name, $pending=false) |
|
| 117 | + private function getDataTable($name, $pending = false) |
|
| 118 | 118 | { |
| 119 | - if(isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 119 | + if (isset($this->dataTables[$name]) && isset($this->dataTables[$name][$pending])) |
|
| 120 | 120 | { |
| 121 | 121 | return $this->dataTables[$name][$pending]; |
| 122 | 122 | } |
| 123 | 123 | $dataSet = $this->dataSet; |
| 124 | - if($pending) |
|
| 124 | + if ($pending) |
|
| 125 | 125 | { |
| 126 | 126 | $dataSet = $this->pendingDataSet; |
| 127 | 127 | } |
| 128 | - if($dataSet === null) |
|
| 128 | + if ($dataSet === null) |
|
| 129 | 129 | { |
| 130 | 130 | throw new \Exception('Unable to obtain dataset for SQL Authentication!'); |
| 131 | 131 | } |
| 132 | 132 | $dataTable = $dataSet[$name]; |
| 133 | - if(!isset($this->dataTables[$name])) |
|
| 133 | + if (!isset($this->dataTables[$name])) |
|
| 134 | 134 | { |
| 135 | 135 | $this->dataTables[$name] = array(); |
| 136 | 136 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | private function getPendingUserDataTable() |
| 142 | 142 | { |
| 143 | - if(isset($this->params['pending_user_table'])) |
|
| 143 | + if (isset($this->params['pending_user_table'])) |
|
| 144 | 144 | { |
| 145 | 145 | return $this->getDataTable($this->params['pending_user_table'], true); |
| 146 | 146 | } |
@@ -149,15 +149,15 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function login($username, $password) |
| 151 | 151 | { |
| 152 | - if($this->current === false) return false; |
|
| 152 | + if ($this->current === false) return false; |
|
| 153 | 153 | $userDataTable = $this->getDataTable('user'); |
| 154 | 154 | $filter = new \Data\Filter("uid eq '$username'"); |
| 155 | 155 | $users = $userDataTable->read($filter, 'uid,pass'); |
| 156 | - if($users === false || !isset($users[0])) |
|
| 156 | + if ($users === false || !isset($users[0])) |
|
| 157 | 157 | { |
| 158 | 158 | return false; |
| 159 | 159 | } |
| 160 | - if(password_verify($password, $users[0]['pass'])) |
|
| 160 | + if (password_verify($password, $users[0]['pass'])) |
|
| 161 | 161 | { |
| 162 | 162 | return array('res'=>true, 'extended'=>$users[0]['uid']); |
| 163 | 163 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | public function isLoggedIn($data) |
| 168 | 168 | { |
| 169 | - if(isset($data['res'])) |
|
| 169 | + if (isset($data['res'])) |
|
| 170 | 170 | { |
| 171 | 171 | return $data['res']; |
| 172 | 172 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $groupDataTable = $this->getDataTable('group'); |
| 184 | 184 | $filter = new \Data\Filter("gid eq '$name'"); |
| 185 | 185 | $groups = $groupDataTable->read($filter); |
| 186 | - if($groups === false || !isset($groups[0])) |
|
| 186 | + if ($groups === false || !isset($groups[0])) |
|
| 187 | 187 | { |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $userDataTable = $this->getDataTable('user'); |
| 196 | 196 | $filter = new \Data\Filter("uid eq '$name'"); |
| 197 | 197 | $users = $userDataTable->read($filter); |
| 198 | - if($users === false || !isset($users[0])) |
|
| 198 | + if ($users === false || !isset($users[0])) |
|
| 199 | 199 | { |
| 200 | 200 | return false; |
| 201 | 201 | } |
@@ -211,33 +211,33 @@ discard block |
||
| 211 | 211 | private function convertDataToClass($dataTableName, $className, $filter, $select, $top, $skip, $orderby) |
| 212 | 212 | { |
| 213 | 213 | $data = $this->getDataByFilter($dataTableName, $filter, $select, $top, $skip, $orderby); |
| 214 | - if($data === false) |
|
| 214 | + if ($data === false) |
|
| 215 | 215 | { |
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | $count = count($data); |
| 219 | - for($i = 0; $i < $count; $i++) |
|
| 219 | + for ($i = 0; $i < $count; $i++) |
|
| 220 | 220 | { |
| 221 | 221 | $data[$i] = new $className($groups[$i]); |
| 222 | 222 | } |
| 223 | 223 | return $data; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
| 226 | + public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
| 227 | 227 | { |
| 228 | 228 | return $this->convertDataToClass('group', 'SQLGroup', $filter, $select, $top, $skip, $orderby); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
| 231 | + public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
| 232 | 232 | { |
| 233 | 233 | return $this->convertDataToClass('group', 'SQLUser', $filter, $select, $top, $skip, $orderby); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public function getPendingUserCount() |
| 237 | 237 | { |
| 238 | - if($this->pending === false) return 0; |
|
| 238 | + if ($this->pending === false) return 0; |
|
| 239 | 239 | $dataTable = $this->getPendingUserDataTable(); |
| 240 | - if($dataTable === null) return 0; |
|
| 240 | + if ($dataTable === null) return 0; |
|
| 241 | 241 | return $dataTable->count(); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,26 +245,26 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | $userDataTable = $this->getPendingUserDataTable(); |
| 247 | 247 | $fieldData = $filter->to_mongo_filter(); |
| 248 | - $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData,' ').'")'); |
|
| 248 | + $firstFilter = new \Data\Filter('substringof(data,"'.implode($fieldData, ' ').'")'); |
|
| 249 | 249 | $users = $userDataTable->read($firstFilter, $select, $top, $skip, $orderby); |
| 250 | - if($users === false) |
|
| 250 | + if ($users === false) |
|
| 251 | 251 | { |
| 252 | 252 | return false; |
| 253 | 253 | } |
| 254 | 254 | $ret = array(); |
| 255 | 255 | $count = count($users); |
| 256 | - for($i = 0; $i < $count; $i++) |
|
| 256 | + for ($i = 0; $i < $count; $i++) |
|
| 257 | 257 | { |
| 258 | 258 | $user = new SQLPendingUser($users[$i], $userDataTable); |
| 259 | 259 | $err = false; |
| 260 | - foreach($fieldData as $field=>$data) |
|
| 260 | + foreach ($fieldData as $field=>$data) |
|
| 261 | 261 | { |
| 262 | - if(strcasecmp($user[$field], $data) !== 0) |
|
| 262 | + if (strcasecmp($user[$field], $data) !== 0) |
|
| 263 | 263 | { |
| 264 | 264 | $err = true; break; |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | - if(!$err) |
|
| 267 | + if (!$err) |
|
| 268 | 268 | { |
| 269 | 269 | array_push($ret, $user); |
| 270 | 270 | } |
@@ -272,22 +272,22 @@ discard block |
||
| 272 | 272 | return $ret; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
| 275 | + public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
| 276 | 276 | |
| 277 | 277 | { |
| 278 | - if($this->pending === false) return false; |
|
| 279 | - if($filter !== false && !$filter->contains('hash')) |
|
| 278 | + if ($this->pending === false) return false; |
|
| 279 | + if ($filter !== false && !$filter->contains('hash')) |
|
| 280 | 280 | { |
| 281 | 281 | return $this->searchPendingUsers($filter, $select, $top, $skip, $orderby); |
| 282 | 282 | } |
| 283 | 283 | $userDataTable = $this->getPendingUserDataTable(); |
| 284 | 284 | $users = $userDataTable->read($filter, $select, $top, $skip, $orderby); |
| 285 | - if($users === false) |
|
| 285 | + if ($users === false) |
|
| 286 | 286 | { |
| 287 | 287 | return false; |
| 288 | 288 | } |
| 289 | 289 | $count = count($users); |
| 290 | - for($i = 0; $i < $count; $i++) |
|
| 290 | + for ($i = 0; $i < $count; $i++) |
|
| 291 | 291 | { |
| 292 | 292 | $users[$i] = new SQLPendingUser($users[$i], $userDataTable); |
| 293 | 293 | } |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | public function createPendingUser($user) |
| 298 | 298 | { |
| 299 | - if($this->pending === false) return false; |
|
| 299 | + if ($this->pending === false) return false; |
|
| 300 | 300 | $userDataTable = $this->getPendingUserDataTable(); |
| 301 | - if(isset($user->password2)) |
|
| 301 | + if (isset($user->password2)) |
|
| 302 | 302 | { |
| 303 | 303 | unset($user->password2); |
| 304 | 304 | } |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | $hash = hash('sha512', $json); |
| 307 | 307 | $array = array('hash'=>$hash, 'data'=>$json); |
| 308 | 308 | $ret = $userDataTable->create($array); |
| 309 | - if($ret !== false) |
|
| 309 | + if ($ret !== false) |
|
| 310 | 310 | { |
| 311 | 311 | $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
| 312 | - if($users === false || !isset($users[0])) |
|
| 312 | + if ($users === false || !isset($users[0])) |
|
| 313 | 313 | { |
| 314 | 314 | throw new \Exception('Error retreiving user object after successful create!'); |
| 315 | 315 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | public function getTempUserByHash($hash) |
| 322 | 322 | { |
| 323 | 323 | $users = $this->getPendingUsersByFilter(new \Data\Filter("hash eq '$hash'")); |
| 324 | - if($users === false || !isset($users[0])) |
|
| 324 | + if ($users === false || !isset($users[0])) |
|
| 325 | 325 | { |
| 326 | 326 | return false; |
| 327 | 327 | } |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | $ret = $auth->activatePendingUser($user); |
| 67 | 67 | if($ret === false) |
| 68 | 68 | {
|
| 69 | - throw new \Exception('Unable to create user! '.$res);
|
|
| 69 | + throw new \Exception('Unable to create user! '.$res);
|
|
| 70 | 70 | } |
| 71 | 71 | return self::SUCCESS; |
| 72 | 72 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | public function __construct($params) |
| 11 | 11 | {
|
| 12 | 12 | parent::__construct($params); |
| 13 | - if(!isset($params['client_secrets_path'])) |
|
| 13 | + if (!isset($params['client_secrets_path'])) |
|
| 14 | 14 | {
|
| 15 | 15 | throw new \Exception('Missing required parameter client_secrets_path!');
|
| 16 | 16 | } |
| 17 | - if(!isset($params['redirect_url'])) |
|
| 17 | + if (!isset($params['redirect_url'])) |
|
| 18 | 18 | {
|
| 19 | 19 | $params['redirect_url'] = 'https://'.$_SERVER['HTTP_HOST'].'/oauth2callback.php?src=google'; |
| 20 | 20 | } |
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | public function authenticate($code, &$currentUser = false) |
| 35 | 35 | {
|
| 36 | 36 | $googleUser = false; |
| 37 | - try{
|
|
| 37 | + try {
|
|
| 38 | 38 | $this->client->authenticate($code); |
| 39 | 39 | $this->token = $this->client->getAccessToken(); |
| 40 | 40 | \FlipSession::setVar('GoogleToken', $this->token);
|
| 41 | 41 | $oauth2Service = new \Google_Service_Oauth2($this->client); |
| 42 | 42 | $googleUser = $oauth2Service->userinfo->get(); |
| 43 | - } catch(\Exception $ex) {
|
|
| 43 | + } catch (\Exception $ex) {
|
|
| 44 | 44 | return self::LOGIN_FAILED; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $auth = \AuthProvider::getInstance(); |
| 48 | 48 | $localUsers = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$googleUser->email));
|
| 49 | - if($localUsers !== false && isset($localUsers[0])) |
|
| 49 | + if ($localUsers !== false && isset($localUsers[0])) |
|
| 50 | 50 | {
|
| 51 | - if($localUsers[0]->canLoginWith('google.com'))
|
|
| 51 | + if ($localUsers[0]->canLoginWith('google.com'))
|
|
| 52 | 52 | {
|
| 53 | 53 | $auth->impersonateUser($localUsers[0]); |
| 54 | 54 | return self::SUCCESS; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $user->setLastName($googleUser->familyName); |
| 65 | 65 | $user->addLoginProvider('google.com');
|
| 66 | 66 | $ret = $auth->activatePendingUser($user); |
| 67 | - if($ret === false) |
|
| 67 | + if ($ret === false) |
|
| 68 | 68 | {
|
| 69 | 69 | throw new \Exception('Unable to create user! '.$res);
|
| 70 | 70 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function getUser($data = false) |
| 76 | 76 | {
|
| 77 | - if($data === false) |
|
| 77 | + if ($data === false) |
|
| 78 | 78 | {
|
| 79 | 79 | $data = $this->token; |
| 80 | 80 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $profileUser['displayName'] = $googleUser->name; |
| 90 | 90 | $profileUser['jpegPhoto'] = base64_encode(file_get_contents($googleUser->picture)); |
| 91 | 91 | return $profileUser; |
| 92 | - } catch(\Exception $e) |
|
| 92 | + } catch (\Exception $e) |
|
| 93 | 93 | {
|
| 94 | 94 | return false; |
| 95 | 95 | } |