Test Setup Failed
Push — master ( 47156c...cfde7f )
by Stefan
06:38
created

displayClassicHotspotPropertyWidget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 1
rs 10
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 $theProfile->institution; ?>&amp;profile_id=<?php echo $theProfile->identifier; ?>' method='POST'>
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
/**
235
 * displays an infocard about a Managed SP deployment
236
 * 
237
 * @param \core\DeploymentManaged $deploymentObject the deployment to work with
238
 * @throws Exception
239
 */
240
function displayDeploymentPropertyWidget(&$deploymentObject) {
241
    // RADIUS status icons
242
    $radiusMessages = [
243
        \core\AbstractDeployment::RADIUS_OK => ['icon' => '../resources/images/icons/Quetto/check-icon.png', 'text' => _("Successfully set profile")],
244
        \core\AbstractDeployment::RADIUS_FAILURE => ['icon' => '../resources/images/icons/Quetto/no-icon.png', 'text' => _("Some problem occured during profile update")],
245
    ];
246
247
    $radius_status = array();
248
    $radius_status[0] = $deploymentObject->radius_status_1;
249
    $radius_status[1] = $deploymentObject->radius_status_2;
250
    $retry = $deploymentObject->checkRADIUSHostandConfigDaemon();
251
    if (is_array($retry)) {
252
        foreach ($retry as $id => $stat) {
253
            if ($stat) {
254
                $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...
255
            }
256
        }
257
    }
258
    ?>
259
    <div style='display: table-row;'>
260
        <div class='profilebox' style='display: table-cell;'>
261
            <h2><?php
262
                switch ($deploymentObject->consortium) {
263
                    case "eduroam":
264
                        $displayname = config\ConfAssistant::CONSORTIUM['name'] . " " . core\DeploymentManaged::PRODUCTNAME;
265
                        break;
266
                    case "OpenRoaming":
267
                        $displayname = "OpenRoaming ANP";
268
                        break;
269
                    default:
270
                        throw new Exception("We are supposed to operate on a roaming consortium we don't know.");
271
                }
272
                echo $displayname . " (<span style='color:" . ( $deploymentObject->status == \core\AbstractDeployment::INACTIVE ? "red;'>" . _("inactive") : "green;'>" . _("active") ) . "</span>)";
273
                ?></h2>
274
            <table>
275
                <caption><?php echo _("Deployment Details"); ?></caption>
276
                <tr>
277
                    <th class='wai-invisible' scope='col'><?php echo("Server IP addresses"); ?></th>
278
                    <th class='wai-invisible' scope='col'><?php echo("Server Port label"); ?></th>
279
                    <th class='wai-invisible' scope='col'><?php echo("Server Port value"); ?></th>
280
                    <th class='wai-invisible' scope='col'><?php echo("Deployment Status"); ?></th>
281
                </tr>
282
                <tr>
283
                    <td><strong><?php echo _("Your primary RADIUS server") ?></strong><br/>
284
                        <?php
285
                        if ($deploymentObject->host1_v4 !== NULL) {
286
                            echo _("IPv4") . ": " . $deploymentObject->host1_v4;
287
                        }
288
                        if ($deploymentObject->host1_v4 !== NULL && $deploymentObject->host1_v6 !== NULL) {
289
                            echo "<br/>";
290
                        }
291
                        if ($deploymentObject->host1_v6 !== NULL) {
292
                            echo _("IPv6") . ": " . $deploymentObject->host1_v6;
293
                        }
294
                        ?>
295
                    </td>
296
                    <td><?php echo _("RADIUS port number: ") ?></td>
297
                    <td><?php echo $deploymentObject->port1; ?></td>
298
                    <td>
299
                        <?php
300
                        echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_1]['icon'] .
301
                        "' alt='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] .
302
                        "' title='" . $radiusMessages[$deploymentObject->radius_status_1]['text'] . "'>";
303
                        ?>
304
                    </td>
305
                </tr>
306
                <tr>
307
                    <td><strong><?php echo _("Your backup RADIUS server") ?><br/></strong>
308
                        <?php
309
                        if ($deploymentObject->host2_v4 !== NULL) {
310
                            echo _("IPv4") . ": " . $deploymentObject->host2_v4;
311
                        }
312
                        if ($deploymentObject->host2_v4 !== NULL && $deploymentObject->host2_v6 !== NULL) {
313
                            echo "<br/>";
314
                        }
315
                        if ($deploymentObject->host2_v6 !== NULL) {
316
                            echo _("IPv6") . ": " . $deploymentObject->host2_v6;
317
                        }
318
                        ?></td>
319
                    <td><?php echo _("RADIUS port number: ") ?></td>
320
                    <td><?php echo $deploymentObject->port2; ?></td>
