Passed
Branch master (3014eb)
by Stefan
07:10
created
web/user/API.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         break;
99 99
     case 'listIdentityProviders':
100 100
         if ($federation === FALSE) {
101
-           $federation = $id ? $validator->existingFederation($id)->tld : FALSE;
101
+            $federation = $id ? $validator->existingFederation($id)->tld : FALSE;
102 102
         }
103 103
         if ($federation === FALSE) { // federation is a mandatory parameter!
104 104
             exit;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         break;
111 111
     case 'listProfiles': // needs $idp set - abort if not
112 112
         if ($idp === FALSE) {
113
-           $idp = $id ? $validator->existingIdP($id)->identifier : FALSE;
113
+            $idp = $id ? $validator->existingIdP($id)->identifier : FALSE;
114 114
         }
115 115
         if ($idp === FALSE) {
116 116
             exit;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         break;
120 120
     case 'listDevices':
121 121
         if ($profile === FALSE) {
122
-           $profile = $id ? $validator->existingProfile($id)->identifier : FALSE;
122
+            $profile = $id ? $validator->existingProfile($id)->identifier : FALSE;
123 123
         }
124 124
         if ($profile === FALSE) {
125 125
             exit;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         break;
147 147
     case 'profileAttributes': // needs $profile set
148 148
         if ($profile === FALSE) {
149
-           $profile = $id ? $validator->existingProfile($id)->identifier : FALSE;
149
+            $profile = $id ? $validator->existingProfile($id)->identifier : FALSE;
150 150
         }
151 151
         if ($profile === FALSE) {
152 152
             exit;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         break;
156 156
     case 'sendLogo': // needs $idp and $disco set
157 157
         if ($idp === FALSE) {
158
-           $idp = $id ? $validator->existingIdP($id)->identifier : FALSE;
158
+            $idp = $id ? $validator->existingIdP($id)->identifier : FALSE;
159 159
         }
160 160
         if ($idp === FALSE) {
161 161
             exit;
Please login to merge, or discard this patch.
web/admin/inc/sendinvite.inc.php 2 patches
Switch Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -100,88 +100,88 @@
 block discarded – undo
100 100
 }
101 101
 
102 102
 switch ($operationMode) {
103
-    case OPERATION_MODE_EDIT:
104
-        $idp = $validator->existingIdP($_GET['inst_id']);
105
-        // editing IdPs is done from within the popup. When we're done, send the 
106
-        // user back to the popup (append the result of the operation later)
107
-        $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&";
108
-        $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
109
-        // is the user primary admin of this IdP?
110
-        $is_owner = $idp->isPrimaryOwner($_SESSION['user']);
111
-        // check if he is (also) federation admin for the federation this IdP is in. His invitations have more blessing then.
112
-        $fedadmin = $userObject->isFederationAdmin($idp->federation);
113
-        // check if he is either one, if not, complain
114
-        if (!$is_owner && !$fedadmin) {
115
-            echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>";
116
-            exit(1);
117
-        }
103
+        case OPERATION_MODE_EDIT:
104
+            $idp = $validator->existingIdP($_GET['inst_id']);
105
+            // editing IdPs is done from within the popup. When we're done, send the 
106
+            // user back to the popup (append the result of the operation later)
107
+            $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&";
108
+            $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
109
+            // is the user primary admin of this IdP?
110
+            $is_owner = $idp->isPrimaryOwner($_SESSION['user']);
111
+            // check if he is (also) federation admin for the federation this IdP is in. His invitations have more blessing then.
112
+            $fedadmin = $userObject->isFederationAdmin($idp->federation);
113
+            // check if he is either one, if not, complain
114
+            if (!$is_owner && !$fedadmin) {
115
+                echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>";
116
+                exit(1);
117
+            }
118 118
 
119
-        $prettyprintname = $idp->name;
120
-        $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp);
121
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress));
122
-        $introtext = "CO-ADMIN";
123
-        $participant_type = $idp->type;
124
-        break;
125
-    case OPERATION_MODE_NEWUNLINKED:
126
-        $redirect_destination = "../overview_federation.php?";
127
-        $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
128
-        // run an input check and conversion of the raw inputs... just in case
129
-        $newinstname = $validator->string($_POST['name']);
130
-        $newcountry = $validator->string($_POST['country']);
131
-        $participant_type = $validator->partType($_POST['participant_type']);
132
-        $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry);
133
-        if ($new_idp_authorized_fedadmin !== TRUE) {
134
-            throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
135
-        }
136
-        $federation = $validator->existingFederation($newcountry);
137
-        $prettyprintname = $newinstname;
138
-        $introtext = "NEW-FED";
139
-        // send the user back to his federation overview page, append the result of the operation later
140
-        // do the token creation magic
141
-        $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type);
142
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE  - Token created for $participant_type " . implode(",", $mailaddress));
143
-        break;
144
-    case OPERATION_MODE_NEWFROMDB:
145
-        $redirect_destination = "../overview_federation.php?";
146
-        $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
147
-        // a real external DB entry was submitted and all the required parameters are there
148
-        $newexternalid = $validator->string($_POST['externals']);
149
-        $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid);
150
-        $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']);
151
-        if ($new_idp_authorized_fedadmin !== TRUE) {
152
-            throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
153
-        }
154
-        $federation = $validator->existingFederation($extinfo['country']);
155
-        $newcountry = $extinfo['country'];
156
-        // see if the inst name is defined in the currently set language; if not, pick its English name; if N/A, pick the last in the list
157
-        $prettyprintname = "";
158
-        foreach ($extinfo['names'] as $lang => $name) {
159
-            if ($lang == $languageInstance->getLang()) {
160
-                $prettyprintname = $name;
119
+            $prettyprintname = $idp->name;
120
+            $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp);
121
+            $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress));
122
+            $introtext = "CO-ADMIN";
123
+            $participant_type = $idp->type;
124
+            break;
125
+        case OPERATION_MODE_NEWUNLINKED:
126
+            $redirect_destination = "../overview_federation.php?";
127
+            $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
128
+            // run an input check and conversion of the raw inputs... just in case
129
+            $newinstname = $validator->string($_POST['name']);
130
+            $newcountry = $validator->string($_POST['country']);
131
+            $participant_type = $validator->partType($_POST['participant_type']);
132
+            $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry);
133
+            if ($new_idp_authorized_fedadmin !== TRUE) {
134
+                throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
161 135
             }
162
-        }
163
-        if ($prettyprintname == "" && isset($extinfo['names']['en'])) {
164
-            $prettyprintname = $extinfo['names']['en'];
165
-        }
166
-        if ($prettyprintname == "") {
167
-            foreach ($extinfo['names'] as $name) {
168
-                $prettyprintname = $name;
136
+            $federation = $validator->existingFederation($newcountry);
137
+            $prettyprintname = $newinstname;
138
+            $introtext = "NEW-FED";
139
+            // send the user back to his federation overview page, append the result of the operation later
140
+            // do the token creation magic
141
+            $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type);
142
+            $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE  - Token created for $participant_type " . implode(",", $mailaddress));
143
+            break;
144
+        case OPERATION_MODE_NEWFROMDB:
145
+            $redirect_destination = "../overview_federation.php?";
146
+            $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
147
+            // a real external DB entry was submitted and all the required parameters are there
148
+            $newexternalid = $validator->string($_POST['externals']);
149
+            $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid);
150
+            $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']);
151
+            if ($new_idp_authorized_fedadmin !== TRUE) {
152
+                throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
169 153
             }
