Test Setup Failed
Push — master ( 76324d...01a5b9 )
by Stefan
05:57
created

displayDeploymentPropertyWidget()   F

Complexity

Conditions 32
Paths > 20000

Size

Total Lines 172
Code Lines 146

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 146
c 1
b 0
f 0
dl 0
loc 172
rs 0
cc 32
nc 20482
nop 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * *****************************************************************************
4
 * Contributions to this work were made on behalf of the GÉANT project, a 
5
 * project that has received funding from the European Union’s Framework 
6
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
7
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
8
 * 691567 (GN4-1) and No. 731122 (GN4-2).
9
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
10
 * of the copyright in all material which was developed by a member of the GÉANT
11
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
12
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
13
 * UK as a branch of GÉANT Vereniging.
14
 * 
15
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
16
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
17
 *
18
 * License: see the web/copyright.inc.php file in the file structure or
19
 *          <base_url>/copyright.php after deploying the software
20
 */
21
22
/**
23
 * This page displays the dashboard overview of an entire IdP.
24
 * 
25
 * @author Stefan Winter <[email protected]>
26
 */
27
?>
28
<?php
29
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
30
31
function displaySilverbulletPropertyWidget(&$theProfile, $readonly, &$uiElements) {
32
    ?>
33
    <div style='padding-bottom:20px;'>
34
        <h2><?php echo $theProfile->name; ?></h2>
35
        <?php
36
        $maxusers = $theProfile->getAttributes("internal:silverbullet_maxusers");
37
        $completeness = $theProfile->isEapTypeDefinitionComplete(new core\common\EAP(core\common\EAP::INTEGER_SILVERBULLET));
38
        // do we have all info needed for showtime? particularly: support email
39
        if (is_array($completeness)) {
40
            ?>
41
            <div class='notacceptable'>
42
                <?php echo _("Information needed!"); ?>
43
                <ul style='margin:1px'>
44
                    <?php
45
                    foreach ($completeness as $missing_attrib) {
46
                        echo "<li>" . $uiElements->displayName($missing_attrib) . "</li>";
47
                    }
48
                    ?>
49
                </ul>
50
            </div>
51
            <?php
52
        } else {
53
            echo sprintf(_("You can create up to %d users."), $maxusers[0]['value']) . "<br/>" . sprintf(_("Their credentials will carry the name <strong>%s</strong>."), $theProfile->realm);
54
        }
55
        ?>
56
        <br/>
57
        <br/>
58
        <?php
59
        if ($readonly === FALSE) {
60
            ?>
61
            <form action='edit_silverbullet.php?inst_id=<?php echo $my_inst->identifier; ?>&amp;profile_id=<?php echo $theProfile->identifier; ?>' method='POST'>
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $my_inst seems to be never defined.
Loading history...
62
                <button <?php echo ( is_array($completeness) ? "disabled" : "" ); ?> type='submit' name='sb_action' value='sb_edit'><?php echo _("Manage User Base"); ?></button>
63
            </form>
64
            <?php
65
        }
66
        ?>
67
    </div>
68
    <?php
69
}
70
71
/**
72
 * display an infocard with overview data of a RADIUS profile
73
 * 
74
 * @param \core\Profile             $theProfile the profile we display
75
 * @param boolean                   $readonly     are we in readonly mode? No edit buttons then...
76
 * @param \web\lib\admin\UIElements $uiElements   some UI elements
77
 * @throws Exception
78
 */
