Test Failed
Push — master ( a13d19...6b96b9 )
by Tomasz
03:24
created
web/lib/admin/domain/SilverbulletCertificate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -255,7 +255,7 @@
 block discarded – undo
255 255
             $userId = $silverbulletUser->getAttribute(self::ID);
256 256
             $query = sprintf("SELECT * FROM `%s` WHERE `%s`=? AND `%s`=? ORDER BY `%s`, `%s` DESC", self::TABLE, self::SILVERBULLETUSERID, $searchAttribute->key, self::REVOCATION_STATUS, self::EXPIRY);
257 257
             $result = $databaseHandle->exec($query, $userId->getType() . $searchAttribute->getType(), $userId->value, $searchAttribute->value);
258
-        } else if($silverbulletUser != null) {
258
+        } else if ($silverbulletUser != null) {
259 259
             $userId = $silverbulletUser->getAttribute(self::ID);
260 260
             $query = sprintf("SELECT * FROM `%s` WHERE `%s`=? ORDER BY `%s`, `%s` DESC", self::TABLE, self::SILVERBULLETUSERID, self::REVOCATION_STATUS, self::EXPIRY);
261 261
             $result = $databaseHandle->exec($query, $userId->getType(), $userId->value);
Please login to merge, or discard this patch.
web/lib/admin/http/SilverbulletController.php 2 patches
Braces   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
             if($commandToken == SaveUsersCommand::COMMAND){
38 38
                 if(isset($_POST[DeleteUserCommand::COMMAND])){
39 39
                     $commandToken = DeleteUserCommand::COMMAND;
40
-                }elseif(isset($_POST[AddInvitationCommand::COMMAND])){
40
+                } elseif(isset($_POST[AddInvitationCommand::COMMAND])){
41 41
                     $commandToken = AddInvitationCommand::COMMAND;
42
-                }elseif(isset($_POST[UpdateUserCommand::COMMAND])){
42
+                } elseif(isset($_POST[UpdateUserCommand::COMMAND])){
43 43
                     $commandToken = UpdateUserCommand::COMMAND;
44
-                }elseif (isset($_POST[RevokeCertificateCommand::COMMAND])){
44
+                } elseif (isset($_POST[RevokeCertificateCommand::COMMAND])){
45 45
                     $commandToken = RevokeCertificateCommand::COMMAND;
46
-                }elseif (isset($_POST[RevokeInvitationCommand::COMMAND])){
46
+                } elseif (isset($_POST[RevokeInvitationCommand::COMMAND])){
47 47
                     $commandToken = RevokeInvitationCommand::COMMAND;
48
-                }elseif (isset($_POST[SaveUsersCommand::COMMAND])){
48
+                } elseif (isset($_POST[SaveUsersCommand::COMMAND])){
49 49
                     $commandToken = SaveUsersCommand::COMMAND;
50 50
                 }
51 51
             }
@@ -63,31 +63,31 @@  discard block
 block discarded – undo
63 63
         if($this->context->isAgreementSigned()){
64 64
             if($commandToken == AddUserCommand::COMMAND){
65 65
                 return new AddUserCommand($commandToken, $this->context);
66
-            }elseif ($commandToken == AddUsersCommand::COMMAND){
66
+            } elseif ($commandToken == AddUsersCommand::COMMAND){
67 67
                 return new AddUsersCommand($commandToken, $this->context);
68
-            }elseif ($commandToken == DeleteUserCommand::COMMAND){
68
+            } elseif ($commandToken == DeleteUserCommand::COMMAND){
69 69
                 return new DeleteUserCommand($commandToken, $this->context);
70
-            }elseif ($commandToken == AddInvitationCommand::COMMAND){
70
+            } elseif ($commandToken == AddInvitationCommand::COMMAND){
71 71
                 return new AddInvitationCommand($commandToken, $this->context);
72
-            }elseif ($commandToken == UpdateUserCommand::COMMAND){
72
+            } elseif ($commandToken == UpdateUserCommand::COMMAND){
73 73
                 return new UpdateUserCommand($commandToken, $this->context);
74
-            }elseif ($commandToken == RevokeCertificateCommand::COMMAND){
74
+            } elseif ($commandToken == RevokeCertificateCommand::COMMAND){
75 75
                 return new RevokeCertificateCommand($commandToken, $this->context);
76
-            }elseif ($commandToken == RevokeInvitationCommand::COMMAND){
76
+            } elseif ($commandToken == RevokeInvitationCommand::COMMAND){
77 77
                 return new RevokeInvitationCommand($commandToken, $this->context);
78
-            }elseif ($commandToken == SaveUsersCommand::COMMAND){
78
+            } elseif ($commandToken == SaveUsersCommand::COMMAND){
79 79
                 return new SaveUsersCommand($commandToken, $this->context);
80
-            }elseif ($commandToken == SendTokenByEmail::COMMAND){
80
+            } elseif ($commandToken == SendTokenByEmail::COMMAND){
81 81
                 return new SendTokenByEmail($commandToken, $this->context);
82
-            }elseif ($commandToken == SendTokenBySms::COMMAND){
82
+            } elseif ($commandToken == SendTokenBySms::COMMAND){
83 83
                 return new SendTokenBySms($commandToken, $this->context);
84
-            }else{
84
+            } else{
85 85
                 return new DefaultCommand($commandToken);
86 86
             }
87
-        }else{
87
+        } else{
88 88
             if($commandToken == TermsOfUseCommand::COMMAND){
89 89
                 return new TermsOfUseCommand($commandToken, $this->context);
90
-            }else{
90
+            } else{
91 91
                 return new DefaultCommand($commandToken);
92 92
             }
93 93
         }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @author Zilvinas Vaira
7 7
  *
8 8
  */
9
-class SilverbulletController extends AbstractController{
9
+class SilverbulletController extends AbstractController {
10 10
     
11 11
     /**
12 12
      * 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * 
20 20
      * @param SilverbulletContext $context Requires silverbullet page context object
21 21
      */
22
-    public function __construct($context){
22
+    public function __construct($context) {
23 23
         $context->setController($this);
24 24
         $this->context = $context;
25 25
     }
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
      * {@inheritDoc}
30 30
      * @see \web\lib\admin\http\AbstractController::parseRequest()
31 31
      */
32
-    public function parseRequest(){
32
+    public function parseRequest() {
33 33
         $commandToken = '';
34
-        if(isset($_POST[SilverbulletController::COMMAND])){
34
+        if (isset($_POST[SilverbulletController::COMMAND])) {
35 35
             $commandToken = $_POST[SilverbulletController::COMMAND];
36
-            if($commandToken == SaveUsersCommand::COMMAND){
37
-                if(isset($_POST[DeleteUserCommand::COMMAND])){
36
+            if ($commandToken == SaveUsersCommand::COMMAND) {
37
+                if (isset($_POST[DeleteUserCommand::COMMAND])) {
38 38
                     $commandToken = DeleteUserCommand::COMMAND;
39
-                }elseif(isset($_POST[AddInvitationCommand::COMMAND])){
39
+                }elseif (isset($_POST[AddInvitationCommand::COMMAND])) {
40 40
                     $commandToken = AddInvitationCommand::COMMAND;
41
-                }elseif(isset($_POST[UpdateUserCommand::COMMAND])){
41
+                }elseif (isset($_POST[UpdateUserCommand::COMMAND])) {
42 42
                     $commandToken = UpdateUserCommand::COMMAND;
43
-                }elseif (isset($_POST[RevokeCertificateCommand::COMMAND])){
43
+                }elseif (isset($_POST[RevokeCertificateCommand::COMMAND])) {
44 44
                     $commandToken = RevokeCertificateCommand::COMMAND;
45
-                }elseif (isset($_POST[RevokeInvitationCommand::COMMAND])){
45
+                }elseif (isset($_POST[RevokeInvitationCommand::COMMAND])) {
46 46
                     $commandToken = RevokeInvitationCommand::COMMAND;
47
-                }elseif (isset($_POST[SaveUsersCommand::COMMAND])){
47
+                }elseif (isset($_POST[SaveUsersCommand::COMMAND])) {
48 48
                     $commandToken = SaveUsersCommand::COMMAND;
49 49
                 }
50 50
             }
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
      * {@inheritDoc}
59 59
      * @see \web\lib\admin\http\AbstractController::doCreateCommand()
60 60
      */
61
-    protected function doCreateCommand($commandToken){
62
-        if($this->context->isAgreementSigned()){
63
-            if($commandToken == AddUserCommand::COMMAND){
61
+    protected function doCreateCommand($commandToken) {
62
+        if ($this->context->isAgreementSigned()) {
63
+            if ($commandToken == AddUserCommand::COMMAND) {
64 64
                 return new AddUserCommand($commandToken, $this->context);
65
-            }elseif ($commandToken == AddUsersCommand::COMMAND){
65
+            }elseif ($commandToken == AddUsersCommand::COMMAND) {
66 66
                 return new AddUsersCommand($commandToken, $this->context);
67
-            }elseif ($commandToken == DeleteUserCommand::COMMAND){
67
+            }elseif ($commandToken == DeleteUserCommand::COMMAND) {
68 68
                 return new DeleteUserCommand($commandToken, $this->context);
69
-            }elseif ($commandToken == AddInvitationCommand::COMMAND){
69
+            }elseif ($commandToken == AddInvitationCommand::COMMAND) {
70 70
                 return new AddInvitationCommand($commandToken, $this->context);
71
-            }elseif ($commandToken == UpdateUserCommand::COMMAND){
71
+            }elseif ($commandToken == UpdateUserCommand::COMMAND) {
72 72
                 return new UpdateUserCommand($commandToken, $this->context);
73
-            }elseif ($commandToken == RevokeCertificateCommand::COMMAND){
73
+            }elseif ($commandToken == RevokeCertificateCommand::COMMAND) {
74 74
                 return new RevokeCertificateCommand($commandToken, $this->context);
75
-            }elseif ($commandToken == RevokeInvitationCommand::COMMAND){
75
+            }elseif ($commandToken == RevokeInvitationCommand::COMMAND) {
76 76
                 return new RevokeInvitationCommand($commandToken, $this->context);
77
-            }elseif ($commandToken == SaveUsersCommand::COMMAND){
77
+            }elseif ($commandToken == SaveUsersCommand::COMMAND) {
78 78
                 return new SaveUsersCommand($commandToken, $this->context);
79
-            }elseif ($commandToken == SendTokenByEmail::COMMAND){
79
+            }elseif ($commandToken == SendTokenByEmail::COMMAND) {
80 80
                 return new SendTokenByEmail($commandToken, $this->context);
81
-            }elseif ($commandToken == SendTokenBySms::COMMAND){
81
+            }elseif ($commandToken == SendTokenBySms::COMMAND) {
82 82
                 return new SendTokenBySms($commandToken, $this->context);
83
-            }else{
83
+            } else {
84 84
                 return new DefaultCommand($commandToken);
85 85
             }
86
-        }else{
87
-            if($commandToken == TermsOfUseCommand::COMMAND){
86
+        } else {
87
+            if ($commandToken == TermsOfUseCommand::COMMAND) {
88 88
                 return new TermsOfUseCommand($commandToken, $this->context);
89
-            }else{
89
+            } else {
90 90
                 return new DefaultCommand($commandToken);
91 91
             }
92 92
         }
Please login to merge, or discard this patch.
web/lib/admin/http/RevokeInvitationCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author Zilvinas Vaira
9 9
  *
10 10
  */
11
-class RevokeInvitationCommand extends AbstractInvokerCommand{
11
+class RevokeInvitationCommand extends AbstractInvokerCommand {
12 12
 
13 13
     const COMMAND = 'revokeinvitation';
14 14
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param string $commandToken
24 24
      * @param SilverbulletContext $context
25 25
      */
26
-    public function __construct($commandToken, $context){
26
+    public function __construct($commandToken, $context) {
27 27
         parent::__construct($commandToken, $context);
28 28
         $this->context = $context;
29 29
     }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * {@inheritDoc}
34 34
      * @see \web\lib\admin\http\AbstractCommand::execute()
35 35
      */
36
-    public function execute(){
36
+    public function execute() {
37 37
         $invitationId = $this->parseInt($_POST[self::COMMAND]);
38 38
         
39 39
         $invitation = SilverbulletInvitation::prepare($invitationId);
Please login to merge, or discard this patch.
web/lib/admin/view/UserCredentialsForm.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $acknowledgeLevel = $user->getAcknowledgeLevel();
159 159
         if($acknowledgeLevel == SilverbulletUser::LEVEL_YELLOW){
160 160
             $row->addAttribute('style', 'background-color:#F0EAC0;');
161
-        }elseif ($acknowledgeLevel == SilverbulletUser::LEVEL_RED){
161
+        } elseif ($acknowledgeLevel == SilverbulletUser::LEVEL_RED){
162 162
             $row->addAttribute('style', 'background-color:#F0C0C0;');
163 163
         }
164 164
         
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
                 $certificateBox->addAttribute('style', 'background-color:#F0C0C0;');
216 216
                 $buttonContainer->addAttribute('style', 'height:22px; margin-top:7px; text-align:center;');
217 217
                 $buttonContainer->addText(_("REVOKED"));
218
-            }elseif ($certificate->isExpired()){
218
+            } elseif ($certificate->isExpired()){
219 219
                 $certificateBox->addAttribute('style', 'background-color:lightgrey;');
220 220
                 $buttonContainer->addAttribute('style', 'height:22px; margin-top:7px; text-align:center;');
221 221
                 $buttonContainer->addText(_("EXPIRED"));
222
-            }else{
222
+            } else{
223 223
                 $buttonContainer->addAttribute('style', 'text-align:right;padding-top: 5px;');
224 224
                 $buttonContainer->addText(new Button(_('Revoke'), 'submit', RevokeCertificateCommand::COMMAND, $certificate->getIdentifier(), 'delete'));
225 225
             }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @author Zilvinas Vaira
27 27
  *
28 28
  */
29
-class UserCredentialsForm implements PageElementInterface{
29
+class UserCredentialsForm implements PageElementInterface {
30 30
     
31 31
     const EDITABLEBLOCK_CLASS = 'sb-editable-block';
32 32
     const TITLEROW_CLASS = 'sb-title-row';
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
         
119 119
         $this->acknowledgeDays = CONFIG_CONFASSISTANT['SILVERBULLET']['gracetime'] ?? SilverbulletUser::MAX_ACKNOWLEDGE;
120 120
         $this->acknowledgeText = $acknowledgeText;
121
-        if($isAcknowledgeEnabled){
121
+        if ($isAcknowledgeEnabled) {
122 122
             $div = new CompositeTag('div');
123 123
             $div->addAttribute('style', 'padding-bottom: 20px;');
124
-            $this->acknowledgeNotice = new Tag ('p');
124
+            $this->acknowledgeNotice = new Tag('p');
125 125
             $div->addTag($this->acknowledgeNotice);
126 126
             $checkbox = new UnaryTag('input');
127 127
             $checkbox->addAttribute('type', 'checkbox');
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             $label->addText('I have verified that all configured users are still eligible for eduroam');
133 133
             $div->addTag($label);
134 134
             $this->decorator->addHtmlElement($div);
135
-            $this->decorator->addHtmlElement(new Button(_('Save'),'submit', SaveUsersCommand::COMMAND, SaveUsersCommand::COMMAND));
135
+            $this->decorator->addHtmlElement(new Button(_('Save'), 'submit', SaveUsersCommand::COMMAND, SaveUsersCommand::COMMAND));
136 136
         }
137 137
         
138 138
         $this->addTitleRow();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     /**
142 142
      * 
143 143
      */
144
-    private function addTitleRow(){
144
+    private function addTitleRow() {
145 145
         $row = new Row(array(self::USER_COLUMN => _('User'), self::TOKEN_COLUMN => _('Token/Certificate details'), self::EXPIRY_COLUMN => _('User/Token Expiry'), self::ACTION_COLUMN => _('Actions')));
146 146
         $row->addAttribute('class', self::TITLEROW_CLASS);
147 147
         $this->table->addRow($row);
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
      * 
152 152
      * @param SilverbulletUser $user
153 153
      */
154
-    public function addUserRow($user){
154
+    public function addUserRow($user) {
155 155
         $row = new Row(array(self::USER_COLUMN => $user->getUsername(), self::EXPIRY_COLUMN => new DatePicker(SaveUsersCommand::PARAM_EXPIRY_MULTIPLE, $user->getExpiry())));
156 156
         $row->addAttribute('class', self::USERROW_CLASS);
157 157
         
158 158
         $acknowledgeLevel = $user->getAcknowledgeLevel();
159
-        if($acknowledgeLevel == SilverbulletUser::LEVEL_YELLOW){
159
+        if ($acknowledgeLevel == SilverbulletUser::LEVEL_YELLOW) {
160 160
             $row->addAttribute('style', 'background-color:#F0EAC0;');
161
-        }elseif ($acknowledgeLevel == SilverbulletUser::LEVEL_RED){
161
+        }elseif ($acknowledgeLevel == SilverbulletUser::LEVEL_RED) {
162 162
             $row->addAttribute('style', 'background-color:#F0C0C0;');
163 163
         }
164 164
         
165 165
         $acknowledgeDays = $user->getAcknowledgeDays();
166
-        if($acknowledgeDays < $this->acknowledgeDays){
166
+        if ($acknowledgeDays < $this->acknowledgeDays) {
167 167
             $this->acknowledgeDays = $acknowledgeDays;
168 168
         }
169 169
         
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $action = new CompositeTag('div');
184 184
         $action->addAttribute('class', 'sb-user-buttons');
185 185
             $deactivationButton = new Button(_('Deactivate User'), 'submit', DeleteUserCommand::COMMAND, $user->getIdentifier(), 'delete');
186
-            if($user->isDeactivated()){
186
+            if ($user->isDeactivated()) {
187 187
                 $deactivationButton->addAttribute('disabled', 'disabled'); 
188 188
             }
189 189
         $action->addTag($deactivationButton);
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
      * 
207 207
      * @param SilverbulletCertificate $certificate
208 208
      */
209
-    public function addCertificateRow($certificate){
210
-        if($certificate->isGenerated()){
209
+    public function addCertificateRow($certificate) {
210
+        if ($certificate->isGenerated()) {
211 211
 
212 212
             //Create certificate box
213 213
             $certificateBox = new CompositeTag('div');
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
 
222 222
             //Create button container div
223 223
             $buttonContainer = new Tag('div');
224
-            if($certificate->isRevoked()){
224
+            if ($certificate->isRevoked()) {
225 225
                 $certificateBox->addAttribute('style', 'background-color:#F0C0C0;');
226 226
                 $buttonContainer->addAttribute('style', 'height:22px; margin-top:7px; text-align:center;');
227 227
                 $buttonContainer->addText(_("REVOKED"));
228
-            }elseif ($certificate->isExpired()){
228
+            }elseif ($certificate->isExpired()) {
229 229
                 $certificateBox->addAttribute('style', 'background-color:lightgrey;');
230 230
                 $buttonContainer->addAttribute('style', 'height:22px; margin-top:7px; text-align:center;');
231 231
                 $buttonContainer->addText(_("EXPIRED"));
232
-            }else{
232
+            } else {
233 233
                 $buttonContainer->addAttribute('style', 'text-align:right;padding-top: 5px;');
234 234
                 $buttonContainer->addText(new Button(_('Revoke'), 'submit', RevokeCertificateCommand::COMMAND, $certificate->getIdentifier(), 'delete'));
235 235
             }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      *
244 244
      * @param SilverbulletInvitation $invitation
245 245
      */
246
-    public function addInvitationRow($invitation){
246
+    public function addInvitationRow($invitation) {
247 247
         $expiryColumn = _("Expiry Date: ") . $invitation->getExpiry();
248 248
         $expiryColumn .= "<br>";
249 249
         $expiryColumn .= _("Activations: ") . $invitation->getRemainingActivations();
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
         $row->addAttribute('class', self::CERTIFICATEROW_CLASS);
252 252
         $index = $this->table->size();
253 253
         $this->table->addRow($row);
254
-        if(!$invitation->isExpired() && !$invitation->isRevoked() && !$invitation->isAbsent()){
254
+        if (!$invitation->isExpired() && !$invitation->isRevoked() && !$invitation->isAbsent()) {
255 255
             $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Copy to Clipboard'), 'button', '', '', self::INVITATION_TOKEN_CLASS . '-copy'));
256
-            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Compose mail...'), 'button', '', '', self::INVITATION_TOKEN_CLASS. '-compose'));
257
-            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Send in SMS...'), 'button', '', '', self::INVITATION_TOKEN_CLASS. '-sms'));
258
-            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Generate QR code...'), 'button', '', '', self::INVITATION_TOKEN_CLASS. '-qrcode'));
256
+            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Compose mail...'), 'button', '', '', self::INVITATION_TOKEN_CLASS . '-compose'));
257
+            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Send in SMS...'), 'button', '', '', self::INVITATION_TOKEN_CLASS . '-sms'));
258
+            $this->table->addToCell($index, self::TOKEN_COLUMN, new Button(_('Generate QR code...'), 'button', '', '', self::INVITATION_TOKEN_CLASS . '-qrcode'));
259 259
         }
260
-        if(!$invitation->isRevoked()){
260
+        if (!$invitation->isRevoked()) {
261 261
             $this->table->addToCell($index, self::ACTION_COLUMN, new Button(_('Revoke'), 'submit', RevokeInvitationCommand::COMMAND, $invitation->getIdentifier(), 'delete'));
262 262
         }
263 263
     }
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
      * @see \web\lib\admin\view\PageElementInterface::render()
269 269
      */
270 270
     public function render() {
271
-        if($this->acknowledgeNotice!=null){
271
+        if ($this->acknowledgeNotice != null) {
272 272
             $this->acknowledgeNotice->addText(sprintf($this->acknowledgeText, $this->acknowledgeDays));
273 273
         }
274 274
         ?>
275
-        <div class="<?php echo self::EDITABLEBLOCK_CLASS;?>">
275
+        <div class="<?php echo self::EDITABLEBLOCK_CLASS; ?>">
276 276
             <?php $this->decorator->render(); ?>
277 277
         </div>
278 278
         <?php
Please login to merge, or discard this patch.
web/lib/admin/domain/SilverbulletInvitation.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
     
54 54
     /**
55 55
      * 
56
-     * @param $silverbulletUser SilverbulletUser
56
+     * @param SilverbulletUser|null $silverbulletUser SilverbulletUser
57 57
      */
58 58
     public function __construct($silverbulletUser) {
59 59
         parent::__construct(self::TABLE, self::TYPE_INST);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * 
98 98
      * @param int $quantity
99 99
      */
100
-    public function setQuantity($quantity){
100
+    public function setQuantity($quantity) {
101 101
         $this->set(self::QUANTITY, $quantity);
102 102
     }
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return string
107 107
      */
108
-    public function getRemainingActivations(){
108
+    public function getRemainingActivations() {
109 109
         return sprintf(_("%s of %s"), count($this->certificates), $this->get(self::QUANTITY));
110 110
     }
111 111
     
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
      * 
114 114
      * @return boolean
115 115
      */
116
-    public function isRevoked(){
116
+    public function isRevoked() {
117 117
         $quantity = $this->get(self::QUANTITY);
118 118
         return $quantity <= 0;
119 119
     }
120 120
     
121
-    public function isAbsent(){
121
+    public function isAbsent() {
122 122
         $quantity = $this->get(self::QUANTITY);
123 123
         return count($this->certificates) >= $quantity;
124 124
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             }
151 151
             $link .= $_SERVER['SERVER_NAME'];
152 152
             $relPath = dirname(dirname($_SERVER['SCRIPT_NAME']));
153
-            if ($relPath[strlen($relPath) -1] == '/') {
153
+            if ($relPath[strlen($relPath) - 1] == '/') {
154 154
                 $relPath = substr($relPath, 0, strlen($relPath) - 1);
155 155
             }
156 156
             $link = $link . $relPath;
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
             $link = $host;
159 159
         }
160 160
         
161
-        if ($this->isRevoked()){
161
+        if ($this->isRevoked()) {
162 162
             $link = _('This token has been revoked!');
163
-        }else if($this->isAbsent()){
163
+        } else if ($this->isAbsent()) {
164 164
             $link = _('All available activations were used!');
165
-        }else if ($this->isExpired()) {
165
+        } else if ($this->isExpired()) {
166 166
             $link = _('User did not consume the token and it expired!');
167 167
         } else {
168 168
             $link .= '/accountstatus/accountstatus.php?token=' . $this->get(self::TOKEN);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * 
223 223
      * @return \web\lib\admin\domain\SilverbulletCertificate[]
224 224
      */
225
-    public function getCertificates(){
225
+    public function getCertificates() {
226 226
         return $this->certificates;
227 227
     }
228 228
     
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * {@inheritDoc}
232 232
      * @see \web\lib\admin\domain\PersistentEntity::load()
233 233
      */
234
-    public function load($searchAttribute = null){
234
+    public function load($searchAttribute = null) {
235 235
         $state = parent::load($searchAttribute);
236 236
         $this->certificates = SilverbulletCertificate::getList(null, new Attribute(SilverbulletCertificate::SILVERBULLETINVITATIONID, $this->getIdentifier(), Attribute::TYPE_INTEGER));
237 237
         return $state;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $userId = $silverbulletUser->getAttribute(self::ID);
261 261
             $query = sprintf("SELECT * FROM `%s` WHERE `%s`=? AND `%s`=? ORDER BY `%s` DESC", self::TABLE, self::SILVERBULLETUSERID, $searchAttribute->key, self::EXPIRY);
262 262
             $result = $databaseHandle->exec($query, $userId->getType() . $searchAttribute->getType(), $userId->value, $searchAttribute->value);
263
-        } else if($silverbulletUser != null) {
263
+        } else if ($silverbulletUser != null) {
264 264
             $userId = $silverbulletUser->getAttribute(self::ID);
265 265
             $query = sprintf("SELECT * FROM `%s` WHERE `%s`=? ORDER BY `%s` DESC", self::TABLE, self::SILVERBULLETUSERID, self::EXPIRY);
266 266
             $result = $databaseHandle->exec($query, $userId->getType(), $userId->value);
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,9 +160,9 @@
 block discarded – undo
160 160
         
161 161
         if ($this->isRevoked()){
162 162
             $link = _('This token has been revoked!');
163
-        }else if($this->isAbsent()){
163
+        } else if($this->isAbsent()){
164 164
             $link = _('All available activations were used!');
165
-        }else if ($this->isExpired()) {
165
+        } else if ($this->isExpired()) {
166 166
             $link = _('User did not consume the token and it expired!');
167 167
         } else {
168 168
             $link .= '/accountstatus/accountstatus.php?token=' . $this->get(self::TOKEN);
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/domain/SilverBulletUserTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use web\lib\admin\domain\Attribute;
6 6
 use web\lib\admin\domain\SilverbulletInvitation;
7 7
 
8
-class SilverbulletUserTest extends PHPUnit_Framework_TestCase{
8
+class SilverbulletUserTest extends PHPUnit_Framework_TestCase {
9 9
     
10 10
     private $username = 'testusername';
11 11
     
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $this->newUser->setExpiry('now');
27 27
     }
28 28
     
29
-    public function testNewUser(){
29
+    public function testNewUser() {
30 30
         $this->newUser->save();
31 31
         $this->assertNotEmpty($this->newUser->getIdentifier());
32 32
         
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $list = SilverbulletUser::getList($this->profileId);
51 51
         $found = false;
52 52
         foreach ($list as $user) {
53
-            if($user->getIdentifier() == $this->newUser->getIdentifier()){
53
+            if ($user->getIdentifier() == $this->newUser->getIdentifier()) {
54 54
                 $found = true;
55 55
                 break;
56 56
             }
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
         $this->assertTrue($result);
62 62
     }
63 63
     
64
-    public function testInactiveUser(){
64
+    public function testInactiveUser() {
65 65
         $this->newUser->save();
66 66
         $this->assertFalse($this->newUser->hasCertificates());
67 67
     }
68 68
     
69
-    public function testActiveUser(){
69
+    public function testActiveUser() {
70 70
         $this->newUser->save();
71 71
         $invitation = new SilverbulletInvitation($this->newUser);
72 72
         $invitation->setQuantity(2);
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
         $this->assertEquals(2, count($certificates));
84 84
     }
85 85
     
86
-    public function testSetDeactivated(){
86
+    public function testSetDeactivated() {
87 87
         $serial = '29837498273948';
88 88
         $cn = 'testCommonName';
89
-        $expiry = date('Y-m-d',strtotime("tomorrow"));
89
+        $expiry = date('Y-m-d', strtotime("tomorrow"));
90 90
         
91 91
         //Testing new user deactivation
92 92
         $this->newUser->save();
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $this->assertEquals(SilverbulletUser::ACTIVE, $existingUser->get(SilverbulletUser::DEACTIVATION_STATUS));
131 131
     }
132 132
     
133
-    protected function tearDown(){
133
+    protected function tearDown() {
134 134
         $this->newUser->delete();
135 135
         $this->profile->delete();
136 136
     }
Please login to merge, or discard this patch.
tests/unit/web/lib/admin/domain/SilverbulletControllerTest.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 use web\lib\admin\http\SilverbulletContext;
16 16
 use web\lib\admin\domain\SilverbulletInvitation;
17 17
 
18
-if ( !isset( $_SESSION ) ) $_SESSION = array();
18
+if (!isset($_SESSION)) $_SESSION = array();
19 19
 
20
-class MockInstitutionPageBuilder extends InstitutionPageBuilder{
20
+class MockInstitutionPageBuilder extends InstitutionPageBuilder {
21 21
     
22 22
     private $profile;
23 23
     
24
-    public function __construct($profile){
24
+    public function __construct($profile) {
25 25
         parent::__construct(new DefaultHtmlPage("Test Page"));
26 26
         $this->profile = $profile; 
27 27
     }
28 28
     
29
-    public function getProfile(){
29
+    public function getProfile() {
30 30
         return $this->profile;
31 31
     }
32 32
     
33 33
 }
34 34
 
35
-class SilverbulletControllerTest extends PHPUnit_Framework_TestCase{
35
+class SilverbulletControllerTest extends PHPUnit_Framework_TestCase {
36 36
     
37 37
     private $username = 'testusername';
38 38
     
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     
45 45
     private $factory;
46 46
     
47
-    protected function setUp(){
47
+    protected function setUp() {
48 48
         $this->databaseHandle = \core\DBConnection::handle('INST');
49 49
         
50 50
         $this->profile = new MockProfileSilverbullet($this->databaseHandle);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $usersAfter = count(SilverbulletUser::getList($this->profile->identifier));
65 65
         $this->assertFalse($usersAfter > $usersBefore);
66 66
         
67
-        $_POST[AddUserCommand::PARAM_EXPIRY] = date('Y-m-d',strtotime("tomorrow"));
67
+        $_POST[AddUserCommand::PARAM_EXPIRY] = date('Y-m-d', strtotime("tomorrow"));
68 68
         $this->factory->parseRequest();
69 69
 
70 70
         $usersAfter = count(SilverbulletUser::getList($this->profile->identifier));
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
         
73 73
     }
74 74
 
75
-    private function countActiveUsers($users){
75
+    private function countActiveUsers($users) {
76 76
         $count = 0;
77 77
         foreach ($users as $user) {
78
-            if(!$user->isDeactivated()){
78
+            if (!$user->isDeactivated()) {
79 79
                 $count++;
80 80
             }
81 81
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     public function testRevokeGeneratedCertificate() {
148 148
         $serial = '29837498273948';
149 149
         $cn = 'testCommonName';
150
-        $expiry = date('Y-m-d',strtotime("tomorrow"));
150
+        $expiry = date('Y-m-d', strtotime("tomorrow"));
151 151
         
152 152
         $this->user->save();
153 153
 
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
         
173 173
     }
174 174
     
175
-    protected function tearDown(){
175
+    protected function tearDown() {
176 176
         $this->user->delete();
177
-        $this->databaseHandle->exec("DELETE FROM `".SilverbulletUser::TABLE."` WHERE `".SilverbulletUser::USERNAME."`='".$this->username."'");
177
+        $this->databaseHandle->exec("DELETE FROM `" . SilverbulletUser::TABLE . "` WHERE `" . SilverbulletUser::USERNAME . "`='" . $this->username . "'");
178 178
         $this->profile->delete();
179 179
     }
180 180
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@
 block discarded – undo
15 15
 use web\lib\admin\http\SilverbulletContext;
16 16
 use web\lib\admin\domain\SilverbulletInvitation;
17 17
 
18
-if ( !isset( $_SESSION ) ) $_SESSION = array();
18
+if ( !isset( $_SESSION ) ) {
19
+    $_SESSION = array();
20
+}
19 21
 
20 22
 class MockInstitutionPageBuilder extends InstitutionPageBuilder{
21 23
     
Please login to merge, or discard this patch.
web/lib/admin/http/AddInvitationCommand.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author Zilvinas Vaira
9 9
  *
10 10
  */
11
-class AddInvitationCommand extends AbstractInvokerCommand{
11
+class AddInvitationCommand extends AbstractInvokerCommand {
12 12
 
13 13
     const COMMAND = 'newinvitation';
14 14
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param string $commandToken
24 24
      * @param SilverbulletContext $context
25 25
      */
26
-    public function __construct($commandToken, $context){
26
+    public function __construct($commandToken, $context) {
27 27
         parent::__construct($commandToken, $context);
28 28
         $this->context = $context;
29 29
     }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * {@inheritDoc}
34 34
      * @see \web\lib\admin\http\AbstractCommand::execute()
35 35
      */
36
-    public function execute(){
36
+    public function execute() {
37 37
         $userIndex = $this->parseInt($_POST[self::COMMAND]);
38 38
         $userIds = $this->parseArray($_POST[SaveUsersCommand::PARAM_ID]);
39 39
         $invitationsQuantities = $this->parseArray($_POST[SaveUsersCommand::PARAM_QUANTITY]);
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
         $user = SilverbulletUser::prepare($userId);
44 44
         $user->load();
45 45
         
46
-        if($user->isExpired()){
46
+        if ($user->isExpired()) {
47 47
             $this->storeErrorMessage(sprintf(_("User '%s' has expired. In order to generate credentials please extend the expiry date!"), $user->getUsername()));
48
-        }else{
48
+        } else {
49 49
             $this->context->createInvitation($user, $this, (int) $invitationsQuantity);
50
-            if(!is_numeric($invitationsQuantity)){
50
+            if (!is_numeric($invitationsQuantity)) {
51 51
                 $this->storeErrorMessage(sprintf(_("Invitations quantity '%' provided for user '%s' was not numeric. Assumed quantity as '1' !"), $invitationsQuantity, $user->getUsername()));
52 52
             }
53
-            if($user->isDeactivated()){
53
+            if ($user->isDeactivated()) {
54 54
                 $user->setDeactivated(false, $this->context->getProfile());
55 55
                 $user->save();
56 56
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
         
46 46
         if($user->isExpired()){
47 47
             $this->storeErrorMessage(sprintf(_("User '%s' has expired. In order to generate credentials please extend the expiry date!"), $user->getUsername()));
48
-        }else{
48
+        } else{
49 49
             $this->context->createInvitation($user, $this, (int) $invitationsQuantity);
50 50
             if(!is_numeric($invitationsQuantity)){
51 51
                 $this->storeErrorMessage(sprintf(_("Invitations quantity '%' provided for user '%s' was not numeric. Assumed quantity as '1' !"), $invitationsQuantity, $user->getUsername()));
Please login to merge, or discard this patch.
web/accountstatus/accountstatus.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $cleanToken = FALSE;
23 23
 $operatingSystem = FALSE;
24 24
 $tokenStatus = ["status" => \core\ProfileSilverbullet::SB_TOKENSTATUS_INVALID,
25
-    "cert_status" => [],];
25
+    "cert_status" => [], ];
26 26
 $profile = NULL;
27 27
 $idp = NULL;
28 28
 $fed = NULL;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         // it can be VALID (exists and not redeemed, EXPIRED, REDEEMED or INVALID (non existent)
39 39
         $tokenStatus = \core\ProfileSilverbullet::tokenStatus($cleanToken);
40 40
     }
41
-} elseif (isset($_SERVER['SSL_CLIENT_SAN_Email']) || isset($_SERVER['SSL_CLIENT_SAN_Email_0']) ) {
41
+} elseif (isset($_SERVER['SSL_CLIENT_SAN_Email']) || isset($_SERVER['SSL_CLIENT_SAN_Email_0'])) {
42 42
     // maybe the user authenticated with his client cert? Then pick any of his
43 43
     // tokens to go on
44 44
     $certname = $_SERVER['SSL_CLIENT_SAN_Email'] ?? $_SERVER['SSL_CLIENT_SAN_Email_0'];
Please login to merge, or discard this patch.