170
-        }
171
-        // TODO when we have access to the data
172
-        $participant_type = "IdPSP";
173
-        // fill the rest of the text
174
-        $introtext = "EXISTING-FED";
175
-        // do the token creation magic
176
-        $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid);
177
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for " . implode(",", $mailaddress));
178
-        break;
179
-    default: // includes OPERATION_MODE_INVALID
180
-        $wrongcontent = print_r($_POST, TRUE);
181
-        echo "<pre>Wrong parameters in POST:
154
+            $federation = $validator->existingFederation($extinfo['country']);
155
+            $newcountry = $extinfo['country'];
156
+            // see if the inst name is defined in the currently set language; if not, pick its English name; if N/A, pick the last in the list
157
+            $prettyprintname = "";
158
+            foreach ($extinfo['names'] as $lang => $name) {
159
+                if ($lang == $languageInstance->getLang()) {
160
+                    $prettyprintname = $name;
161
+                }
162
+            }
163
+            if ($prettyprintname == "" && isset($extinfo['names']['en'])) {
164
+                $prettyprintname = $extinfo['names']['en'];
165
+            }
166
+            if ($prettyprintname == "") {
167
+                foreach ($extinfo['names'] as $name) {
168
+                    $prettyprintname = $name;
169
+                }
170
+            }
171
+            // TODO when we have access to the data
172
+            $participant_type = "IdPSP";
173
+            // fill the rest of the text
174
+            $introtext = "EXISTING-FED";
175
+            // do the token creation magic
176
+            $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid);
177
+            $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for " . implode(",", $mailaddress));
178
+            break;
179
+        default: // includes OPERATION_MODE_INVALID
180
+            $wrongcontent = print_r($_POST, TRUE);
181
+            echo "<pre>Wrong parameters in POST:
182 182
 " . htmlspecialchars($wrongcontent) . "
183 183
 </pre>";
184
-        exit(1);
184
+            exit(1);
185 185
 }
186 186
 
187 187
 // send, and invalidate the token immediately if the mail could not be sent!
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *          <base_url>/copyright.php after deploying the software
21 21
  */
22 22
 
23
-require_once dirname(dirname(dirname(__DIR__))) . "/config/_config.php";
23
+require_once dirname(dirname(dirname(__DIR__)))."/config/_config.php";
24 24
 
25 25
 $auth = new \web\lib\admin\Authentication();
26 26
 $auth->authenticate();
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $addressSegments = explode(",", $newmailaddress);
48 48
     $confirmedMails = [];
49 49
     if ($addressSegments === FALSE) {
50
-        header("Location: $redirect_destination" . "invitation=INVALIDSYNTAX");
50
+        header("Location: $redirect_destination"."invitation=INVALIDSYNTAX");
51 51
         exit;
52 52
     }
53 53
     foreach ($addressSegments as $oneAddressCandidate) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         }
58 58
     }
59 59
     if (count($confirmedMails) == 0) {
60
-        header("Location: $redirect_destination" . "invitation=INVALIDSYNTAX");
60
+        header("Location: $redirect_destination"."invitation=INVALIDSYNTAX");
61 61
         exit;
62 62
     } else {
63 63
         return $confirmedMails;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $idp = $validator->existingIdP($_GET['inst_id']);
105 105
         // editing IdPs is done from within the popup. When we're done, send the 
106 106
         // user back to the popup (append the result of the operation later)
107
-        $redirect_destination = "manageAdmins.inc.php?inst_id=" . $idp->identifier . "&";
107
+        $redirect_destination = "manageAdmins.inc.php?inst_id=".$idp->identifier."&";
108 108
         $mailaddress = abortOnBogusMail($newmailaddress, $redirect_destination);
109 109
         // is the user primary admin of this IdP?
110 110
         $is_owner = $idp->isPrimaryOwner($_SESSION['user']);
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
         $fedadmin = $userObject->isFederationAdmin($idp->federation);
113 113
         // check if he is either one, if not, complain
114 114
         if (!$is_owner && !$fedadmin) {
115
-            echo "<p>" . sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst) . "</p>";
115
+            echo "<p>".sprintf(_("Something's wrong... you are a %s admin, but not for the %s the requested %s belongs to!"), $uiElements->nomenclatureFed, $uiElements->nomenclatureFed, $uiElements->nomenclatureInst)."</p>";
116 116
             exit(1);
117 117
         }
118 118
 
119 119
         $prettyprintname = $idp->name;
120 120
         $newtokens = $mgmt->createTokens($fedadmin, $mailaddress, $idp);
121
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP " . $idp->identifier . " - Token created for " . implode(",", $mailaddress));
121
+        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP ".$idp->identifier." - Token created for ".implode(",", $mailaddress));
122 122
         $introtext = "CO-ADMIN";
123 123
         $participant_type = $idp->type;
124 124
         break;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $participant_type = $validator->partType($_POST['participant_type']);
132 132
         $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($newcountry);
133 133
         if ($new_idp_authorized_fedadmin !== TRUE) {
134
-            throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
134
+            throw new Exception("Something's wrong... you want to create a new ".$uiElements->nomenclatureInst.", but are not a ".$uiElements->nomenclatureFed." admin for the ".$uiElements->nomenclatureFed." it should be in!");
135 135
         }
136 136
         $federation = $validator->existingFederation($newcountry);
137 137
         $prettyprintname = $newinstname;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         // send the user back to his federation overview page, append the result of the operation later
140 140
         // do the token creation magic
141 141
         $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $newinstname, 0, $newcountry, $participant_type);
142
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE  - Token created for $participant_type " . implode(",", $mailaddress));
142
+        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "ORG FUTURE  - Token created for $participant_type ".implode(",", $mailaddress));
143 143
         break;
144 144
     case OPERATION_MODE_NEWFROMDB:
145 145
         $redirect_destination = "../overview_federation.php?";
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $extinfo = $catInstance->getExternalDBEntityDetails($newexternalid);
150 150
         $new_idp_authorized_fedadmin = $userObject->isFederationAdmin($extinfo['country']);
151 151
         if ($new_idp_authorized_fedadmin !== TRUE) {
152
-            throw new Exception("Something's wrong... you want to create a new " . $uiElements->nomenclatureInst . ", but are not a " . $uiElements->nomenclatureFed . " admin for the " . $uiElements->nomenclatureFed . " it should be in!");
152
+            throw new Exception("Something's wrong... you want to create a new ".$uiElements->nomenclatureInst.", but are not a ".$uiElements->nomenclatureFed." admin for the ".$uiElements->nomenclatureFed." it should be in!");
153 153
         }
154 154
         $federation = $validator->existingFederation($extinfo['country']);
155 155
         $newcountry = $extinfo['country'];
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
         $introtext = "EXISTING-FED";
175 175
         // do the token creation magic
176 176
         $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid);
177
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for " . implode(",", $mailaddress));
177
+        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for ".implode(",", $mailaddress));
178 178
         break;
179 179
     default: // includes OPERATION_MODE_INVALID
180 180
         $wrongcontent = print_r($_POST, TRUE);
181 181
         echo "<pre>Wrong parameters in POST:
182
-" . htmlspecialchars($wrongcontent) . "
182
+" . htmlspecialchars($wrongcontent)."
183 183
 </pre>";
184 184
         exit(1);
185 185
 }
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 }
205 205
 
206 206
 if (count($status) == 0) {
207
-    header("Location: $redirect_destination" . "invitation=FAILURE");
207
+    header("Location: $redirect_destination"."invitation=FAILURE");
208 208
     exit;
209 209
 }
210 210
 $finalDestParams = "invitation=SUCCESS";
211 211
 if (count($status) < count($totalSegments)) { // only a subset of mails was sent, update status
212 212
     $finalDestParams = "invitation=PARTIAL";
213 213
 }
214
-$finalDestParams .= "&successcount=" . count($status);
214
+$finalDestParams .= "&successcount=".count($status);
215 215
 if ($allEncrypted === TRUE) {
216 216
     $finalDestParams .= "&transportsecurity=ENCRYPTED";
217 217
 } elseif ($allClear === TRUE) {
@@ -220,4 +220,4 @@  discard block
 block discarded – undo
220 220
     $finalDestParams .= "&transportsecurity=PARTIAL";
221 221
 }
222 222
 
223
-header("Location: $redirect_destination" . $finalDestParams);
223
+header("Location: $redirect_destination".$finalDestParams);
Please login to merge, or discard this patch.
web/admin/API.php 1 patch
Switch Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -115,217 +115,217 @@  discard block
 block discarded – undo
115 115
 }
116 116
 
