Passed
Push — master ( 92b22a...c0cf2f )
by Robbie
04:26
created
src/Model/LDAPGroupMapping.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @var array
48 48
      */
49 49
     private static $dependencies = [
50
-        'ldapService' => '%$' . LDAPService::class,
50
+        'ldapService' => '%$'.LDAPService::class,
51 51
     ];
52 52
 
53 53
     private static $singular_name = 'LDAP Group Mapping';
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
         $fields = parent::getCMSFields();
64 64
         $fields->removeByName('DN');
65 65
 
66
-        $field = DropdownField::create('DN', _t(__CLASS__ . '.LDAPGROUP', 'LDAP Group'));
67
-        $field->setEmptyString(_t(__CLASS__ . '.SELECTONE', 'Select one'));
66
+        $field = DropdownField::create('DN', _t(__CLASS__.'.LDAPGROUP', 'LDAP Group'));
67
+        $field->setEmptyString(_t(__CLASS__.'.SELECTONE', 'Select one'));
68 68
         $groups = $this->ldapService->getGroups(true, ['dn', 'name']);
69 69
         $source = [];
70 70
         if ($groups) {
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
         $fields->removeByName('Scope');
80 80
         $fields->addFieldToTab(
81 81
             'Root.Main',
82
-            DropdownField::create('Scope', _t(__CLASS__ . '.SCOPE', 'Scope'), [
82
+            DropdownField::create('Scope', _t(__CLASS__.'.SCOPE', 'Scope'), [
83 83
                 'Subtree' => _t(
84
-                    __CLASS__ . '.SUBTREE_DESCRIPTION',
84
+                    __CLASS__.'.SUBTREE_DESCRIPTION',
85 85
                     'Users within this group and all nested groups within'
86 86
                 ),
87
-                'OneLevel' => _t(__CLASS__ . '.ONELEVEL_DESCRIPTION', 'Only users within this group'),
87
+                'OneLevel' => _t(__CLASS__.'.ONELEVEL_DESCRIPTION', 'Only users within this group'),
88 88
             ])
89 89
         );
90 90
 
Please login to merge, or discard this patch.
src/Extensions/LDAPGroupExtension.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'Root.LDAP',
65 65
             ReadonlyField::create(
66 66
                 'LastSynced',
67
-                _t(__CLASS__ . '.LASTSYNCED', 'Last synced')
67
+                _t(__CLASS__.'.LASTSYNCED', 'Last synced')
68 68
             )
69 69
         );
70 70
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $fields->addFieldToTab('Root.Members', ReadonlyField::create('Code'), 'Members');
76 76
 
77 77
             $message = _t(
78
-                __CLASS__ . '.INFOIMPORTED',
78
+                __CLASS__.'.INFOIMPORTED',
79 79
                 'This group is automatically imported from LDAP.'
80 80
             );
81 81
             $fields->addFieldToTab(
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
 
90 90
             $fields->addFieldToTab('Root.LDAP', ReadonlyField::create(
91 91
                 'LDAPGroupMappingsRO',
92
-                _t(__CLASS__ . '.AUTOMAPPEDGROUPS', 'Automatically mapped LDAP Groups'),
92
+                _t(__CLASS__.'.AUTOMAPPEDGROUPS', 'Automatically mapped LDAP Groups'),
93 93
                 implode('; ', $this->owner->LDAPGroupMappings()->column('DN'))
94 94
             ));
95 95
         } else {
96 96
             $field = GridField::create(
97 97
                 'LDAPGroupMappings',
98
-                _t(__CLASS__ . '.MAPPEDGROUPS', 'Mapped LDAP Groups'),
98
+                _t(__CLASS__.'.MAPPEDGROUPS', 'Mapped LDAP Groups'),
99 99
                 $this->owner->LDAPGroupMappings()
100 100
             );
101 101
             $config = GridFieldConfig_RecordEditor::create();
102 102
             $config->getComponentByType(GridFieldAddNewButton::class)
103
-                ->setButtonName(_t(__CLASS__ . '.ADDMAPPEDGROUP', 'Add LDAP group mapping'));
103
+                ->setButtonName(_t(__CLASS__.'.ADDMAPPEDGROUP', 'Add LDAP group mapping'));
104 104
 
105 105
             $field->setConfig($config);
106 106
             $fields->addFieldToTab('Root.LDAP', $field);
Please login to merge, or discard this patch.
src/Authenticators/LDAPLostPasswordHandler.php 1 patch
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     ];
38 38
 
39 39
     private static $dependencies = [
40
-        'service' => '%$' . LDAPService::class,
40
+        'service' => '%$'.LDAPService::class,
41 41
     ];
42 42
 
43 43
     /**
@@ -136,8 +136,7 @@  discard block
 block discarded – undo
136 136
     public function lostPasswordForm()
137 137
     {
138 138
         $loginFieldLabel = (Config::inst()->get(LDAPAuthenticator::class, 'allow_email_login') === 'yes') ?
139
-            _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAMEOREMAIL', 'Username or email') :
140
-            _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAME', 'Username');
139
+            _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAMEOREMAIL', 'Username or email') : _t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAME', 'Username');
141 140
         $loginField = TextField::create('Login', $loginFieldLabel);
142 141
 
143 142
         $action = FormAction::create(
@@ -158,13 +157,13 @@  discard block
 block discarded – undo
158 157
     {
159 158
         if (Config::inst()->get(LDAPAuthenticator::class, 'allow_email_login') === 'yes') {
160 159
             $message = _t(
161
-                __CLASS__ . '.NOTERESETPASSWORDUSERNAMEOREMAIL',
160
+                __CLASS__.'.NOTERESETPASSWORDUSERNAMEOREMAIL',
162 161
                 'Enter your username or your email address and we will send you a link with which '
163 162
                 . 'you can reset your password'
164 163
             );
165 164
         } else {
166 165
             $message = _t(
167
-                __CLASS__ . '.NOTERESETPASSWORDUSERNAME',
166
+                __CLASS__.'.NOTERESETPASSWORDUSERNAME',
168 167
                 'Enter your username and we will send you a link with which you can reset your password'
169 168
             );
170 169
         }
@@ -180,17 +179,17 @@  discard block
 block discarded – undo
180 179
         $username = Convert::raw2xml(
181 180
             rawurldecode($this->getRequest()->param('OtherID'))
182 181
         );
183
-        $username .= ($extension = $this->getRequest()->getExtension()) ? '.' . $extension : '';
182
+        $username .= ($extension = $this->getRequest()->getExtension()) ? '.'.$extension : '';
184 183
 
185 184
         return [
186 185
             'Title' => _t(
187
-                __CLASS__ . '.PASSWORDSENTHEADER',
186
+                __CLASS__.'.PASSWORDSENTHEADER',
188 187
                 "Password reset link sent to '{username}'",
189 188
                 ['username' => $username]
190 189
             ),
191 190
             'Content' =>
192 191
                 _t(
193
-                    __CLASS__ . '.PASSWORDSENTTEXT',
192
+                    __CLASS__.'.PASSWORDSENTTEXT',
194 193
                     "Thank you! A reset link has been sent to '{username}', provided an account exists.",
195 194
                     ['username' => $username]
196 195
                 ),
Please login to merge, or discard this patch.
src/Authenticators/LDAPAuthenticator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             if (Config::inst()->get(self::class, 'allow_email_login') != 'yes') {
91 91
                 $result->addError(
92 92
                     _t(
93
-                        __CLASS__ . '.PLEASEUSEUSERNAME',
93
+                        __CLASS__.'.PLEASEUSEUSERNAME',
94 94
                         'Please enter your username instead of your email to log in.'
95 95
                     )
96 96
                 );
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     }
109 109
                 }
110 110
 
111
-                $result->addError(_t(__CLASS__ . '.INVALIDCREDENTIALS', 'Invalid credentials'));
111
+                $result->addError(_t(__CLASS__.'.INVALIDCREDENTIALS', 'Invalid credentials'));
112 112
                 return null;
113 113
             }
114 114
         } else {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         if (!$data) {
142 142
             $result->addError(
143 143
                 _t(
144
-                    __CLASS__ . '.PROBLEMFINDINGDATA',
144
+                    __CLASS__.'.PROBLEMFINDINGDATA',
145 145
                     'There was a problem retrieving your user data'
146 146
                 )
147 147
             );
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $result = Authenticator::LOGIN | Authenticator::LOGOUT | Authenticator::CHECK_PASSWORD;
202 202
 
203
-        if ((bool)LDAPService::config()->get('allow_password_change')) {
204
-            $result |=  Authenticator::RESET_PASSWORD | Authenticator::CHANGE_PASSWORD;
203
+        if ((bool) LDAPService::config()->get('allow_password_change')) {
204
+            $result |= Authenticator::RESET_PASSWORD | Authenticator::CHANGE_PASSWORD;
205 205
         }
206 206
         return $result;
207 207
     }
Please login to merge, or discard this patch.
src/Services/LDAPService.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @var array
48 48
      */
49 49
     private static $dependencies = [
50
-        'gateway' => '%$' . LDAPGateway::class
50
+        'gateway' => '%$'.LDAPGateway::class
51 51
     ];
52 52
 
53 53
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function get_cache()
125 125
     {
126
-        return Injector::inst()->get(CacheInterface::class . '.ldap');
126
+        return Injector::inst()->get(CacheInterface::class.'.ldap');
127 127
     }
128 128
 
129 129
     /**
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
         // show better errors than the defaults for various status codes returned by LDAP
193 193
         if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_ACCOUNT_LOCKED_OUT') !== false) {
194 194
             $message = _t(
195
-                __CLASS__ . '.ACCOUNTLOCKEDOUT',
196
-                'Your account has been temporarily locked because of too many failed login attempts. ' .
195
+                __CLASS__.'.ACCOUNTLOCKEDOUT',
196
+                'Your account has been temporarily locked because of too many failed login attempts. '.
197 197
                 'Please try again later.'
198 198
             );
199 199
         }
200 200
         if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_LOGON_FAILURE') !== false) {
201 201
             $message = _t(
202
-                __CLASS__ . '.INVALIDCREDENTIALS',
202
+                __CLASS__.'.INVALIDCREDENTIALS',
203 203
                 'The provided details don\'t seem to be correct. Please try again.'
204 204
             );
205 205
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     public function getNodes($cached = true, $attributes = [])
223 223
     {
224 224
         $cache = self::get_cache();
225
-        $cacheKey = 'nodes' . md5(implode('', $attributes));
225
+        $cacheKey = 'nodes'.md5(implode('', $attributes));
226 226
         $results = $cache->has($cacheKey);
227 227
 
228 228
         if (!$results || !$cached) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $searchLocations = $this->config()->groups_search_locations ?: [null];
254 254
         $cache = self::get_cache();
255
-        $cacheKey = 'groups' . md5(implode('', array_merge($searchLocations, $attributes)));
255
+        $cacheKey = 'groups'.md5(implode('', array_merge($searchLocations, $attributes)));
256 256
         $results = $cache->has($cacheKey);
257 257
 
258 258
         if (!$results || !$cached) {
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
         }
521 521
 
522 522
         $member->IsExpired = ($data['useraccountcontrol'] & 2) == 2;
523
-        $member->LastSynced = (string)DBDatetime::now();
523
+        $member->LastSynced = (string) DBDatetime::now();
524 524
 
525 525
         foreach ($member->config()->ldap_field_mappings as $attribute => $field) {
526 526
             if (!isset($data[$attribute])) {
527 527
                 $this->getLogger()->notice(
528 528
                     sprintf(
529
-                        'Attribute %s configured in Member.ldap_field_mappings, ' .
529
+                        'Attribute %s configured in Member.ldap_field_mappings, '.
530 530
                                 'but no available attribute in AD data (GUID: %s, Member ID: %s)',
531 531
                         $attribute,
532 532
                         $data['objectguid'],
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                 ) {
545 545
                     $this->getLogger()->debug(
546 546
                         sprintf(
547
-                            'Member field %s configured for thumbnailphoto AD attribute, but it isn\'t a ' .
547
+                            'Member field %s configured for thumbnailphoto AD attribute, but it isn\'t a '.
548 548
                             'valid relation to an Image class',
549 549
                             $field
550 550
                         )
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
                 }
555 555
 
556 556
                 $filename = sprintf('thumbnailphoto-%s.jpg', $data['samaccountname']);
557
-                $path = ASSETS_DIR . '/' . $member->config()->ldap_thumbnail_path;
558
-                $absPath = BASE_PATH . '/' . $path;
557
+                $path = ASSETS_DIR.'/'.$member->config()->ldap_thumbnail_path;
558
+                $absPath = BASE_PATH.'/'.$path;
559 559
                 if (!file_exists($absPath)) {
560 560
                     Filesystem::makeFolder($absPath);
561 561
                 }
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
                 }
568 568
 
569 569
                 // The image data is provided in raw binary.
570
-                file_put_contents($absPath . '/' . $filename, $data[$attribute]);
570
+                file_put_contents($absPath.'/'.$filename, $data[$attribute]);
571 571
                 $record = new $imageClass();
572 572
                 $record->Name = $filename;
573
-                $record->Filename = $path . '/' . $filename;
573
+                $record->Filename = $path.'/'.$filename;
574 574
                 $record->write();
575 575
 
576
-                $relationField = $field . 'ID';
576
+                $relationField = $field.'ID';
577 577
                 $member->{$relationField} = $record->ID;
578 578
             } else {
579 579
                 $member->$field = $data[$attribute];
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             $group->Description = $data['description'];
720 720
         }
721 721
         $group->DN = $data['dn'];
722
-        $group->LastSynced = (string)DBDatetime::now();
722
+        $group->LastSynced = (string) DBDatetime::now();
723 723
         $group->write();
724 724
 
725 725
         // Mappings on this group are automatically maintained to contain just the group's DN.
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
                 ),
783 783
             ]);
784 784
         } catch (Exception $e) {
785
-            throw new ValidationException('LDAP synchronisation failure: ' . $e->getMessage());
785
+            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
786 786
         }
787 787
 
788 788
         $user = $this->getUserByUsername($member->Username);
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
                 'distinguishedname' => $dn
827 827
             ]);
828 828
         } catch (Exception $e) {
829
-            throw new ValidationException('LDAP group creation failure: ' . $e->getMessage());
829
+            throw new ValidationException('LDAP group creation failure: '.$e->getMessage());
830 830
         }
831 831
 
832 832
         $data = $this->getGroupByDN($dn);
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
             try {
992 992
                 $this->update($groupDn, ['member' => $members]);
993 993
             } catch (Exception $e) {
994
-                throw new ValidationException('LDAP group membership remove failure: ' . $e->getMessage());
994
+                throw new ValidationException('LDAP group membership remove failure: '.$e->getMessage());
995 995
             }
996 996
         }
997 997
     }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         try {
1018 1018
             $this->update($groupDn, ['member' => $members]);
1019 1019
         } catch (Exception $e) {
1020
-            throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage());
1020
+            throw new ValidationException('LDAP group membership add failure: '.$e->getMessage());
1021 1021
         }
1022 1022
     }
1023 1023
 
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
         try {
1101 1101
             $this->delete($data['distinguishedname']);
1102 1102
         } catch (Exception $e) {
1103
-            throw new ValidationException('LDAP delete user failed: ' . $e->getMessage());
1103
+            throw new ValidationException('LDAP delete user failed: '.$e->getMessage());
1104 1104
         }
1105 1105
     }
1106 1106
 
Please login to merge, or discard this patch.