@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | } else { |
| 114 | 114 | $resultResource = ldap_search($resource, $baseDn, $this->getFilter()); |
| 115 | 115 | } |
| 116 | - if (! is_resource($resultResource)) { |
|
| 116 | + if (!is_resource($resultResource)) { |
|
| 117 | 117 | /* |
| 118 | 118 | * @TODO better exception msg |
| 119 | 119 | */ |
| 120 | - throw new \Exception('ldap_search returned something wrong...' . ldap_error($resource)); |
|
| 120 | + throw new \Exception('ldap_search returned something wrong...'.ldap_error($resource)); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $entries = ldap_get_entries($resource, $resultResource); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $attributeValue = []; |
| 205 | 205 | |
| 206 | 206 | $limit = $offset + $maxPerRequest - 1; |
| 207 | - $searchedAttribute = $attrName . ';range=' . $offset . '-' . $limit; |
|
| 207 | + $searchedAttribute = $attrName.';range='.$offset.'-'.$limit; |
|
| 208 | 208 | |
| 209 | 209 | $ldap = $this->getLdap(); |
| 210 | 210 | $entry = $ldap->getEntry($dn, [ |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | public function current() |
| 236 | 236 | { |
| 237 | - if (! is_array($this->current)) { |
|
| 237 | + if (!is_array($this->current)) { |
|
| 238 | 238 | $this->rewind(); |
| 239 | 239 | } |
| 240 | - if (! is_array($this->current)) { |
|
| 240 | + if (!is_array($this->current)) { |
|
| 241 | 241 | return; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | public function key() |
| 247 | 247 | { |
| 248 | - if (! is_array($this->current)) { |
|
| 248 | + if (!is_array($this->current)) { |
|
| 249 | 249 | $this->rewind(); |
| 250 | 250 | } |
| 251 | - if (! is_array($this->current)) { |
|
| 251 | + if (!is_array($this->current)) { |
|
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | $member->write(); |
| 153 | 153 | |
| 154 | 154 | // Pretend we're the module, and generate some mappings. |
| 155 | - Group::get()->each(function ($group) use ($member) { |
|
| 155 | + Group::get()->each(function($group) use ($member) { |
|
| 156 | 156 | $group->Members()->add($member, [ |
| 157 | 157 | 'IsImportedFromLDAP' => '1' |
| 158 | 158 | ]); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @var array |
| 28 | 28 | */ |
| 29 | 29 | private static $dependencies = [ |
| 30 | - 'LDAPService' => '%$' . LDAPService::class, |
|
| 30 | + 'LDAPService' => '%$'.LDAPService::class, |
|
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getTitle() |
| 51 | 51 | { |
| 52 | - return _t(__CLASS__ . '.SYNCTITLE', 'Sync all groups from LDAP'); |
|
| 52 | + return _t(__CLASS__.'.SYNCTITLE', 'Sync all groups from LDAP'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function log($message) |
| 160 | 160 | { |
| 161 | - $message = sprintf('[%s] ', date('Y-m-d H:i:s')) . $message; |
|
| 162 | - echo Director::is_cli() ? ($message . PHP_EOL) : ($message . '<br>'); |
|
| 161 | + $message = sprintf('[%s] ', date('Y-m-d H:i:s')).$message; |
|
| 162 | + echo Director::is_cli() ? ($message.PHP_EOL) : ($message.'<br>'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @var array |
| 29 | 29 | */ |
| 30 | 30 | private static $dependencies = [ |
| 31 | - 'LDAPService' => '%$' . LDAPService::class, |
|
| 31 | + 'LDAPService' => '%$'.LDAPService::class, |
|
| 32 | 32 | ]; |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function getTitle() |
| 52 | 52 | { |
| 53 | - return _t(__CLASS__ . '.SYNCTITLE', 'Sync all users from Active Directory'); |
|
| 53 | + return _t(__CLASS__.'.SYNCTITLE', 'Sync all users from Active Directory'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function log($message) |
| 156 | 156 | { |
| 157 | - $message = sprintf('[%s] ', date('Y-m-d H:i:s')) . $message; |
|
| 158 | - echo Director::is_cli() ? ($message . PHP_EOL) : ($message . '<br>'); |
|
| 157 | + $message = sprintf('[%s] ', date('Y-m-d H:i:s')).$message; |
|
| 158 | + echo Director::is_cli() ? ($message.PHP_EOL) : ($message.'<br>'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @var array |
| 27 | 27 | */ |
| 28 | 28 | private static $dependencies = [ |
| 29 | - 'LDAPService' => '%$' . LDAPService::class, |
|
| 29 | + 'LDAPService' => '%$'.LDAPService::class, |
|
| 30 | 30 | ]; |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function getTitle() |
| 41 | 41 | { |
| 42 | - return _t(__CLASS__ . '.SYNCONETITLE', 'Sync single user from LDAP'); |
|
| 42 | + return _t(__CLASS__.'.SYNCONETITLE', 'Sync single user from LDAP'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | 'IsExpired', |
| 125 | 125 | $ldapMetadata[] = ReadonlyField::create( |
| 126 | 126 | 'IsExpired', |
| 127 | - _t(__CLASS__ . '.ISEXPIRED', 'Has user\'s LDAP/AD login expired?') |
|
| 127 | + _t(__CLASS__.'.ISEXPIRED', 'Has user\'s LDAP/AD login expired?') |
|
| 128 | 128 | ) |
| 129 | 129 | ); |
| 130 | 130 | $fields->replaceField( |
| 131 | 131 | 'LastSynced', |
| 132 | 132 | $ldapMetadata[] = ReadonlyField::create( |
| 133 | 133 | 'LastSynced', |
| 134 | - _t(__CLASS__ . '.LASTSYNCED', 'Last synced') |
|
| 134 | + _t(__CLASS__.'.LASTSYNCED', 'Last synced') |
|
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | $fields->addFieldsToTab('Root.LDAP', $ldapMetadata); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $message = ''; |
| 140 | 140 | if ($this->owner->GUID && $this->owner->config()->update_ldap_from_local) { |
| 141 | 141 | $message = _t( |
| 142 | - __CLASS__ . '.CHANGEFIELDSUPDATELDAP', |
|
| 142 | + __CLASS__.'.CHANGEFIELDSUPDATELDAP', |
|
| 143 | 143 | 'Changing fields here will update them in LDAP.' |
| 144 | 144 | ); |
| 145 | 145 | } elseif ($this->owner->GUID && !$this->owner->config()->update_ldap_from_local) { |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | // Set to readonly, but not disabled so that the data is still sent to the |
| 152 | 152 | // server and doesn't break Member_Validator |
| 153 | 153 | $field->setReadonly(true); |
| 154 | - $field->setTitle($field->Title() . _t(__CLASS__ . '.IMPORTEDFIELD', ' (imported)')); |
|
| 154 | + $field->setTitle($field->Title()._t(__CLASS__.'.IMPORTEDFIELD', ' (imported)')); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | $message = _t( |
| 158 | - __CLASS__ . '.INFOIMPORTED', |
|
| 159 | - 'This user is automatically imported from LDAP. ' . |
|
| 158 | + __CLASS__.'.INFOIMPORTED', |
|
| 159 | + 'This user is automatically imported from LDAP. '. |
|
| 160 | 160 | 'Manual changes to imported fields will be removed upon sync.' |
| 161 | 161 | ); |
| 162 | 162 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | for ($k = 1; $k <= 2; ++$k) { |
| 43 | 43 | $hex_guid_to_guid_str .= substr($hex_guid, 16 - 2 * $k, 2); |
| 44 | 44 | } |
| 45 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 16, 4); |
|
| 46 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 20); |
|
| 45 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 16, 4); |
|
| 46 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 20); |
|
| 47 | 47 | |
| 48 | 48 | return strtoupper($hex_guid_to_guid_str); |
| 49 | 49 | } |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | for ($x = 0; $x < $subcount; $x++) { |
| 97 | 97 | $subauth[$x] = hexdec(self::little_endian(substr($hex_sid, 16 + ($x * 8), 8))); |
| 98 | - $result .= '-' . $subauth[$x]; |
|
| 98 | + $result .= '-'.$subauth[$x]; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Cheat by tacking on the S- |
| 102 | - return 'S-' . $result; |
|
| 102 | + return 'S-'.$result; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | 51 | private static $dependencies = [ |
| 52 | - 'gateway' => '%$' . LDAPGateway::class |
|
| 52 | + 'gateway' => '%$'.LDAPGateway::class |
|
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public static function get_cache() |
| 127 | 127 | { |
| 128 | - return Injector::inst()->get(CacheInterface::class . '.ldap'); |
|
| 128 | + return Injector::inst()->get(CacheInterface::class.'.ldap'); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | // show better errors than the defaults for various status codes returned by LDAP |
| 208 | 208 | if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_ACCOUNT_LOCKED_OUT') !== false) { |
| 209 | 209 | $message = _t( |
| 210 | - __CLASS__ . '.ACCOUNTLOCKEDOUT', |
|
| 211 | - 'Your account has been temporarily locked because of too many failed login attempts. ' . |
|
| 210 | + __CLASS__.'.ACCOUNTLOCKEDOUT', |
|
| 211 | + 'Your account has been temporarily locked because of too many failed login attempts. '. |
|
| 212 | 212 | 'Please try again later.' |
| 213 | 213 | ); |
| 214 | 214 | } |
| 215 | 215 | if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_LOGON_FAILURE') !== false) { |
| 216 | 216 | $message = _t( |
| 217 | - __CLASS__ . '.INVALIDCREDENTIALS', |
|
| 217 | + __CLASS__.'.INVALIDCREDENTIALS', |
|
| 218 | 218 | 'The provided details don\'t seem to be correct. Please try again.' |
| 219 | 219 | ); |
| 220 | 220 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | public function getNodes($cached = true, $attributes = []) |
| 238 | 238 | { |
| 239 | 239 | $cache = self::get_cache(); |
| 240 | - $cacheKey = 'nodes' . md5(implode('', $attributes)); |
|
| 240 | + $cacheKey = 'nodes'.md5(implode('', $attributes)); |
|
| 241 | 241 | $results = $cache->has($cacheKey); |
| 242 | 242 | |
| 243 | 243 | if (!$results || !$cached) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | $searchLocations = $this->config()->groups_search_locations ?: [null]; |
| 269 | 269 | $cache = self::get_cache(); |
| 270 | - $cacheKey = 'groups' . md5(implode('', array_merge($searchLocations, $attributes))); |
|
| 270 | + $cacheKey = 'groups'.md5(implode('', array_merge($searchLocations, $attributes))); |
|
| 271 | 271 | $results = $cache->has($cacheKey); |
| 272 | 272 | |
| 273 | 273 | if (!$results || !$cached) { |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | $member->IsExpired = ($data['useraccountcontrol'] & 2) == 2; |
| 538 | - $member->LastSynced = (string)DBDatetime::now(); |
|
| 538 | + $member->LastSynced = (string) DBDatetime::now(); |
|
| 539 | 539 | |
| 540 | 540 | foreach ($member->config()->ldap_field_mappings as $attribute => $field) { |
| 541 | 541 | // Special handling required for attributes that don't exist in the response. |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | } else { |
| 557 | 557 | $this->getLogger()->debug( |
| 558 | 558 | sprintf( |
| 559 | - 'Attribute %s configured in Member.ldap_field_mappings, ' . |
|
| 559 | + 'Attribute %s configured in Member.ldap_field_mappings, '. |
|
| 560 | 560 | 'but no available attribute in AD data (GUID: %s, Member ID: %s)', |
| 561 | 561 | $attribute, |
| 562 | 562 | $data['objectguid'], |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | // Lookup the previous mappings and see if there is any mappings no longer present. |
| 747 | - $unmappedGroups = $member->Groups()->alterDataQuery(function (DataQuery $query) { |
|
| 747 | + $unmappedGroups = $member->Groups()->alterDataQuery(function(DataQuery $query) { |
|
| 748 | 748 | // join with the Group_Members table because we only want those group members assigned by this module. |
| 749 | 749 | $query->leftJoin("Group_Members", '"Group_Members"."GroupID" = "Group"."ID"'); |
| 750 | 750 | $query->where('"Group_Members"."IsImportedFromLDAP" = 1'); |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $group->Description = $data['description']; |
| 786 | 786 | } |
| 787 | 787 | $group->DN = $data['dn']; |
| 788 | - $group->LastSynced = (string)DBDatetime::now(); |
|
| 788 | + $group->LastSynced = (string) DBDatetime::now(); |
|
| 789 | 789 | $group->write(); |
| 790 | 790 | |
| 791 | 791 | // Mappings on this group are automatically maintained to contain just the group's DN. |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | ), |
| 849 | 849 | ]); |
| 850 | 850 | } catch (Exception $e) { |
| 851 | - throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage()); |
|
| 851 | + throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage()); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | $user = $this->getUserByUsername($member->Username); |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | 'distinguishedname' => $dn |
| 893 | 893 | ]); |
| 894 | 894 | } catch (Exception $e) { |
| 895 | - throw new ValidationException('LDAP group creation failure: ' . $e->getMessage()); |
|
| 895 | + throw new ValidationException('LDAP group creation failure: '.$e->getMessage()); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | $data = $this->getGroupByDN($dn); |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | $dn = $newDn; |
| 949 | 949 | } |
| 950 | 950 | } catch (Exception $e) { |
| 951 | - throw new ValidationException('LDAP move failure: ' . $e->getMessage()); |
|
| 951 | + throw new ValidationException('LDAP move failure: '.$e->getMessage()); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | try { |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | $this->update($dn, $attributes); |
| 974 | 974 | } catch (Exception $e) { |
| 975 | - throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage()); |
|
| 975 | + throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage()); |
|
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | try { |
| 1058 | 1058 | $this->update($groupDn, ['member' => $members]); |
| 1059 | 1059 | } catch (Exception $e) { |
| 1060 | - throw new ValidationException('LDAP group membership remove failure: ' . $e->getMessage()); |
|
| 1060 | + throw new ValidationException('LDAP group membership remove failure: '.$e->getMessage()); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | } |
| 1063 | 1063 | } |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | try { |
| 1084 | 1084 | $this->update($groupDn, ['member' => $members]); |
| 1085 | 1085 | } catch (Exception $e) { |
| 1086 | - throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage()); |
|
| 1086 | + throw new ValidationException('LDAP group membership add failure: '.$e->getMessage()); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | 1089 | |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | try { |
| 1167 | 1167 | $this->delete($data['distinguishedname']); |
| 1168 | 1168 | } catch (Exception $e) { |
| 1169 | - throw new ValidationException('LDAP delete user failed: ' . $e->getMessage()); |
|
| 1169 | + throw new ValidationException('LDAP delete user failed: '.$e->getMessage()); |
|
| 1170 | 1170 | } |
| 1171 | 1171 | } |
| 1172 | 1172 | |