117 117
 switch ($inputDecoded['ACTION']) {
118
-    case web\lib\admin\API::ACTION_NEWINST:
119
-        // create the inst, no admin, no attributes
120
-        $typeRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_INSTTYPE);
121
-        if ($typeRaw === FALSE) {
122
-            throw new Exception("We did not receive a valid participant type!");
123
-        }
124
-        $type = $validator->partType($typeRaw);
125
-        $idp = new \core\IdP($fed->newIdP($type, "PENDING", "API"));
126
-        // now add all submitted attributes
127
-        $inputs = $adminApi->uglify($scrubbedParameters);
128
-        $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]);
129
-        $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]);
130
-        break;
131
-    case web\lib\admin\API::ACTION_DELINST:
132
-        try {
133
-            $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
134
-        } catch (Exception $e) {
135
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
136
-            exit(1);
137
-        }
138
-        $idp->destroy();
139
-        $adminApi->returnSuccess([]);
140
-        break;
141
-    case web\lib\admin\API::ACTION_ADMIN_LIST:
142
-        try {
143
-            $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
144
-        } catch (Exception $e) {
145
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
146
-            exit(1);
147
-        }
148
-        $adminApi->returnSuccess($idp->listOwners());
149
-        break;
150
-    case web\lib\admin\API::ACTION_ADMIN_ADD:
151
-        // IdP in question
152
-        try {
153
-            $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
154
-        } catch (Exception $e) {
155
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
156
-            exit(1);
157
-        }
158
-        // here is the token
159
-        $mgmt = new core\UserManagement();
160
-        // we know we have an admin ID but scrutinizer wants this checked more explicitly
161
-        $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
162
-        if ($admin === FALSE) {
163
-            throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
164
-        }
165
-        $newtokens = $mgmt->createTokens(true, [$admin], $idp);
166
-        $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0];
167
-        $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]];
168
-        // done with the essentials - display in response. But if we also have an email address, send it there
169
-        $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL);
170
-        if ($email !== FALSE) {
171
-            $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed, $idp->type);
172
-            $success["EMAIL SENT"] = $sent["SENT"];
173
-            if ($sent["SENT"] === TRUE) {
174
-                $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"];
118
+        case web\lib\admin\API::ACTION_NEWINST:
119
+            // create the inst, no admin, no attributes
120
+            $typeRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_INSTTYPE);
121
+            if ($typeRaw === FALSE) {
122
+                throw new Exception("We did not receive a valid participant type!");
175 123
             }
176
-        }
177
-        $adminApi->returnSuccess($success);
178
-        break;
179
-    case web\lib\admin\API::ACTION_ADMIN_DEL:
180
-        // IdP in question
181
-        try {
182
-            $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
183
-        } catch (Exception $e) {
184
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
185
-            exit(1);
186
-        }
187
-        $currentAdmins = $idp->listOwners();
188
-        $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
189
-        if ($toBeDeleted === FALSE) {
190
-            throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
191
-        }
192
-        $found = FALSE;
193
-        foreach ($currentAdmins as $oneAdmin) {
194
-            if ($oneAdmin['MAIL'] == $toBeDeleted) {
195
-                $found = TRUE;
196
-                $mgmt = new core\UserManagement();
197
-                $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']);
124
+            $type = $validator->partType($typeRaw);
125
+            $idp = new \core\IdP($fed->newIdP($type, "PENDING", "API"));
126
+            // now add all submitted attributes
127
+            $inputs = $adminApi->uglify($scrubbedParameters);
128
+            $optionParser->processSubmittedFields($idp, $inputs["POST"], $inputs["FILES"]);
129
+            $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_CAT_INST_ID => $idp->identifier]);
130
+            break;
131
+        case web\lib\admin\API::ACTION_DELINST:
132
+            try {
133
+                $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
134
+            } catch (Exception $e) {
135
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
136
+                exit(1);
198 137
             }
199
-        }
200
-        if ($found) {
138
+            $idp->destroy();
201 139
             $adminApi->returnSuccess([]);
202
-        }
203
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier);
204
-        break;
205
-    case web\lib\admin\API::ACTION_STATISTICS_FED:
206
-        $adminApi->returnSuccess($fed->downloadStats("array"));
207
-        break;
208
-    case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
209
-    // fall-through intended: both get mostly identical treatment
210
-    case web\lib\admin\API::ACTION_NEWPROF_SB:
211
-        try {
212
-            $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
213
-        } catch (Exception $e) {
214
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
215
-            exit(1);
216
-        }
217
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
218
-            $type = "RADIUS";
219
-        } else {
220
-            $type = "SILVERBULLET";
221
-        }
222
-        $profile = $idp->newProfile($type);
223
-        if ($profile === NULL) {
224
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
225
-            exit(1);
226
-        }
227
-        $inputs = $adminApi->uglify($scrubbedParameters);
228
-        $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
229
-        if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
230
-            // auto-accept ToU?
231
-            if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
232
-                $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
233
-            }
234
-            // we're done at this point
235
-            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
236 140
             break;
237
-        }
238
-        if (!$profile instanceof core\ProfileRADIUS) {
239
-            throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
240
-        }
241
-        /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
242
-          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
243
-        $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
244
-        $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
245
-        if ($realm !== FALSE) {
246
-            if ($outer === FALSE) {
247
-                $outer = "";
248
-                $profile->setAnonymousIDSupport(FALSE);
141
+        case web\lib\admin\API::ACTION_ADMIN_LIST:
142
+            try {
143
+                $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
144
+            } catch (Exception $e) {
145
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
146
+                exit(1);
147
+            }
148
+            $adminApi->returnSuccess($idp->listOwners());
149
+            break;
150
+        case web\lib\admin\API::ACTION_ADMIN_ADD:
151
+            // IdP in question
152
+            try {
153
+                $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
154
+            } catch (Exception $e) {
155
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
156
+                exit(1);
157
+            }
158
+            // here is the token
159
+            $mgmt = new core\UserManagement();
160
+            // we know we have an admin ID but scrutinizer wants this checked more explicitly
161
+            $admin = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
162
+            if ($admin === FALSE) {
163
+                throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
164
+            }
165
+            $newtokens = $mgmt->createTokens(true, [$admin], $idp);
166
+            $URL = "https://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . "/action_enrollment.php?token=" . array_keys($newtokens)[0];
167
+            $success = ["TOKEN URL" => $URL, "TOKEN" => array_keys($newtokens)[0]];
168
+            // done with the essentials - display in response. But if we also have an email address, send it there
169
+            $email = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TARGETMAIL);
170
+            if ($email !== FALSE) {
171
+                $sent = \core\common\OutsideComm::adminInvitationMail($email, "EXISTING-FED", array_keys($newtokens)[0], $idp->name, $fed, $idp->type);
172
+                $success["EMAIL SENT"] = $sent["SENT"];
173
+                if ($sent["SENT"] === TRUE) {
174
+                    $success["EMAIL TRANSPORT SECURE"] = $sent["TRANSPORT"];
175
+                }
176
+            }
177
+            $adminApi->returnSuccess($success);
178
+            break;
179
+        case web\lib\admin\API::ACTION_ADMIN_DEL:
180
+            // IdP in question
181
+            try {
182
+                $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
183
+            } catch (Exception $e) {
184
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
185
+                exit(1);
186
+            }
187
+            $currentAdmins = $idp->listOwners();
188
+            $toBeDeleted = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_ADMINID);
189
+            if ($toBeDeleted === FALSE) {
190
+                throw new Exception("A required parameter is missing, and this wasn't caught earlier?!");
191
+            }
192
+            $found = FALSE;
193
+            foreach ($currentAdmins as $oneAdmin) {
194
+                if ($oneAdmin['MAIL'] == $toBeDeleted) {
195
+                    $found = TRUE;
196
+                    $mgmt = new core\UserManagement();
197
+                    $mgmt->removeAdminFromIdP($idp, $oneAdmin['ID']);
198
+                }
199
+            }
200
+            if ($found) {
201
+                $adminApi->returnSuccess([]);
202
+            }
203
+            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The admin with ID $toBeDeleted is not associated to IdP " . $idp->identifier);
204
+            break;
205
+        case web\lib\admin\API::ACTION_STATISTICS_FED:
206
+            $adminApi->returnSuccess($fed->downloadStats("array"));
207
+            break;
208
+        case \web\lib\admin\API::ACTION_NEWPROF_RADIUS:
209
+        // fall-through intended: both get mostly identical treatment
210
+        case web\lib\admin\API::ACTION_NEWPROF_SB:
211
+            try {
212
+                $idp = $validator->existingIdP($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_INST_ID));
213
+            } catch (Exception $e) {
214
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "IdP identifier does not exist!");
215
+                exit(1);
216
+            }
217
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_RADIUS) {
218
+                $type = "RADIUS";
249 219
             } else {
250
-                $outer = $outer . "@";
251
-                $profile->setAnonymousIDSupport(TRUE);
220
+                $type = "SILVERBULLET";
252 221
             }