79
function displayRadiusPropertyWidget(&$theProfile, $readonly, &$uiElements) {
80
    ?>
81
    <div style='padding-bottom:20px;'>
82
        <?php $profile_name = $theProfile->name; ?>
83
        <h2 style='overflow:auto; display:inline; padding-bottom: 10px;'><?php printf(_("Profile: %s"), $profile_name); ?></h2>
84
        <?php
85
        // see if there are any profile-level overrides
86
        $attribs = $theProfile->getAttributes();
87
        // write things into a buffer; we need some function calls to determine
88
        // readiness - but want to display it before!
89
        $has_overrides = FALSE;
90
        foreach ($attribs as $attrib) {
91
            if ($attrib['level'] == \core\Options::LEVEL_PROFILE && !preg_match("/^(internal:|profile:name|profile:description|eap:)/", $attrib['name'])) {
92
                $has_overrides = TRUE;
93
            }
94
        }
95
        $buffer_eaptypediv = "<div style='margin-bottom:40px; float:left;'>" . _("<strong>EAP Types</strong> (in order of preference):") . "<br/>";
96
        $typelist = $theProfile->getEapMethodsinOrderOfPreference();
97
        $allcomplete = TRUE;
98
        foreach ($typelist as $eaptype) {
99
            $buffer_eaptypediv .= $eaptype->getPrintableRep();
100
            $completeness = $theProfile->isEapTypeDefinitionComplete($eaptype);
101
            if ($completeness === true) {
102
                $buffer_eaptypediv .= " <div class='acceptable'>" . _("OK") . "</div>";
103
            } else {
104
                $buffer_eaptypediv .= " <div class='notacceptable'>";
105
                $buffer_eaptypediv .= _("Information needed!");
106
                if (is_array($completeness)) {
107
                    $buffer_eaptypediv .= "<ul style='margin:1px'>";
108
                    foreach ($completeness as $missing_attrib) {
109
                        $buffer_eaptypediv .= "<li>" . $uiElements->displayName($missing_attrib) . "</li>";
110
                    }
111
                    $buffer_eaptypediv .= "</ul>";
112
                }
113
                $buffer_eaptypediv .= "</div>";
114
                $allcomplete = FALSE;
115
            }
116
            $attribs = $theProfile->getAttributes();
117
            $justOnce = FALSE;
118
            foreach ($attribs as $attrib) {
119
                if ($attrib['level'] == \core\Options::LEVEL_METHOD && !preg_match("/^internal:/", $attrib['name']) && !$justOnce) {
120
                    $justOnce = TRUE;
121
                    $buffer_eaptypediv .= "<img src='../resources/images/icons/Letter-E-blue-icon.png' alt='" . _("Options on EAP Method/Device level are in effect.") . "'>";
122
                }
123
            }
124
            $buffer_eaptypediv .= "<br/>";
125
        }
126
        $buffer_eaptypediv .= "</div>";
127
128
        $buffer_headline = "<span style='float:right;'>";
129
        $readiness = $theProfile->readinessLevel();
130
        if ($has_overrides) {
131
            $buffer_headline .= $uiElements->boxRemark("", _("Option override on profile level is in effect."), TRUE);
132
        }
133
        if (!$allcomplete) {
134
            $buffer_headline .= $uiElements->boxError("", _("The information in this profile is incomplete."), TRUE);
135
        }
136
        switch ($readiness) {
137
            case core\AbstractProfile::READINESS_LEVEL_SHOWTIME:
138
                $buffer_headline .= $uiElements->boxOkay("", _("This profile is shown on the user download interface."), TRUE);
139
                break;
140
            case core\AbstractProfile::READINESS_LEVEL_SUFFICIENTCONFIG:
141
                $buffer_headline .= $uiElements->boxWarning("", sprintf(_("This profile is NOT shown on the user download interface, even though we have enough information to show. To enable the profile, add the attribute \"%s\" and tick the corresponding box."), $uiElements->displayName("profile:production")), TRUE);
142
        }
143
144
        $buffer_headline .= "</span></div>";
145
146
        echo $buffer_headline;
147
        echo $buffer_eaptypediv;
148
149
        $has_eaptypes = count($theProfile->getEapMethodsInOrderOfPreference(1));
150
        $hasRealmArray = $theProfile->getAttributes("internal:realm");
151
        $has_realm = $hasRealmArray[0]['value'];
152
153
        // our own base location, to give to diag URLs
154
        if (isset($_SERVER['HTTPS'])) {
155
            $link = 'https://';
156
        } else {
157
            $link = 'http://';
158
        }
159
        $link .= $_SERVER['SERVER_NAME'];
160
        ?>
161
        <div class='profilemodulebuttons' style='float:right;'>
162
            <?php
163
            if (\config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] !== NULL) {
164
                if (\config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] == "LOCAL") {
165
                    $diagUrl = "../diag/";
166
                } else {
167
                    $diagUrl = \config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] . "/diag/";
168
                }
169
                ?>
170
                <form action='<?php echo $diagUrl . "action_realmcheck.php?inst_id=" . $theProfile->institution . "&profile_id=" . $theProfile->identifier ?>' method='post' accept-charset='UTF-8'>