321
                    <td>
322
                        <?php
323
                        echo "<img src='" . $radiusMessages[$deploymentObject->radius_status_2]['icon'] .
324
                        "' alt='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] .
325
                        "' title='" . $radiusMessages[$deploymentObject->radius_status_2]['text'] . "'>";
326
                        ?>
327
                    </td>
328
                </tr>
329
330
                <tr>
331
                    <td><strong><?php echo _("RADIUS shared secret"); ?></strong></td>
332
                    <td><?php echo $deploymentObject->secret; ?></td>
333
                </tr>
334
                <tr><td colspan="4"><hr></td></tr>
335
                <?php if ($opname = $deploymentObject->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL) { ?>
336
                    <tr>
337
                        <td><strong><?php echo _("Custom Operator-Name"); ?></strong></td>
338
                        <td><?php echo $opname; ?></td>
339
                    </tr>
340
                    <?php
341
                }
342
                if ($vlan = $deploymentObject->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) {
343
                    ?>
344
                    <tr>
345
                        <td><strong><?php echo _("VLAN tag for own users"); ?></strong></td>
346
                        <td><?php echo $vlan; ?></td>
347
                    </tr>
348
                <?php } ?>
349
                <?php
350
                $allRealms = array_values(array_unique(array_column($deploymentObject->getAttributes("managedsp:realmforvlan"), "value")));
351
                if (!empty($allRealms)) {
352
                    ?>
353
                    <tr>
354
                        <td><strong><?php echo _("Realm to be considered own users"); ?></strong></td>
355
                        <td><?php echo implode(', ', $allRealms); ?></td>
356
                    </tr>
357
                    <?php
358
                }
359
                ?>
360
            </table>
361
            <div class='buttongroupprofilebox' style='clear:both;'>
362
                <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
363
                    <br/>
364
                    <button type='submit' name='profile_action' style='cursor:pointer;' value='edit'><?php echo _("Advanced Configuration"); ?></button>
365
                </form>
366
                <?php if ($deploymentObject->status == \core\AbstractDeployment::ACTIVE) { ?>
367
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
368
                        <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); ?>')">
369
                            <?php echo _("Deactivate"); ?>
370
                        </button>
371
                        <?php
372
                        if (isset($_GET['res']) && is_array($_GET['res'])) {
373
                            $res = array_count_values($_GET['res']);
374
                            if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) {
375
                                echo '<br>';
376
                                if ($res['FAILURE'] == 2) {
377
                                    echo ' <span style="color: red;">' . _("Activation failure.") . '</span>';
378
                                } else {
379
                                    if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
380
                                        echo ' <span style="color: red;">' . _("Activation failure for your primary RADIUS server.") . '</span>';
381
                                    } else {
382
                                        echo ' <span style="color: red;">' . _("Activation failure for your backup RADIUS server.") . '</span>';
383
                                    }
384
                                }
385
                            }
386
                        }
387
                        ?>
388
                    </form>
389
                    <?php
390
                } else {
391
                    ?>
392
                    <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&amp;deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'>
393
                        <button class='delete' style='background-color: green;' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_ACTIVATE; ?>'>
394
                            <?php echo _("Activate"); ?>
395
                        </button>
396
                        <?php
397
                        if (isset($_GET['res']) && is_array($_GET['res'])) {
398
                            $res = array_count_values($_GET['res']);
399
                            if ($res['FAILURE'] > 0) {
400
                                echo '<br>';
401
                                if ($res['FAILURE'] == 2) {
402
                                    echo ' <span style="color: red;">' . _("Failure during deactivation, your request is queued for handling") . '</span>';
403
                                } else {
404
                                    if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') {
405
                                        echo ' <span style="color: red;">' . _("Deactivation failure for your primary RADIUS server, your request is queued.") . '</span>';
406
                                    } else {
407
                                        echo ' <span style="color: red;">' . _("Deactivation failure for your backup RADIUS server, your request is queued.") . '</span>';
408
                                    }
409
                                }
410
                            }
411
                        }
412
                        ?>
413
                    </form>
414
                    <?php
415
                }
416
                ?>
417
            </div>
418
        </div>
419
        <div style='width:20px;'></div> <!-- QR code space, reserved -->
420
        <div style='display: table-cell; min-width:200px;'></div> <!-- statistics space, reserved -->
421
    </div>
422
    <!-- dummy div to keep a little distance-->
423
    <div style='height:20px'></div>
424
    <?php
425
}
426
427
/**
428
 * displays a eduroam DB entry for SPs. Not implemented yet.
429
 * 
430
 * @param \core\DeploymentClassic $deploymentObject the deployment to work with
431
 */