253
-            $profile->setRealm($outer . $realm);
254
-        }
255
-        /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
256
-        $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
257
-        if ($testuser !== FALSE) {
258
-            $profile->setRealmCheckUser(TRUE, $testuser);
259
-        }
260
-        /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
222
+            $profile = $idp->newProfile($type);
223
+            if ($profile === NULL) {
224
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INTERNAL_ERROR, "Unable to create a new Profile, for no apparent reason. Please contact support.");
225
+                exit(1);
226
+            }
227
+            $inputs = $adminApi->uglify($scrubbedParameters);
228
+            $optionParser->processSubmittedFields($profile, $inputs["POST"], $inputs["FILES"]);
229
+            if ($inputDecoded['ACTION'] == web\lib\admin\API::ACTION_NEWPROF_SB) {
230
+                // auto-accept ToU?
231
+                if ($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_TOU) !== FALSE) {
232
+                    $profile->addAttribute("hiddenprofile:tou_accepted", NULL, 1);
233
+                }
234
+                // we're done at this point
235
+                $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profile->identifier]);
236
+                break;
237
+            }
238
+            if (!$profile instanceof core\ProfileRADIUS) {
239
+                throw new Exception("Can't be. This is only here to convince Scrutinizer that we're really talking RADIUS.");
240
+            }
241
+            /* const AUXATTRIB_PROFILE_REALM = 'ATTRIB-PROFILE-REALM';
242
+          const AUXATTRIB_PROFILE_OUTERVALUE = 'ATTRIB-PROFILE-OUTERVALUE'; */
243
+            $realm = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_REALM);
244
+            $outer = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_OUTERVALUE);
245
+            if ($realm !== FALSE) {
246
+                if ($outer === FALSE) {
247
+                    $outer = "";
248
+                    $profile->setAnonymousIDSupport(FALSE);
249
+                } else {
250
+                    $outer = $outer . "@";
251
+                    $profile->setAnonymousIDSupport(TRUE);
252
+                }
253
+                $profile->setRealm($outer . $realm);
254
+            }
255
+            /* const AUXATTRIB_PROFILE_TESTUSER = 'ATTRIB-PROFILE-TESTUSER'; */
256
+            $testuser = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_TESTUSER);
257
+            if ($testuser !== FALSE) {
258
+                $profile->setRealmCheckUser(TRUE, $testuser);
259
+            }
260
+            /* const AUXATTRIB_PROFILE_INPUT_HINT = 'ATTRIB-PROFILE-HINTREALM';
261 261
           const AUXATTRIB_PROFILE_INPUT_VERIFY = 'ATTRIB-PROFILE-VERIFYREALM'; */
262
-        $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
263
-        $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
264
-        if ($enforce !== FALSE) {
265
-            $profile->setInputVerificationPreference($enforce, $hint);
266
-        }
267
-        /* const AUXATTRIB_PROFILE_EAPTYPE */
268
-        $iterator = 1;
269
-        foreach ($scrubbedParameters as $oneParam) {
270
-            if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
271
-                $type = new \core\common\EAP($oneParam["VALUE"]);
272
-                $profile->addSupportedEapMethod($type, $iterator);
273
-                $iterator = $iterator + 1;
262
+            $hint = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_HINT);
263
+            $enforce = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_PROFILE_INPUT_VERIFY);
264
+            if ($enforce !== FALSE) {
265
+                $profile->setInputVerificationPreference($enforce, $hint);
274 266
             }
275
-        }
276
-        // reinstantiate $profile freshly from DB - it was updated in the process
277
-        $profileFresh = new core\ProfileRADIUS($profile->identifier);
278
-        $profileFresh->prepShowtime();
279
-        $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
280
-        break;
281
-    case web\lib\admin\API::ACTION_ENDUSER_NEW:
282
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
283
-        if ($prof_id === FALSE) {
284
-            exit(1);
285
-        }
286
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
287
-        if ($evaluation === FALSE) {
288
-            exit(1);
289
-        }
290
-        list($idp, $profile) = $evaluation;
291
-        $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
292
-        $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
293
-        if ($expiryRaw === FALSE) {
294
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
295
-            exit(1);
296
-        }
297
-        $expiry = new DateTime($expiryRaw);
298
-        try {
299
-            $retval = $profile->addUser($user, $expiry);
300
-        } catch (Exception $e) {
301
-            $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?");
302
-            exit(1);
303
-        }
304
-        if ($retval == 0) {// that didn't work, it seems
305
-            $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators.");
306
-            exit(1);
307
-        }
308
-        $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]);
309
-        break;
310
-    case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
311
-    // fall-through intended: both actions are very similar
312
-    case \web\lib\admin\API::ACTION_TOKEN_NEW:
313
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
314
-        if ($profile_id === FALSE) {
315
-            exit(1);
316
-        }
317
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
318
-        if ($evaluation === FALSE) {
319
-            exit(1);
320
-        }
321
-        list($idp, $profile) = $evaluation;
322
-        $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
323
-        if ($userId === FALSE) {
324
-            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
325
-            exit(1);
326
-        }
327
-        $additionalInfo = [];
328
-        switch ($inputDecoded['ACTION']) { // this is where the two differ
267
+            /* const AUXATTRIB_PROFILE_EAPTYPE */
268
+            $iterator = 1;
269
+            foreach ($scrubbedParameters as $oneParam) {
270
+                if ($oneParam['NAME'] == web\lib\admin\API::AUXATTRIB_PROFILE_EAPTYPE && is_int($oneParam["VALUE"])) {
271
+                    $type = new \core\common\EAP($oneParam["VALUE"]);
272
+                    $profile->addSupportedEapMethod($type, $iterator);
273
+                    $iterator = $iterator + 1;
274
+                }
275
+            }
276
+            // reinstantiate $profile freshly from DB - it was updated in the process
277
+            $profileFresh = new core\ProfileRADIUS($profile->identifier);
278
+            $profileFresh->prepShowtime();
279
+            $adminApi->returnSuccess([\web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID => $profileFresh->identifier]);
280
+            break;
281
+        case web\lib\admin\API::ACTION_ENDUSER_NEW:
282
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
283
+            if ($prof_id === FALSE) {
284
+                exit(1);
285
+            }
286
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
287
+            if ($evaluation === FALSE) {
288
+                exit(1);
289
+            }
290
+            list($idp, $profile) = $evaluation;
291
+            $user = $validator->string($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME));
292
+            $expiryRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_EXPIRY);
293
+            if ($expiryRaw === FALSE) {
294
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "The expiry date wasn't found in the request.");
295
+                exit(1);
296
+            }
297
+            $expiry = new DateTime($expiryRaw);
298
+            try {
299
+                $retval = $profile->addUser($user, $expiry);
300
+            } catch (Exception $e) {
301
+                $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed. Maybe a duplicate username, or malformed expiry date?");
302
+                exit(1);
303
+            }
304
+            if ($retval == 0) {// that didn't work, it seems
305
+                $adminApi->returnError(web\lib\admin\API::ERROR_INTERNAL_ERROR, "The operation failed subtly. Contact the administrators.");
306
+                exit(1);
307
+            }
308
+            $adminApi->returnSuccess([web\lib\admin\API::AUXATTRIB_SB_USERNAME => $user, \web\lib\admin\API::AUXATTRIB_SB_USERID => $retval]);
309
+            break;
310
+        case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
311
+        // fall-through intended: both actions are very similar
312
+        case \web\lib\admin\API::ACTION_TOKEN_NEW:
313
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
314
+            if ($profile_id === FALSE) {
315
+                exit(1);
316
+            }
317
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
318
+            if ($evaluation === FALSE) {
319
+                exit(1);
320
+            }
321
+            list($idp, $profile) = $evaluation;
322
+            $userId = $validator->integer($adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID));
323
+            if ($userId === FALSE) {
324
+                $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "User ID is not an integer.");
325
+                exit(1);
326
+            }
327
+            $additionalInfo = [];
328
+            switch ($inputDecoded['ACTION']) { // this is where the two differ
329 329
             case \web\lib\admin\API::ACTION_ENDUSER_DEACTIVATE:
330 330
                 $result = $profile->deactivateUser($userId);
331 331
                 break;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                     }
