Passed
Push — master ( e2f476...5bb890 )
by Stefan
06:49
created
web/admin/inc/sendinvite.inc.php 1 patch
Switch Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -100,87 +100,87 @@
 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
-        $participant_type = $extinfo['type'];
172
-        // fill the rest of the text
173
-        $introtext = "EXISTING-FED";
174
-        // do the token creation magic
175
-        $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid);
176
-        $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for " . implode(",", $mailaddress));
177
-        break;
178
-    default: // includes OPERATION_MODE_INVALID
179
-        $wrongcontent = print_r($_POST, TRUE);
180
-        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
+            $participant_type = $extinfo['type'];
172
+            // fill the rest of the text
173
+            $introtext = "EXISTING-FED";
174
+            // do the token creation magic
175
+            $newtokens = $mgmt->createTokens(TRUE, $mailaddress, $prettyprintname, $newexternalid);
176
+            $loggerInstance->writeAudit($_SESSION['user'], "NEW", "IdP FUTURE  - Token created for " . implode(",", $mailaddress));
177
+            break;
178
+        default: // includes OPERATION_MODE_INVALID
179
+            $wrongcontent = print_r($_POST, TRUE);
180
+            echo "<pre>Wrong parameters in POST:
181 181
 " . htmlspecialchars($wrongcontent) . "
182 182
 </pre>";
183
-        exit(1);
183
+            exit(1);
184 184
 }
185 185
 
186 186
 // send, and invalidate the token immediately if the mail could not be sent!
Please login to merge, or discard this patch.