171
                    <input type='hidden' name='comefrom' value='<?php echo htmlspecialchars($link . $_SERVER['SCRIPT_NAME']); ?>'/>
172
                    <button type='submit' name='profile_action' value='check' <?php echo ($has_realm ? "" : "disabled='disabled'"); ?> title='<?php echo _("The realm can only be checked if you configure the realm!"); ?>'>
173
                        <?php echo _("Check realm reachability"); ?>
174
                    </button>
175
                </form>
176
                <?php
177
            }
178
            ?>
179
            <form action='overview_installers.php?inst_id=<?php echo $theProfile->institution; ?>&amp;profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'>
180
                <button type='submit' name='profile_action' value='check' <?php echo ($has_eaptypes ? "" : "disabled='disabled'"); ?> title='<?php echo _("You have not fully configured any supported EAP types!"); ?>'>
181
                    <?php echo _("Installer Fine-Tuning and Download"); ?>
182
                </button>
183
            </form>
184
        </div>
185
        <div class='buttongroupprofilebox' style='clear:both; display: flex;'>
186
            <?php if ($readonly === FALSE) { ?>
187
                <div style='margin-right: 200px;'>
188
                    <form action='edit_profile.php?inst_id=<?php echo $theProfile->institution; ?>&amp;profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'>
189
                        <hr/>
190
                        <button type='submit' name='profile_action' value='edit'><?php echo _("Edit"); ?></button>
191
                    </form>
192
                    <form action='edit_profile_result.php?inst_id=<?php echo $theProfile->institution; ?>&amp;profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'>
193
                        <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_DELETE; ?>' onclick="return confirm('<?php echo sprintf(_("Do you really want to delete the profile %s?"), $profile_name); ?>')">
194
                            <?php echo _("Delete") ?>
195
                        </button>
196
                    </form>
197
                </div>
198
                <?php
199
            }
200
            if ($readiness == core\AbstractProfile::READINESS_LEVEL_SHOWTIME) {
201
                ?>
202
                <div style='display: flex;'>
203
                    <?php
204
                    $idpLevelUrl = $link . dirname(dirname($_SERVER['SCRIPT_NAME'])) . "?idp=" . $theProfile->institution;
205
                    $displayurl = $idpLevelUrl . "&amp;profile=" . $theProfile->identifier;
206
                    $QRurl = $idpLevelUrl . "&profile=" . $theProfile->identifier;
207
                    $qrCode = new \chillerlan\QRCode\QRCode(new \chillerlan\QRCode\QROptions([
208
                                'outputType' => \chillerlan\QRCode\QRCode::OUTPUT_IMAGE_PNG,
209
                                'eccLevel' => \chillerlan\QRCode\QRCode::ECC_H,
210
                                'scale' => web\lib\admin\UIElements::QRCODE_PIXELS_PER_SYMBOL,
211
                                'imageBase64' => false,
212
                    ]));
213
                    echo "<a href='$displayurl' style='white-space: nowrap; text-align: center;'>";
214
                    $rawQr = $qrCode->render($QRurl);
215
                    if (empty($rawQr)) {
216
                        throw new Exception("Something went seriously wrong during QR code generation!");
217
                    }
218
                    $uri = "data:image/png;base64," . base64_encode($uiElements->pngInjectConsortiumLogo($rawQr, web\lib\admin\UIElements::QRCODE_PIXELS_PER_SYMBOL));
219
                    $size = getimagesize($uri);
220
                    echo "<img width='" . ($size[0] / 4) . "' height='" . ($size[1] / 4) . "' src='$uri' alt='QR-code'/>";
221
222
                    //echo "<nobr>$displayurl</nobr></a>";
223
                    echo "<p>$displayurl</p></a>";
224
                    ?>
225
                </div>
226
                <?php
227
            }
228
            ?>
229
        </div>
230
    </div>
231
    <?php