359 359
                 }
360 360
                 break;
361
-        }
361
+            }
362 362
 
363 363
         if ($result !== TRUE) {
364 364
             $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "These parameters did not lead to an existing, active user.");
@@ -366,65 +366,65 @@  discard block
 block discarded – undo
366 366
         }
367 367
         $adminApi->returnSuccess($additionalInfo);
368 368
         break;
369
-    case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
370
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
371
-        if ($profile_id === FALSE) {
372
-            exit(1);
373
-        }
374
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
375
-        if ($evaluation === FALSE) {
376
-            exit(1);
377
-        }
378
-        list($idp, $profile) = $evaluation;
379
-        $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
380
-        $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
381
-        $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
382
-        if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE) {
383
-            // we need at least one of those
384
-            $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, or certificate serial is required.");
385
-        }
386
-        $userlist = $profile->listAllUsers();
387
-        if ($userName === FALSE && $certSerial === FALSE) { // we got a user ID
388
-            if (!isset($userlist[$userId])) {
389
-                return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This user ID does not exist in this profile.");
369
+        case \web\lib\admin\API::ACTION_ENDUSER_IDENTIFY:
370
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
371
+            if ($profile_id === FALSE) {
372
+                exit(1);
390 373
             }
391
-            $adminApi->returnSuccess([$userId => $userlist[$userId]]);
392
-        }
393
-        if ($userId === FALSE && $certSerial === FALSE) { // we got a username
394
-            $key = array_search($userName, $userlist);
395
-            if ($key === FALSE) {
396
-                return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This username does not exist in this profile.");
374
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
375
+            if ($evaluation === FALSE) {
376
+                exit(1);
397 377
             }
398
-            $adminApi->returnSuccess([$key => $userlist[$key]]);
399
-        }
400
-        if ($userId === FALSE && $userName === FALSE) { // we got a cert serial
401
-            $serial = explode(":", $certSerial);
402
-            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
403
-            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
404
-                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
378
+            list($idp, $profile) = $evaluation;
379
+            $userId = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
380
+            $userName = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERNAME);
381
+            $certSerial = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
382
+            if ($userId === FALSE && $userName === FALSE && $certSerial === FALSE) {
383
+                // we need at least one of those
384
+                $adminApi->returnError(\web\lib\admin\API::ERROR_MISSING_PARAMETER, "At least one of User ID, Username, or certificate serial is required.");
405 385
             }
406
-            if ($cert->profileId != $profile->identifier) {
407
-                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
386
+            $userlist = $profile->listAllUsers();
387
+            if ($userName === FALSE && $certSerial === FALSE) { // we got a user ID
388
+                if (!isset($userlist[$userId])) {
389
+                    return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This user ID does not exist in this profile.");
390
+                }
391
+                $adminApi->returnSuccess([$userId => $userlist[$userId]]);
408 392
             }
409
-            $adminApi->returnSuccess([$cert->userId => $userlist[$cert->userId]]);
410
-        }
411
-        $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "Only exactly one of User ID, username or cert serial can be specified.");
412
-        break;
413
-    case \web\lib\admin\API::ACTION_ENDUSER_LIST:
414
-    // fall-through: those two are similar
415
-    case \web\lib\admin\API::ACTION_TOKEN_LIST:
416
-        $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
417
-        if ($profile_id === FALSE) {
418
-            exit(1);
419
-        }
420
-        $evaluation = commonSbProfileChecks($fed, $profile_id);
421
-        if ($evaluation === FALSE) {
422
-            exit(1);
423
-        }
424
-        list($idp, $profile) = $evaluation;
425
-        $allUsers = $profile->listAllUsers();
426
-        // this is where they differ
427
-        switch ($inputDecoded['ACTION']) {
393
+            if ($userId === FALSE && $certSerial === FALSE) { // we got a username
394
+                $key = array_search($userName, $userlist);
395
+                if ($key === FALSE) {
396
+                    return $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "This username does not exist in this profile.");
397
+                }
398
+                $adminApi->returnSuccess([$key => $userlist[$key]]);
399
+            }
400
+            if ($userId === FALSE && $userName === FALSE) { // we got a cert serial
401
+                $serial = explode(":", $certSerial);
402
+                $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
403
+                if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
404
+                    $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
405
+                }
406
+                if ($cert->profileId != $profile->identifier) {
407
+                    $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
408
+                }
409
+                $adminApi->returnSuccess([$cert->userId => $userlist[$cert->userId]]);
410
+            }
411
+            $adminApi->returnError(\web\lib\admin\API::ERROR_INVALID_PARAMETER, "Only exactly one of User ID, username or cert serial can be specified.");
412
+            break;
413
+        case \web\lib\admin\API::ACTION_ENDUSER_LIST:
414
+        // fall-through: those two are similar
415
+        case \web\lib\admin\API::ACTION_TOKEN_LIST:
416
+            $profile_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
417
+            if ($profile_id === FALSE) {
418
+                exit(1);
419
+            }
420
+            $evaluation = commonSbProfileChecks($fed, $profile_id);
421
+            if ($evaluation === FALSE) {
422
+                exit(1);
423
+            }
424
+            list($idp, $profile) = $evaluation;
425
+            $allUsers = $profile->listAllUsers();
426
+            // this is where they differ
427
+            switch ($inputDecoded['ACTION']) {
428 428
             case \web\lib\admin\API::ACTION_ENDUSER_LIST:
429 429
                 $adminApi->returnSuccess($allUsers);
430 430
                 break;
@@ -443,105 +443,105 @@  discard block
 block discarded – undo
443 443
                     $infoSet[$oneTokenObject->userId] = [\web\lib\admin\API::AUXATTRIB_TOKEN => $oneTokenObject->invitationTokenString, "STATUS" => $oneTokenObject->invitationTokenStatus];
444 444
                 }
445 445
                 $adminApi->returnSuccess($infoSet);
446
-        }
447
-        break;
448
-    case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
449
-        $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
450
-        if ($tokenRaw === FALSE) {
451
-            exit(1);
452
-        }
453
-        $token = new core\SilverbulletInvitation($tokenRaw);
454
-        if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
455
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
456
-            exit(1);
457
-        }
458
-        $token->revokeInvitation();
459
-        $adminApi->returnSuccess([]);
460
-        break;
461
-    case \web\lib\admin\API::ACTION_CERT_LIST:
462
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
463
-        $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
464
-        if ($prof_id === FALSE || !is_int($user_id)) {
465
-            exit(1);
466
-        }
467
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
468
-        if ($evaluation === FALSE) {
469
-            exit(1);
470
-        }
471
-        list($idp, $profile) = $evaluation;
472
-        $invitations = $profile->userStatus($user_id);
473
-        // now pull out cert information from the object
474
-        $certs = [];
475
-        foreach ($invitations as $oneInvitation) {
476
-            $certs = array_merge($certs, $oneInvitation->associatedCertificates);
477
-        }
478
-        // extract relevant subset of information from cert objects
479
-        $certDetails = [];
480
-        foreach ($certs as $cert) {
481
-            $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
482
-        }
483
-        $adminApi->returnSuccess($certDetails);
484
-        break;
485
-    case \web\lib\admin\API::ACTION_CERT_REVOKE:
486
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
487
-        if ($prof_id === FALSE) {
488
-            exit(1);
489
-        }
490
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
491
-        if ($evaluation === FALSE) {
492
-            exit(1);
493
-        }
494
-        list($idp, $profile) = $evaluation;
495
-        // tear apart the serial
496
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
497
-        if ($serialRaw === FALSE) {
498
-            exit(1);
499
-        }
500
-        $serial = explode(":", $serialRaw);
501
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
502
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
503
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
504
-        }
505
-        if ($cert->profileId != $profile->identifier) {
506
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
507
-        }
508
-        $cert->revokeCertificate();
509
-        $adminApi->returnSuccess([]);
446
+            }
510 447
         break;
