@@ -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'], |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | if ($imageClass !== Image::class && !is_subclass_of($imageClass, Image::class)) { |
| 642 | 642 | $this->getLogger()->warning( |
| 643 | 643 | sprintf( |
| 644 | - 'Member field %s configured for ' . $attributeName . ' AD attribute, but it isn\'t a valid relation to an ' |
|
| 644 | + 'Member field %s configured for '.$attributeName.' AD attribute, but it isn\'t a valid relation to an ' |
|
| 645 | 645 | . 'Image class', |
| 646 | 646 | $fieldName |
| 647 | 647 | ) |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | // Setup variables |
| 669 | 669 | $thumbnailFolder = Folder::find_or_make($member->config()->ldap_thumbnail_path); |
| 670 | - $filename = sprintf($attributeName . '-%s.jpg', $data['objectguid']); |
|
| 670 | + $filename = sprintf($attributeName.'-%s.jpg', $data['objectguid']); |
|
| 671 | 671 | $filePath = File::join_paths($thumbnailFolder->getFilename(), $filename); |
| 672 | 672 | $fileCfg = [ |
| 673 | 673 | // if there's a filename conflict we've got new content so overwrite it. |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | // Lookup the previous mappings and see if there is any mappings no longer present. |
| 763 | - $unmappedGroups = $member->Groups()->alterDataQuery(function (DataQuery $query) { |
|
| 763 | + $unmappedGroups = $member->Groups()->alterDataQuery(function(DataQuery $query) { |
|
| 764 | 764 | // join with the Group_Members table because we only want those group members assigned by this module. |
| 765 | 765 | $query->leftJoin("Group_Members", '"Group_Members"."GroupID" = "Group"."ID"'); |
| 766 | 766 | $query->where('"Group_Members"."IsImportedFromLDAP" = 1'); |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | $group->Description = $data['description']; |
| 802 | 802 | } |
| 803 | 803 | $group->DN = $data['dn']; |
| 804 | - $group->LastSynced = (string)DBDatetime::now(); |
|
| 804 | + $group->LastSynced = (string) DBDatetime::now(); |
|
| 805 | 805 | $group->write(); |
| 806 | 806 | |
| 807 | 807 | // Mappings on this group are automatically maintained to contain just the group's DN. |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | ), |
| 865 | 865 | ]); |
| 866 | 866 | } catch (Exception $e) { |
| 867 | - throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage()); |
|
| 867 | + throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage()); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | $user = $this->getUserByUsername($member->Username); |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | 'distinguishedname' => $dn |
| 909 | 909 | ]); |
| 910 | 910 | } catch (Exception $e) { |
| 911 | - throw new ValidationException('LDAP group creation failure: ' . $e->getMessage()); |
|
| 911 | + throw new ValidationException('LDAP group creation failure: '.$e->getMessage()); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | $data = $this->getGroupByDN($dn); |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | $dn = $newDn; |
| 965 | 965 | } |
| 966 | 966 | } catch (Exception $e) { |
| 967 | - throw new ValidationException('LDAP move failure: ' . $e->getMessage()); |
|
| 967 | + throw new ValidationException('LDAP move failure: '.$e->getMessage()); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | try { |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | |
| 989 | 989 | $this->update($dn, $attributes); |
| 990 | 990 | } catch (Exception $e) { |
| 991 | - throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage()); |
|
| 991 | + throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage()); |
|
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | try { |
| 1074 | 1074 | $this->update($groupDn, ['member' => $members]); |
| 1075 | 1075 | } catch (Exception $e) { |
| 1076 | - throw new ValidationException('LDAP group membership remove failure: ' . $e->getMessage()); |
|
| 1076 | + throw new ValidationException('LDAP group membership remove failure: '.$e->getMessage()); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | } |
| 1079 | 1079 | } |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | try { |
| 1100 | 1100 | $this->update($groupDn, ['member' => $members]); |
| 1101 | 1101 | } catch (Exception $e) { |
| 1102 | - throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage()); |
|
| 1102 | + throw new ValidationException('LDAP group membership add failure: '.$e->getMessage()); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | } |
| 1105 | 1105 | |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | try { |
| 1183 | 1183 | $this->delete($data['distinguishedname']); |
| 1184 | 1184 | } catch (Exception $e) { |
| 1185 | - throw new ValidationException('LDAP delete user failed: ' . $e->getMessage()); |
|
| 1185 | + throw new ValidationException('LDAP delete user failed: '.$e->getMessage()); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | } |
| 1188 | 1188 | |