432
function displayClassicHotspotPropertyWidget($deploymentObject) {
0 ignored issues
show
Unused Code introduced by
The parameter $deploymentObject is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

432
function displayClassicHotspotPropertyWidget(/** @scrutinizer ignore-unused */ $deploymentObject) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
433
    
434
}
435
436
$deco = new \web\lib\admin\PageDecoration();
437
$validator = new \web\lib\common\InputValidation();
438
$uiElements = new web\lib\admin\UIElements();
439
440
echo $deco->defaultPagePrelude(sprintf(_("%s: %s Dashboard"), \config\Master::APPEARANCE['productname'], $uiElements->nomenclatureParticipant));
441
require_once "inc/click_button_js.php";
442
443
// let's check if the inst handle actually exists in the DB
444
$my_inst = $validator->existingIdP($_GET['inst_id'], $_SESSION['user']);
445
$myfed = new \core\Federation($my_inst->federation);
446
447
// delete stored realm
448
449
if (isset($_SESSION['check_realm'])) {
450
    unset($_SESSION['check_realm']);
451
}
452
$mapCode = web\lib\admin\AbstractMap::instance($my_inst, TRUE);
453
echo $mapCode->htmlHeadCode();
454
?>
455
</head>
456
<body <?php echo $mapCode->bodyTagCode(); ?>>
457
    <?php
458
    echo $deco->productheader("ADMIN-PARTICIPANT");
459
460
// Sanity check complete. Show what we know about this IdP.
461
    $idpoptions = $my_inst->getAttributes();
462
    ?>
463
    <h1><?php echo sprintf(_("%s Overview"), $uiElements->nomenclatureParticipant); ?></h1>
464
    <hr/>
465
    <div>
466
        <h2 style='display: flex;'><?php echo sprintf(_("%s general settings"), $uiElements->nomenclatureParticipant); ?>&nbsp;
467
            <form action='edit_participant.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
468
                <button type='submit' name='submitbutton' value='<?php echo \web\lib\common\FormElements::BUTTON_EDIT; ?>'><?php echo _("Edit ..."); ?></button>
469
            </form>
470
        </h2>
471
        <?php
472
        echo $uiElements->instLevelInfoBoxes($my_inst);
473
        ?>
474
        <?php
475
        foreach ($idpoptions as $optionname => $optionvalue) {
476
            if ($optionvalue['name'] == "general:geo_coordinates") {
477
                echo '<div class="infobox">';
478
                echo $mapCode->htmlShowtime();
479
                echo '</div>';
480
                break;
481
            }
482
        }
483
        ?>
484
485
    </div>
486
    <hr/>
487
    <?php if (preg_match("/IdP/", $my_inst->type)) { ?>
488
        <h2 style='display: flex;'><?php printf(_("%s: %s Deployment Details"), $uiElements->nomenclatureParticipant, $uiElements->nomenclatureIdP); ?>&nbsp;
489
            <?php
490
            $readonly = \config\Master::DB['INST']['readonly'];
491
            $profiles_for_this_idp = $my_inst->listProfiles();
492
            if ($readonly === FALSE) {
493
494
                // the opportunity to add a new silverbullet profile is only shown if
495
                // a) there is no SB profile yet
496
                // b) federation wants this to happen
497
                // first find out if we already have SB profiles
498
                $sbProfileExists = FALSE;
499
                foreach ($profiles_for_this_idp as $profilecount => $profile_list) {
500
                    switch (get_class($profile_list)) {
501
                        case "core\ProfileSilverbullet":
502
                            $sbProfileExists = TRUE;
503
                            break;
504
                        default:
505
                    }
506
                }
507
508
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0 && $sbProfileExists === FALSE) {
509
                    // the button is grayed out if there's no support email address configured...
510
                    $hasMail = count($my_inst->getAttributes("support:email"));
511
                    ?>
512
                    <form action='edit_silverbullet.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
513
                        <div>
514
                            <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
515
                                <?php echo sprintf(_("Add %s profile ..."), \core\ProfileSilverbullet::PRODUCTNAME); ?>
516
                            </button>
517
                        </div>
518
                    </form>&nbsp;
519
                    <?php
520
                }
521
                ?>
522
523
                <?php
524
                // adding a normal profile is always possible if we're configured for it
525
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_RADIUS'] == "LOCAL") {
526
                    ?>
527
                    <form action='edit_profile.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
528
                        <div>
529
                            <button type='submit' name='profile_action' value='new'>
530
                                <?php echo _("New RADIUS/EAP profile (manual setup) ..."); ?>
531
                            </button>
532
                        </div>
533
                    </form>&nbsp;
534
                    <form action='edit_profile.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
535
                        <div>
536
                            <button type='submit' name='profile_action' value='new'>
537
                                <?php echo _("New RADIUS/EAP profile (autodetect server details) ..."); ?>
538
                            </button>
539
                        </div>
540
                    </form>
541
                    <?php
542
                }