511
-    case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
512
-        $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
513
-        if ($prof_id === FALSE) {
514
-            exit(1);
515
-        }
516
-        $evaluation = commonSbProfileChecks($fed, $prof_id);
517
-        if ($evaluation === FALSE) {
518
-            exit(1);
519
-        }
520
-        list($idp, $profile) = $evaluation;
521
-        // tear apart the serial
522
-        $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
523
-        if ($serialRaw === FALSE) {
524
-            exit(1);
525
-        }
526
-        $serial = explode(":", $serialRaw);
527
-        $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
528
-        if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
529
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
530
-        }
531
-        if ($cert->profileId != $profile->identifier) {
532
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
533
-        }
534
-        $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
535
-        if ($annotationRaw === FALSE) {
536
-            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
448
+        case \web\lib\admin\API::ACTION_TOKEN_REVOKE:
449
+            $tokenRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_TOKEN);
450
+            if ($tokenRaw === FALSE) {
451
+                exit(1);
452
+            }
453
+            $token = new core\SilverbulletInvitation($tokenRaw);
454
+            if ($token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_VALID && $token->invitationTokenStatus !== core\SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
455
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "This is not a currently valid token.");
456
+                exit(1);
457
+            }
458
+            $token->revokeInvitation();
459
+            $adminApi->returnSuccess([]);
537 460
             break;
538
-        }
539
-        $annotation = json_decode($annotationRaw, TRUE);
540
-        $cert->annotate($annotation);
541
-        $adminApi->returnSuccess([]);
461
+        case \web\lib\admin\API::ACTION_CERT_LIST:
462
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
463
+            $user_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_USERID);
464
+            if ($prof_id === FALSE || !is_int($user_id)) {
465
+                exit(1);
466
+            }
467
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
468
+            if ($evaluation === FALSE) {
469
+                exit(1);
470
+            }
471
+            list($idp, $profile) = $evaluation;
472
+            $invitations = $profile->userStatus($user_id);
473
+            // now pull out cert information from the object
474
+            $certs = [];
475
+            foreach ($invitations as $oneInvitation) {
476
+                $certs = array_merge($certs, $oneInvitation->associatedCertificates);
477
+            }
478
+            // extract relevant subset of information from cert objects
479
+            $certDetails = [];
480
+            foreach ($certs as $cert) {
481
+                $certDetails[$cert->ca_type . ":" . $cert->serial] = ["ISSUED" => $cert->issued, "EXPIRY" => $cert->expiry, "STATUS" => $cert->status, "DEVICE" => $cert->device, "CN" => $cert->username, "ANNOTATION" => $cert->annotation];
482
+            }
483
+            $adminApi->returnSuccess($certDetails);
484
+            break;
485
+        case \web\lib\admin\API::ACTION_CERT_REVOKE:
486
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
487
+            if ($prof_id === FALSE) {
488
+                exit(1);
489
+            }
490
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
491
+            if ($evaluation === FALSE) {
492
+                exit(1);
493
+            }
494
+            list($idp, $profile) = $evaluation;
495
+            // tear apart the serial
496
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
497
+            if ($serialRaw === FALSE) {
498
+                exit(1);
499
+            }
500
+            $serial = explode(":", $serialRaw);
501
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
502
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
503
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
504
+            }
505
+            if ($cert->profileId != $profile->identifier) {
506
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
507
+            }
508
+            $cert->revokeCertificate();
509
+            $adminApi->returnSuccess([]);
510
+            break;
511
+        case \web\lib\admin\API::ACTION_CERT_ANNOTATE:
512
+            $prof_id = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_CAT_PROFILE_ID);
513
+            if ($prof_id === FALSE) {
514
+                exit(1);
515
+            }
516
+            $evaluation = commonSbProfileChecks($fed, $prof_id);
517
+            if ($evaluation === FALSE) {
518
+                exit(1);
519
+            }
520
+            list($idp, $profile) = $evaluation;
521
+            // tear apart the serial
522
+            $serialRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTSERIAL);
523
+            if ($serialRaw === FALSE) {
524
+                exit(1);
525
+            }
526
+            $serial = explode(":", $serialRaw);
527
+            $cert = new \core\SilverbulletCertificate($serial[1], $serial[0]);
528
+            if ($cert->status == \core\SilverbulletCertificate::CERTSTATUS_INVALID) {
529
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial not found.");
530
+            }
531
+            if ($cert->profileId != $profile->identifier) {
532
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Serial does not belong to this profile.");
533
+            }
534
+            $annotationRaw = $adminApi->firstParameterInstance($scrubbedParameters, web\lib\admin\API::AUXATTRIB_SB_CERTANNOTATION);
535
+            if ($annotationRaw === FALSE) {
536
+                $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_PARAMETER, "Unable to extract annotation.");
537
+                break;
538
+            }
539
+            $annotation = json_decode($annotationRaw, TRUE);
540
+            $cert->annotate($annotation);
541
+            $adminApi->returnSuccess([]);
542 542
         
543
-        break;
543
+            break;
544 544
         
545
-    default:
546
-        $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
545
+        default:
546
+            $adminApi->returnError(web\lib\admin\API::ERROR_INVALID_ACTION, "Not implemented yet.");
547 547
 }
548 548
\ No newline at end of file
Please login to merge, or discard this patch.
web/admin/edit_federation_result.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @author Stefan Winter <[email protected]>
26 26
  */
27 27
 
28
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
28
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
29 29
 
30 30
 $auth = new \web\lib\admin\Authentication();
31 31
 $deco = new \web\lib\admin\PageDecoration();
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 $my_fed = $validator->existingFederation($_GET['fed_id'], $_SESSION['user']);
41 41
 if (isset($_POST['submitbutton']) && $_POST['submitbutton'] == web\lib\common\FormElements::BUTTON_SAVE) { // here we go
42 42
     $fed_name = $my_fed->name;
43
-    echo "<h1>" . sprintf(_("Submitted attributes for %s '%s'"), $uiElements->nomenclatureFed, $fed_name) . "</h1>";
43
+    echo "<h1>".sprintf(_("Submitted attributes for %s '%s'"), $uiElements->nomenclatureFed, $fed_name)."</h1>";
44 44
     echo "<table>";
45 45
     echo $optionParser->processSubmittedFields($my_fed, $_POST, $_FILES);
46 46
     echo "</table>";
47 47
 
48 48
     $loggerInstance = new \core\common\Logging();
49
-    $loggerInstance->writeAudit($_SESSION['user'], "MOD", "FED " . $my_fed->name . " - attributes changed");
49
+    $loggerInstance->writeAudit($_SESSION['user'], "MOD", "FED ".$my_fed->name." - attributes changed");
50 50
 
51 51
     // re-instantiate ourselves... profiles need fresh data
52 52
 
53 53
     $my_fed = $validator->existingFederation($_GET['fed_id'], $_SESSION['user']);
54 54
 
55
-    echo "<br/><form method='post' action='overview_federation.php' accept-charset='UTF-8'><button type='submit'>" . _("Continue to dashboard") . "</button></form>";
55
+    echo "<br/><form method='post' action='overview_federation.php' accept-charset='UTF-8'><button type='submit'>"._("Continue to dashboard")."</button></form>";
56 56
 }
57 57
 echo $deco->footer();
Please login to merge, or discard this patch.
web/admin/edit_silverbullet.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 /*
21 21
  * Class autoloader invocation, should be included prior to any other code at the entry points to the application
22 22
  */
23
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
24
-require_once dirname(dirname(dirname(__FILE__))) . "/core/phpqrcode.php";
23
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
24
+require_once dirname(dirname(dirname(__FILE__)))."/core/phpqrcode.php";
25 25
 const QRCODE_PIXELS_PER_SYMBOL = 12;
26 26
 
27 27
 $auth = new \web\lib\admin\Authentication();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     $fed = new \core\Federation($inst->federation);
56 56
     $allowSb = $fed->getAttributes("fed:silverbullet");
57 57
     if (count($allowSb) == 0) {
58
-        throw new Exception("We were told to create a new SB profile, but this " . CONFIG_CONFASSISTANT['CONSORTIUM']['nomenclature_federation'] . " does not allow SB at all!");
58
+        throw new Exception("We were told to create a new SB profile, but this ".CONFIG_CONFASSISTANT['CONSORTIUM']['nomenclature_federation']." does not allow SB at all!");
59 59
     }
60 60
     // okay, new SB profiles are allowed. 
61 61
     // but is there a support:email attribute on inst level?
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     // Create one.
67 67
     $newProfile = $inst->newProfile(core\AbstractProfile::PROFILETYPE_SILVERBULLET);