232
}
233
234
function displayDeploymentPropertyWidget(&$deploymentObject) {
235
    $radius_status = array();
236
    $radius_status[0] = $deploymentObject->radius_status_1;
237
    $radius_status[1] = $deploymentObject->radius_status_2;
238
    $retry = $deploymentObject->checkRADIUSHostandConfigDaemon();
239
    if (is_array($retry)) {
240
        foreach ($retry as $id => $stat) {
241
            if ($stat) {
242
                $response = $deploymentObject->setRADIUSconfig($id, 1);
0 ignored issues
show
Unused Code introduced by
The assignment to $response is dead and can be removed.
Loading history...
243
            }
244
        }
245
    }
246
    ?>
247
    <div style='display: table-row;'>
248
        <div class='profilebox' style='display: table-cell;'>
249
            <h2><?php
250
                switch ($deploymentObject->consortium) {
251
                    case "eduroam":
252
                        $displayname = config\ConfAssistant::CONSORTIUM['name'] . " " . core\DeploymentManaged::PRODUCTNAME;
253
                        break;
254
                    case "OpenRoaming":
255
                        $displayname = "OpenRoaming ANP";
256
                        break;
257
                    default:
258
                        throw new Exception("We are supposed to operate on a roaming consortium we don't know.");
259
                }
260
                echo $displayname . " (<span style='color:" . ( $deploymentObject->status == \core\AbstractDeployment::INACTIVE ? "red;'>" . _("inactive") : "green;'>" . _("active") ) . "</span>)";
261
                ?></h2>
262
            <table>
263
                <caption><?php echo _("Deployment Details"); ?></caption>
264
                <tr>
265
                    <th class='wai-invisible' scope='col'><?php echo("Server IP addresses"); ?></th>
266
                    <th class='wai-invisible' scope='col'><?php echo("Server Port label"); ?></th>
267
                    <th class='wai-invisible' scope='col'><?php echo("Server Port value"); ?></th>
268
                    <th class='wai-invisible' scope='col'><?php echo("Deployment Status"); ?></th>
269
                </tr>
270
                <tr>
271
                    <td><strong><?php echo _("Your primary RADIUS server") ?></strong><br/>
272
                        <?php
273
                        if ($deploymentObject->host1_v4 !== NULL) {
274
                            echo _("IPv4") . ": " . $deploymentObject->host1_v4;
275
                        }
276
                        if ($deploymentObject->host1_v4 !== NULL && $deploymentObject->host1_v6 !== NULL) {
277
                            echo "<br/>";
278
                        }
279
                        if ($deploymentObject->host1_v6 !== NULL) {
280
                            echo _("IPv6") . ": " . $deploymentObject->host1_v6;
281
                        }
282
                        ?>
283
                    </td>
284
                    <td><?php echo _("RADIUS port number: ") ?></td>
285
                    <td><?php echo $deploymentObject->port1; ?></td>
286
                    <td>
287
                        <?php
288
                        echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_1]['icon'] .
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $radiusMessages seems to be never defined.
Loading history...
289
                        "' alt='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] .
290
                        "' title='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . "'>";
291
                        ?>
292
                    </td>
293
                </tr>
294
                <tr>
295
                    <td><strong><?php echo _("Your backup RADIUS server") ?><br/></strong>
296
                        <?php
297
                        if ($deploymentObject->host2_v4 !== NULL) {
298
                            echo _("IPv4") . ": " . $deploymentObject->host2_v4;
299
                        }
300
                        if ($deploymentObject->host2_v4 !== NULL && $deploymentObject->host2_v6 !== NULL) {
301
                            echo "<br/>";
302
                        }
303
                        if ($deploymentObject->host2_v6 !== NULL) {
304
                            echo _("IPv6") . ": " . $deploymentObject->host2_v6;
305
                        }
306
                        ?></td>
307
                    <td><?php echo _("RADIUS port number: ") ?></td>
308
                    <td><?php echo $deploymentObject->port2; ?></td>
309
                    <td>
310
                        <?php
311
                        echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_2]['icon'] .
312
                        "' alt='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] .
313
                        "' title='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . "'>";
314
                        ?>
315
                    </td>
316
                </tr>
317
318
                <tr>
319
                    <td><strong><?php echo _("RADIUS shared secret"); ?></strong></td>
320
                    <td><?php echo $deploymentObject->secret; ?></td>
321
                </tr>
322
                <tr><td colspan="4"><hr></td></tr>