543
            }
544
            ?>
545
        </h2>
546
        <?php
547
        if (count($profiles_for_this_idp) == 0) { // no profiles yet.
548
            printf(_("There are not yet any profiles for your %s."), $uiElements->nomenclatureIdP);
549
        }
550
// if there is one profile and it is of type Silver Bullet, display a very
551
// simple widget with just a "Manage" button
552
        foreach ($profiles_for_this_idp as $profilecount => $profile_list) {
553
            ?>
554
            <div style='display: table-row; margin-bottom: 20px;'>
555
                <div class='profilebox' style='display: table-cell; min-width: 650px;'>
556
                    <?php
557
                    switch (get_class($profile_list)) {
558
                        case "core\ProfileSilverbullet":
559
                            displaySilverbulletPropertyWidget($profile_list, $readonly, $uiElements);
560
                            break;
561
                        case "core\ProfileRADIUS":
562
                            displayRadiusPropertyWidget($profile_list, $readonly, $uiElements);
563
                            break;
564
                        default:
565
                            throw new Exception("We were asked to operate on something that is neither a RADIUS nor Silverbullet profile!");
566
                    }
567
                    ?>
568
                </div>
569
                <!-- dummy width to keep a little distance -->
570
                <div style='width:20px;'></div>
571
                <div style='display: table-cell; min-width:200px;'>
572
                    <p>
573
                        <strong><?php echo _("User Downloads"); ?></strong>
574
                    </p>
575
                    <table>
576
                        <?php
577
                        $stats = $profile_list->getUserDownloadStats();
578
                        foreach ($stats as $dev => $count) {
579
                            echo "<tr><td><strong>$dev</strong></td><td>$count</td></tr>";
580
                        }
581
                        ?>
582
                    </table>
583
                </div>
584
            </div>
585
            <!-- dummy div to keep a little distance-->
586
            <div style='height:20px'></div>
587
            <?php
588
        }
589
        ?>
590
        <hr/>
591
        <?php
592
    }
593
    if (preg_match("/SP/", $my_inst->type)) {
594
        ?>
595
        <h2 style='display: flex;'><?php printf(_("%s: %s Deployment Details"), $uiElements->nomenclatureParticipant, $uiElements->nomenclatureHotspot); ?>&nbsp;
596
            <?php
597
            if ($readonly === FALSE) {
598
                if (\config\Master::FUNCTIONALITY_LOCATIONS['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && count($myfed->getAttributes("fed:silverbullet")) > 0) {
599
                    // the button is grayed out if there's no support email address configured...
600
                    $hasMail = count($my_inst->getAttributes("support:email"));
601
                    ?>
602
                    <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
603
                        <div>
604
                            <input type="hidden" name="consortium" value="eduroam"/>
605
                            <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
606
                                <?php echo sprintf(_("Add %s deployment ..."), \config\ConfAssistant::CONSORTIUM['name'] . " " . \core\DeploymentManaged::PRODUCTNAME); ?>
607
                            </button>
608
609
                        </div>
610
                    </form>
611
                    <?php if (count($myfed->getAttributes("fed:openroaming")) > 0) {
612
                        ?>
613
                        &nbsp;
614
                        <form action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>' method='post' accept-charset='UTF-8'>
615
                            <div>
616
                                <input type="hidden" name="consortium" value="OpenRoaming"/>
617
                                <button type='submit' <?php echo ($hasMail > 0 ? "" : "disabled"); ?> name='profile_action' value='new'>
618
                                    <?php echo sprintf(_("Add %s deployment ..."), "OpenRoaming ANP"); ?>
619
                                </button>
620
621
                            </div>
622
                        </form>
623
                        <?php
624
                    }
625
                }
626
            }
627
            ?>
628
        </h2>
629
        <?php
630
        $hotspotProfiles = $my_inst->listDeployments();
631
        if (count($hotspotProfiles) == 0) { // no profiles yet.
632
            echo sprintf(_("There are not yet any known deployments for your %s."), $uiElements->nomenclatureHotspot);
633
        }
634
635
        foreach ($hotspotProfiles as $counter => $deploymentObject) {
636
            switch (get_class($deploymentObject)) {
637
                case "core\DeploymentManaged":
638
                    displayDeploymentPropertyWidget($deploymentObject);
639
                    break;
640
                case "core\DeploymentClassic":
641
                    displayClassicHotspotPropertyWidget($deploymentObject);
642
                    break;
643
                default:
644
                    throw new Exception("We were asked to operate on something that is neither a classic nor a Managed hotspot deployment!");
645
            }
646
        }
647
    }
648
    echo $deco->footer();
649