68 68
     // and modify the REQUEST_URI to add the new profile ID
69
-    $_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI'] . "&profile_id=" . $newProfile->identifier;
69
+    $_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_URI']."&profile_id=".$newProfile->identifier;
70 70
     $_GET['profile_id'] = $newProfile->identifier;
71 71
     $profile = $newProfile;
72 72
 } else {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                         break;
135 135
                     }
136 136
                     $properName = $validator->syntaxConformUser($elements[0]);
137
-                    $properDate = new DateTime($elements[1] . " 00:00:00");
137
+                    $properDate = new DateTime($elements[1]." 00:00:00");
138 138
                     $numberOfActivations = $elements[2] ?? 1;
139 139
                     $number = $validator->integer($numberOfActivations);
140 140
                     if ($number === FALSE) { // invalid input received, default to sane
@@ -227,18 +227,18 @@  discard block
 block discarded – undo
227 227
                     // warn and ask for confirmation unless already confirmed
228 228
                     if (!isset($_POST['insecureconfirm']) || $_POST['insecureconfirm'] != "CONFIRM") {
229 229
                         echo $deco->pageheader(_("Insecure mail domain!"), "ADMIN-IDP-USERS");
230
-                        echo "<p>" . sprintf(_("The mail domain of the mail address <strong>%s</strong> is not secure: some or all of the mail servers are not accepting encrypted connections (no consistent support for STARTTLS)."), $properEmail) . "</p>";
231
-                        echo "<p>" . _("The invitation would need to be sent in cleartext across the internet, and can possibly be read and abused by anyone in transit.") . "</p>";
232
-                        echo "<p>" . _("Do you want the system to send this mail anyway?") . "</p>";
230
+                        echo "<p>".sprintf(_("The mail domain of the mail address <strong>%s</strong> is not secure: some or all of the mail servers are not accepting encrypted connections (no consistent support for STARTTLS)."), $properEmail)."</p>";
231
+                        echo "<p>"._("The invitation would need to be sent in cleartext across the internet, and can possibly be read and abused by anyone in transit.")."</p>";
232
+                        echo "<p>"._("Do you want the system to send this mail anyway?")."</p>";
233 233
                         echo $formtext;
234
-                        echo "<button type='submit' class='delete'>" . _("DO NOT SEND") . "</button>";
234
+                        echo "<button type='submit' class='delete'>"._("DO NOT SEND")."</button>";
235 235
                         echo "</form>";
236 236
                         echo $formtext;
237
-                        echo "<input type='hidden' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT . "'</>";
237
+                        echo "<input type='hidden' name='command' value='".\web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT."'</>";
238 238
                         echo "<input type='hidden' name='address' value='$properEmail'</>";
239
-                        echo "<input type='hidden' name='token' value='" . $invitationObject->invitationTokenString . "'</>";
239
+                        echo "<input type='hidden' name='token' value='".$invitationObject->invitationTokenString."'</>";
240 240
                         echo "<input type='hidden' name='insecureconfirm' value='CONFIRM'/>";
241
-                        echo "<button type='submit'>" . _("Send anyway.") . "</button>";
241
+                        echo "<button type='submit'>"._("Send anyway.")."</button>";
242 242
                         echo "</form>";
243 243
                         echo $deco->footer();
244 244
                         exit;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 $allUsers = $profile->listAllUsers();
289 289
 $activeUsers = $profile->listActiveUsers();
290 290
 
291
-echo $deco->defaultPagePrelude(sprintf(_('Managing %s users'), \core\ProfileSilverbullet::PRODUCTNAME ));
291
+echo $deco->defaultPagePrelude(sprintf(_('Managing %s users'), \core\ProfileSilverbullet::PRODUCTNAME));
292 292
 
293 293
 ?>
294 294
 <script src='js/option_expand.js' type='text/javascript'></script>
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     echo $deco->productHeader("ADMIN-IDP-USERS");
327 327
     ?>
328 328
     <img src='../resources/images/icons/loading51.gif' id='spin' alt='loading...' style='position:absolute;left: 50%; top: 50%; transform: translate(-100px, -50px); display:none; z-index: 100;'>
329
-    <?php echo $uiElements->instLevelInfoBoxes($inst);?>
329
+    <?php echo $uiElements->instLevelInfoBoxes($inst); ?>
330 330
     <div class='infobox'>
331 331
         <h2><?php echo sprintf(_('Current %s users'), \core\ProfileSilverbullet::PRODUCTNAME); ?></h2>
332 332
         <table>
@@ -426,23 +426,23 @@  discard block
 block discarded – undo
426 426
                                 ?>
427 427
 
428 428
                                 <div class="sb-certificate-summary ca-summary" <?php echo $style; ?>>
429
-                                    <div class="sb-certificate-details"><?php echo _("Device:") . " " . $display; ?>
430
-                                        <br><?php echo _("Serial Number:") . "&nbsp;" . gmp_strval($oneCert->serial, 16); ?>
431
-                                        <br><?php echo _("CN:") . "&nbsp;" . explode('@', $oneCert->username)[0] . "@…"; ?>
432
-                                        <br><?php echo _("Expiry:") . "&nbsp;" . $oneCert->expiry; ?>
433
-                                        <br><?php echo _("Issued:") . "&nbsp;" . $oneCert->issued; ?>
429
+                                    <div class="sb-certificate-details"><?php echo _("Device:")." ".$display; ?>
430
+                                        <br><?php echo _("Serial Number:")."&nbsp;".gmp_strval($oneCert->serial, 16); ?>
431
+                                        <br><?php echo _("CN:")."&nbsp;".explode('@', $oneCert->username)[0]."@…"; ?>
432
+                                        <br><?php echo _("Expiry:")."&nbsp;".$oneCert->expiry; ?>
433
+                                        <br><?php echo _("Issued:")."&nbsp;".$oneCert->issued; ?>
434 434
                                     </div>
435 435
                                     <div style="text-align:right;padding-top: 5px; <?php echo $buttonStyle; ?>">
436 436
                                         <?php
437 437
                                         if ($buttonText == "") {
438 438
                                             echo "$formtext"
439
-                                            . "<input type='hidden' name='certSerial' value='" . $oneCert->serial . "'/>"
440
-                                            . "<input type='hidden' name='certAlgo' value='" . $oneCert->ca_type . "'/>"
439
+                                            . "<input type='hidden' name='certSerial' value='".$oneCert->serial."'/>"
440
+                                            . "<input type='hidden' name='certAlgo' value='".$oneCert->ca_type."'/>"
441 441
                                             . "<button type='submit' "
442 442
                                                     . "name='command' "
443
-                                                    . "value='" . \web\lib\common\FormElements::BUTTON_REVOKECREDENTIAL . "' "
443
+                                                    . "value='".\web\lib\common\FormElements::BUTTON_REVOKECREDENTIAL."' "
444 444
                                                     . "class='delete' "
445
-                                                    . "onclick='return confirm(\"" . sprintf(_("The device in question will stop functioning with %s. The revocation cannot be undone. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "\")'>"
445
+                                                    . "onclick='return confirm(\"".sprintf(_("The device in question will stop functioning with %s. The revocation cannot be undone. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."\")'>"
446 446
                                                     . _("Revoke") 
447 447
                                                     . "</button>"
448 448
                                             . "</form>";
@@ -468,38 +468,38 @@  discard block
 block discarded – undo
468 468
                                     $tokenHtmlBuffer .= "<tr class='sb-certificate-row'><td></td>";
469 469
                                     $jsEncodedBody = str_replace('\n', '%0D%0A', str_replace('"', '', json_encode($invitationObject->invitationMailBody())));
470 470
                                     $tokenHtmlBuffer .= "<td>";
471
-                                    $tokenHtmlBuffer .= sprintf(_("The invitation token %s is ready for sending! Choose how to send it:"),"<input type='text' readonly='readonly' style='background-color:lightgrey;' size='60' value='" . $invitationObject->link() . "' name='token' class='identifiedtokenarea-" . $invitationObject->identifier . "'>(…)<br/>");
471
+                                    $tokenHtmlBuffer .= sprintf(_("The invitation token %s is ready for sending! Choose how to send it:"), "<input type='text' readonly='readonly' style='background-color:lightgrey;' size='60' value='".$invitationObject->link()."' name='token' class='identifiedtokenarea-".$invitationObject->identifier."'>(…)<br/>");
472 472
                                     $tokenHtmlBuffer .= "<table>
473 473
                                     <tr><td style='vertical-align:bottom;'>"._("E-Mail:")."</td><td>
474 474
                                     $formtext
475
-                                <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
475
+                                <input type='hidden' value='".$invitationObject->invitationTokenString."' name='token'><br/>
476 476
                                 <input type='text' name='address' id='address-$invitationObject->identifier'/>
477
-                                <button type='button' onclick='window.location=\"mailto:\"+document.getElementById(\"address-$invitationObject->identifier\").value+\"?subject=" . $invitationObject->invitationMailSubject() . "&amp;body=$jsEncodedBody\"; return false;'>" . _("Local mail client") . "</button>
478
-                                <button type='submit' name='command' onclick='document.getElementById(\"spin\").style.display =\"block\"' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT . "'>"._("Send with CAT")."</button>
477
+                                <button type='button' onclick='window.location=\"mailto:\"+document.getElementById(\"address-$invitationObject->identifier\").value+\"?subject=".$invitationObject->invitationMailSubject()."&amp;body=$jsEncodedBody\"; return false;'>"._("Local mail client")."</button>
478
+                                <button type='submit' name='command' onclick='document.getElementById(\"spin\").style.display =\"block\"' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONMAILBYCAT."'>"._("Send with CAT")."</button>
479 479
                                     </form>
480 480
                                     </td></tr>
481 481
                                     <tr><td style='vertical-align:bottom;'>"._("SMS:")."</td><td>
482 482
                                     $formtext
483
-                                    <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
483
+                                    <input type='hidden' value='".$invitationObject->invitationTokenString."' name='token'><br/>
484 484
                                     <input type='text' name='smsnumber' />
485
-				<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONSMS . "'>" . _("Send in SMS...") . "</button>
485
+				<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_SENDINVITATIONSMS."'>"._("Send in SMS...")."</button>
486 486
                                     </form>
487 487
 				</td></tr>
488 488
                                     <tr><td style='vertical-align:bottom;'>"._("Manual:")."</td><td>
489
-				<button type='button' class='clipboardButton' onclick='clipboardCopy(" . $invitationObject->identifier . ");'>" . _("Copy to Clipboard") . "</button>
489
+				<button type='button' class='clipboardButton' onclick='clipboardCopy(" . $invitationObject->identifier.");'>"._("Copy to Clipboard")."</button>
490 490
                                     <form style='display:inline-block;' method='post' action='inc/displayQRcode.inc.php' onsubmit='popupQRWindow(this); return false;' accept-charset='UTF-8'>
491
-                                    <input type='hidden' value='" . $invitationObject->invitationTokenString . "' name='token'><br/>
492
-                                      <button type='submit'>" . _("Display QR code") . "</button>
491
+                                    <input type='hidden' value='" . $invitationObject->invitationTokenString."' name='token'><br/>
492
+                                      <button type='submit'>" . _("Display QR code")."</button>
493 493
                                   </form>
494 494
                                         </td></tr>
495 495
                                         
496 496
                                 </table>
497 497
                                 </td>";
498
-                                    $tokenHtmlBuffer .= "<td>" . _("Expiry Date:") . " " . $invitationObject->expiry . " UTC<br>" . _("Activations remaining:") . " " . sprintf(_("%d of %d"), $invitationObject->activationsRemaining, $invitationObject->activationsTotal) . "</td>";
498
+                                    $tokenHtmlBuffer .= "<td>"._("Expiry Date:")." ".$invitationObject->expiry." UTC<br>"._("Activations remaining:")." ".sprintf(_("%d of %d"), $invitationObject->activationsRemaining, $invitationObject->activationsTotal)."</td>";
499 499
                                     $tokenHtmlBuffer .= "<td>"
500 500
                                             . $formtext
501
-                                            . "<input type='hidden' name='invitationtoken' value='" . $invitationObject->invitationTokenString . "'/>"
502
-                                            . "<button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_REVOKEINVITATION . "' class='delete'>"._("Revoke"). "</button></form>"
501
+                                            . "<input type='hidden' name='invitationtoken' value='".$invitationObject->invitationTokenString."'/>"
502
+                                            . "<button type='submit' name='command' value='".\web\lib\common\FormElements::BUTTON_REVOKEINVITATION."' class='delete'>"._("Revoke")."</button></form>"
503 503
                                             . "</td></tr>";
504 504
                                     break;
505 505
                                 case core\SilverbulletInvitation::SB_TOKENSTATUS_EXPIRED:
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
                                 <span><input type="text" maxlength="19" class="sb-date-picker" name="userexpiry" value="<?php echo $profile->getUserExpiryDate($oneUserId); ?>">&nbsp;(UTC)</span>
522 522
                             </div>
523 523
                             <input type="hidden" name="userid" value="<?php echo $oneUserId; ?>"/>
524
-                            <button type="submit" name="command" value="<?php echo \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY ?>"><?php echo _("Update");?></button>
524
+                            <button type="submit" name="command" value="<?php echo \web\lib\common\FormElements::BUTTON_CHANGEUSEREXPIRY ?>"><?php echo _("Update"); ?></button>
525 525
                             </form>
526 526
                         </td>
527 527
                         <td>
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
                                 <?php
530 530
                                 if ($hasOnePendingInvite || count($validCerts) > 0) {
531 531
                                     $deletionText = sprintf(_("All of the currently active devices will stop functioning with %s. This cannot be undone. While the user can be re-activated later, they will then need to be re-provisioned with new invitation tokens. Are you sure you want to do this?"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']);
532
-                                    echo $formtext . "
532
+                                    echo $formtext."
533 533
                                     <input type='hidden' name='userid' value='$oneUserId'/>
534 534
                                     <button type='submit' "
535 535
                                             . "name='command' "
536
-                                            . "value='" . \web\lib\common\FormElements::BUTTON_DEACTIVATEUSER . "' "
536
+                                            . "value='".\web\lib\common\FormElements::BUTTON_DEACTIVATEUSER."' "
537 537
                                             . "class='delete' "
538
-                                            . ( count($validCerts) > 0 ? "onclick='return confirm(\"".$deletionText."\")' " : "" )
538
+                                            . (count($validCerts) > 0 ? "onclick='return confirm(\"".$deletionText."\")' " : "")
539 539
                                             . ">" 
540 540
                                             . _("Deactivate User") 
541 541
                                             . "</button>
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
                                     . ' If all accounts shown as active above are indeed still valid, please check the box below and push "Save".'
575 575
                                     . ' If any of the accounts are stale, please deactivate them by pushing the corresponding button before doing this.'), CONFIG_CONFASSISTANT['SILVERBULLET']['gracetime'] ?? core\ProfileSilverbullet::SB_ACKNOWLEDGEMENT_REQUIRED_DAYS);
576 576
 
577
-                    echo $formtext . "<div style='padding-bottom: 20px;'>"
577
+                    echo $formtext."<div style='padding-bottom: 20px;'>"
578 578
                     . "
579 579
                     <p>$acknowledgeText</p>
580 580
                     <input type='checkbox' name='acknowledge' value='true'>
581
-                    <label>" . sprintf(_("I have verified that all configured users are still eligible for %s."),CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</label>
581
+                    <label>".sprintf(_("I have verified that all configured users are still eligible for %s."), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'])."</label>
582 582
                 </div>
583
-                <button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_ACKUSERELIGIBILITY . "'>"._("Save")."</button></form>";
583
+                <button type='submit' name='command' value='" . \web\lib\common\FormElements::BUTTON_ACKUSERELIGIBILITY."'>"._("Save")."</button></form>";
584 584
                 }
585 585
                 ?>
586 586
             </div>
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
     
658 658
     <form action="overview_idp.php?inst_id=<?php echo $inst->identifier; ?>" method="POST">
659 659
         <p>
660
-        <button type='submit' name='submitbutton' value="nomatter"><?php echo sprintf(_("Back to %s page"),$uiElements->nomenclatureInst);?></button>
660
+        <button type='submit' name='submitbutton' value="nomatter"><?php echo sprintf(_("Back to %s page"), $uiElements->nomenclatureInst); ?></button>
661 661
         </p>
662 662
     </form>
663 663
     <?php
Please login to merge, or discard this patch.