323
                <?php if ($opname = $deploymentObject->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { ?>
324
                    <tr>
325
                        <td><strong><?php echo _("Custom Operator-Name"); ?></strong></td>
326
                        <td><?php echo $opname; ?></td>
327
                    </tr>
328
                    <?php
329
                }
330
                if ($vlan = $deploymentObject->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) {
331
                    ?>
332
                    <tr>
333
                        <td><strong><?php echo _("VLAN tag for own users"); ?></strong></td>
334
                        <td><?php echo $vlan; ?></td>
335
                    </tr>
336
                <?php } ?>
337
                <?php
338
                $allRealms = array_values(array_unique(array_column($deploymentObject->getAttributes("managedsp:realmforvlan"), "value")));
339
                if (!empty($allRealms)) {
340
                    ?>
341
                    <tr>
342
                        <td><strong><?php echo _("Realm to be considered own users"); ?></strong></td>
343
                        <td><?php echo implode(', ', $allRealms); ?></td>
344
                    </tr>
345
                    <?php
346
                }
347
                ?>
348
            </table>
349
            <div class='buttongroupprofilebox' style='clear:both;'>
350
                <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $my_inst seems to be never defined.
Loading history...
351
                    <br/>
352
                    <button type='submit' name='profile_action' style='cursor:pointer;' value='edit'><?php echo _("Advanced Configuration"); ?></button>
353
                </form>
354
                <?php if ($deploymentObject->status == \core\AbstractDeployment::ACTIVE) { ?>
355
                    <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
356
                        <button class='delete' type='submit' style='cursor:pointer;' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_DELETE; ?>' onclick="return confirm('<?php printf(_("Do you really want to deactivate the %s deployment?"), core\DeploymentManaged::PRODUCTNAME); ?>')">
357
                            <?php echo _("Deactivate"); ?>
358
                        </button>
359
                        <?php
360
                        if (isset($_GET['res']) && is_array($_GET['res'])) {
361
                            $res = array_count_values($_GET['res']);
362
                            if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) {
363
                                echo '<br>';
364
                                if ($res['FAILURE'] == 2) {
365
                                    echo ' <span style="color: red;">' . _("Activation failure.") . '</span>';
366
                                } else {
367
                                    if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
368
                                        echo ' <span style="color: red;">' . _("Activation failure for your primary RADIUS server.") . '</span>';
369
                                    } else {
370
                                        echo ' <span style="color: red;">' . _("Activation failure for your backup RADIUS server.") . '</span>';
371
                                    }
372
                                }
373
                            }
374
                        }
375
                        ?>
376
                    </form>
377
                    <?php
378
                } else {
379
                    ?>
380
                    <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
381
                        <button class='delete' style='background-color: green;' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_ACTIVATE; ?>'>
382
                            <?php echo _("Activate"); ?>
383
                        </button>
384
                        <?php
385
                        if (isset($_GET['res']) && is_array($_GET['res'])) {
386
                            $res = array_count_values($_GET['res']);
387
                            if ($res['FAILURE'] > 0) {
388
                                echo '<br>';
389
                                if ($res['FAILURE'] == 2) {
390
                                    echo ' <span style="color: red;">' . _("Failure during deactivation, your request is queued for handling") . '</span>';
391
                                } else {
392
                                    if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
393
                                        echo ' <span style="color: red;">' . _("Deactivation failure for your primary RADIUS server, your request is queued.") . '</span>';
394
                                    } else {
395
                                        echo ' <span style="color: red;">' . _("Deactivation failure for your backup RADIUS server, your request is queued.") . '</span>';
396
                                    }
397
                                }
398
                            }
399
                        }
400
                        ?>
401
                    </form>
402
                    <?php
403
                }
404
                ?>
405
            </div>
406
        </div>
407
        <div style='width:20px;'></div> <!-- QR code space, reserved -->
408
        <div style='display: table-cell; min-width:200px;'></div> <!-- statistics space, reserved -->
409
    </div>
410
    <!-- dummy div to keep a little distance-->
411
    <div style='height:20px'></div>
412
    <?php
413
}
414
415
$deco = new \web\lib\admin\PageDecoration();
416
$validator = new \web\lib\common\InputValidation();
417
$uiElements = new web\lib\admin\UIElements();
418
419
echo $deco->defaultPagePrelude(sprintf(_("%s: %s Dashboard"), \config\Master::APPEARANCE['productname'], $uiElements->nomenclatureParticipant));
420
require_once "inc/click_button_js.php";
421
422
// RADIUS status icons
423
$radiusMessages = [
424
    \core\AbstractDeployment::RADIUS_OK => ['icon' => '../resources/images/icons/Quetto/check-icon.png', 'text' => _("Successfully set profile")],
425
    \core\AbstractDeployment::RADIUS_FAILURE => ['icon' => '../resources/images/icons/Quetto/no-icon.png', 'text' => _("Some problem occured during profile update")],
426
];
427
428
// let's check if the inst handle actually exists in the DB
429
$my_inst = $validator->existingIdP($_GET['inst_id'], $_SESSION['user']);
430
$myfed = new \core\Federation($my_inst->federation);
431
432
// delete stored realm
433
434
if (isset($_SESSION['check_realm'])) {
435
    unset($_SESSION['check_realm']);
436
}
437
$mapCode = web\lib\admin\AbstractMap::instance($my_inst, TRUE);
438
echo $mapCode->htmlHeadCode();
439
?>
440
</head>
441
<body <?php echo $mapCode->bodyTagCode(); ?>>
442
    <?php
443
    echo $deco->productheader("ADMIN-PARTICIPANT");
444
445
// Sanity check complete. Show what we know about this IdP.
446
    $idpoptions = $my_inst->getAttributes();
447
    ?>
448
    <h1><?php echo sprintf(_("%s Overview"), $uiElements->nomenclatureParticipant); ?></h1>
449
    <hr/>
450
    <div>
451
        <h2 style='display: flex;'><?php echo sprintf(_("%s general settings"), $uiElements->nomenclatureParticipant); ?>&nbsp;
452
            <form action='edit_participant.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
453
                <button type='submit' name='submitbutton' value='<?php echo \web\lib\common\FormElements::BUTTON_EDIT; ?>'><?php echo _("Edit ..."); ?></button>
454
            </form>
455
        </h2>
456
        <?php
457
        echo $uiElements->instLevelInfoBoxes($my_inst);
458
        ?>
459
        <?php
460
        foreach ($idpoptions as $optionname => $optionvalue) {
461
            if ($optionvalue['name'] == "general:geo_coordinates") {
462
                echo '<div class="infobox">';
463
                echo $mapCode->htmlShowtime();
464
                echo '</div>';
465
                break;
466
            }
467
        }
468
        ?>
469
470
    </div>
471
    <hr/>
472
    <?php if (preg_match("/IdP/", $my_inst->type)) { ?>
473
        <h2 style='display: flex;'><?php printf(_("%s: %s Deployment Details"), $uiElements->nomenclatureParticipant, $uiElements->nomenclatureIdP); ?>&nbsp;
474
            <?php
475
            $readonly = \config\Master::DB['INST']['readonly'];
476
            $profiles_for_this_idp = $my_inst->listProfiles();
477
            if ($readonly === FALSE) {
478
479
                // the opportunity to add a new silverbullet profile is only shown if
480
                // a) there is no SB profile yet
481
                // b) federation wants this to happen
482
                // first find out if we already have SB profiles
483
                $sbProfileExists = FALSE;
484
                foreach ($profiles_for_this_idp as $profilecount => $profile_list) {
485
                    switch (get_class($profile_list)) {
486
                        case "core\ProfileSilverbullet":
487
                            $sbProfileExists = TRUE;
488
                            break;
489
                        default:
490
                    }
491
                }
492
493
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0 && $sbProfileExists === FALSE) {
494
                    // the button is grayed out if there's no support email address configured...
495
                    $hasMail = count($my_inst->getAttributes("support:email"));
496
                    ?>
497
                    <form action='edit_silverbullet.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
498
                        <div>
499
                            <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
500
                                <?php echo sprintf(_("Add %s profile ..."), \core\ProfileSilverbullet::PRODUCTNAME); ?>
501
                            </button>
502
                        </div>
503
                    </form>&nbsp;
504
                    <?php
505
                }
506
                ?>
507
508
                <?php
509
                // adding a normal profile is always possible if we're configured for it
510
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_RADIUS'] == "LOCAL") {
511
                    ?>
512
                    <form action='edit_profile.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
513
                        <div>
514
                            <button type='submit' name='profile_action' value='new'>
515
                                <?php echo _("New RADIUS/EAP profile (manual setup) ..."); ?>
516
                            </button>
517
                        </div>
518
                    </form>&nbsp;
519
                    <form action='edit_profile.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
520
                        <div>
521
                            <button type='submit' name='profile_action' value='new'>
522
                                <?php echo _("New RADIUS/EAP profile (autodetect server details) ..."); ?>
523
                            </button>
524
                        </div>
525
                    </form>
526
                    <?php
527
                }
528
            }
529
            ?>
530
        </h2>
531
        <?php
532
        if (count($profiles_for_this_idp) == 0) { // no profiles yet.
533
            printf(_("There are not yet any profiles for your %s."), $uiElements->nomenclatureIdP);
534
        }
535
// if there is one profile and it is of type Silver Bullet, display a very
536
// simple widget with just a "Manage" button
537
        foreach ($profiles_for_this_idp as $profilecount => $profile_list) {
538
            ?>
539
            <div style='display: table-row; margin-bottom: 20px;'>
540
                <div class='profilebox' style='display: table-cell; min-width: 650px;'>
541
                    <?php
542
                    switch (get_class($profile_list)) {
543
                        case "core\ProfileSilverbullet":
544
                            displaySilverbulletPropertyWidget($profile_list, $readonly, $uiElements);
545
                            break;
546
                        case "core\ProfileRADIUS":
547
                            displayRadiusPropertyWidget($profile_list, $readonly, $uiElements);
548
                            break;
549
                        default:
550
                            throw new Exception("We were asked to operate on something that is neither a RADIUS nor Silverbullet profile!");
551
                    }
552
                    ?>
553
                </div>
554
                <!-- dummy width to keep a little distance -->
555
                <div style='width:20px;'></div>
556
                <div style='display: table-cell; min-width:200px;'>
557
                    <p>
558
                        <strong><?php echo _("User Downloads"); ?></strong>
559
                    </p>
560
                    <table>
561
                        <?php
562
                        $stats = $profile_list->getUserDownloadStats();
563
                        foreach ($stats as $dev => $count) {
564
                            echo "<tr><td><strong>$dev</strong></td><td>$count</td></tr>";
565
                        }
566
                        ?>
567
                    </table>
568
                </div>
569
            </div>
570
            <!-- dummy div to keep a little distance-->
571
            <div style='height:20px'></div>
572
            <?php
573
        }
574
        ?>
575
        <hr/>
576
        <?php
577
    }
578
    if (preg_match("/SP/", $my_inst->type)) {
579
        ?>
580
        <h2 style='display: flex;'><?php printf(_("%s: %s Deployment Details"), $uiElements->nomenclatureParticipant, $uiElements->nomenclatureHotspot); ?>&nbsp;
581
            <?php
582
            if ($readonly === FALSE) {
583
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0) {
584
                    // the button is grayed out if there's no support email address configured...
585
                    $hasMail = count($my_inst->getAttributes("support:email"));
586
                    ?>
587
                    <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
588
                        <div>
589
                            <input type="hidden" name="consortium" value="eduroam"/>
590
                            <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
591
                                <?php echo sprintf(_("Add %s deployment ..."), \config\ConfAssistant::CONSORTIUM['name'] . " " . \core\DeploymentManaged::PRODUCTNAME); ?>
592
                            </button>
593
594
                        </div>
595
                    </form>
596
                    <?php if (count($myfed->getAttributes("fed:openroaming")) > 0) {
597
                        ?>
598
                        &nbsp;
599
                        <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
600
                            <div>
601
                                <input type="hidden" name="consortium" value="OpenRoaming"/>
602
                                <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
603
                                    <?php echo sprintf(_("Add %s deployment ..."), "OpenRoaming ANP"); ?>
604
                                </button>
605
606
                            </div>
607
                        </form>
608
                        <?php
609
                    }
610
                }
611
            }
612
            ?>
613
        </h2>
614
        <?php
615
        $hotspotProfiles = $my_inst->listDeployments();
616
        if (count($hotspotProfiles) == 0) { // no profiles yet.
617
            echo sprintf(_("There are not yet any known deployments for your %s."), $uiElements->nomenclatureHotspot);
618
        }
619
620
        foreach ($hotspotProfiles as $counter => $deploymentObject) {
621
            displayDeploymentPropertyWidget($deploymentObject);
622
        }
623
    }
624
    echo $deco->footer();
625