| Conditions | 31 |
| Paths | > 20000 |
| Total Lines | 189 |
| Code Lines | 153 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 82 | function displayRadiusPropertyWidget(&$theProfile, $readonly, &$uiElements, $editMode) { |
||
| 83 | ?> |
||
| 84 | <div style='padding-bottom:20px;'> |
||
| 85 | <?php $profile_name = $theProfile->name; ?> |
||
| 86 | <div style='margin-bottom:10px; display:block;'> |
||
| 87 | <h2 style='overflow:auto; display:inline; padding-bottom: 10px;'><?php printf(_("Profile: %s"), $profile_name); ?></h2> |
||
| 88 | </div> |
||
| 89 | <?php |
||
| 90 | // see if there are any profile-level overrides |
||
| 91 | $attribs = $theProfile->getAttributes(); |
||
| 92 | // write things into a buffer; we need some function calls to determine |
||
| 93 | // readiness - but want to display it before! |
||
| 94 | $has_overrides = FALSE; |
||
| 95 | foreach ($attribs as $attrib) { |
||
| 96 | if ($attrib['level'] == \core\Options::LEVEL_PROFILE && !preg_match("/^(internal:|profile:name|profile:description|profile:production|eap:)/", $attrib['name'])) { |
||
| 97 | $has_overrides = TRUE; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | $buffer_eaptypediv = "<div style='margin-bottom:40px; float:left;'>" . _("<strong>EAP Types</strong> (in order of preference):") . "<br/>"; |
||
| 101 | $typelist = $theProfile->getEapMethodsinOrderOfPreference(); |
||
| 102 | $allcomplete = TRUE; |
||
| 103 | foreach ($typelist as $eaptype) { |
||
| 104 | $buffer_eaptypediv .= $eaptype->getPrintableRep(); |
||
| 105 | $completeness = $theProfile->isEapTypeDefinitionComplete($eaptype); |
||
| 106 | if ($completeness === true) { |
||
| 107 | $buffer_eaptypediv .= " <div class='acceptable'>" . _("OK") . "</div>"; |
||
| 108 | } else { |
||
| 109 | $buffer_eaptypediv .= " <div class='notacceptable'>"; |
||
| 110 | $buffer_eaptypediv .= _("Information needed!"); |
||
| 111 | if (is_array($completeness)) { |
||
| 112 | $buffer_eaptypediv .= "<ul style='margin:1px'>"; |
||
| 113 | foreach ($completeness as $missing_attrib) { |
||
| 114 | $buffer_eaptypediv .= "<li>" . $uiElements->displayName($missing_attrib) . "</li>"; |
||
| 115 | } |
||
| 116 | $buffer_eaptypediv .= "</ul>"; |
||
| 117 | } |
||
| 118 | $buffer_eaptypediv .= "</div>"; |
||
| 119 | $allcomplete = FALSE; |
||
| 120 | } |
||
| 121 | $attribs = $theProfile->getAttributes(); |
||
| 122 | $justOnce = FALSE; |
||
| 123 | foreach ($attribs as $attrib) { |
||
| 124 | if ($attrib['level'] == \core\Options::LEVEL_METHOD && !preg_match("/^internal:/", $attrib['name']) && !$justOnce) { |
||
| 125 | $justOnce = TRUE; |
||
| 126 | $buffer_eaptypediv .= "<img src='../resources/images/icons/Tabler/square-rounded-letter-e-blue.svg' alt='" . _("Options on EAP Method/Device level are in effect.") . "'>"; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | $buffer_eaptypediv .= "<br/>"; |
||
| 130 | } |
||
| 131 | $buffer_eaptypediv .= "</div>"; |
||
| 132 | |||
| 133 | $buffer_headline = "<div style='float:right;padding-left:10px'>"; |
||
| 134 | $readiness = $theProfile->readinessLevel(); |
||
| 135 | if ($has_overrides) { |
||
| 136 | $buffer_headline .= $uiElements->boxRemark("", _("Option override on profile level is in effect."), TRUE); |
||
| 137 | } |
||
| 138 | $buffer_headline .= "<br/>"; |
||
| 139 | if (!$allcomplete) { |
||
| 140 | $buffer_headline .= $uiElements->boxError("", _("The information in this profile is incomplete."), TRUE); |
||
| 141 | } |
||
| 142 | switch ($readiness) { |
||
| 143 | case core\AbstractProfile::READINESS_LEVEL_SHOWTIME: |
||
| 144 | $buffer_headline .= $uiElements->boxOkay("", _("This profile is shown on the user download interface."), TRUE); |
||
| 145 | break; |
||
| 146 | case core\AbstractProfile::READINESS_LEVEL_SUFFICIENTCONFIG: |
||
| 147 | $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); |
||
| 148 | } |
||
| 149 | if ($theProfile->isRedirected()) { |
||
| 150 | $iconData = $uiElements->iconData('PROFILES_REDIRECTED'); |
||
| 151 | $iconData['text'] = _("Profile redirected"); |
||
| 152 | $buffer_headline .= "<br/>" . $uiElements->catIcon(($iconData)); |
||
| 153 | |||
| 154 | } |
||
| 155 | |||
| 156 | $certStatus = $theProfile->certificateStatus(); |
||
| 157 | switch ($certStatus) { |
||
| 158 | case core\AbstractProfile::CERT_STATUS_OK: |
||
| 159 | $iconData = $uiElements->iconData('CERT_STATUS_OK'); |
||
| 160 | $buffer_headline .= "<br/>" . $uiElements->catIcon(($iconData)); |
||
| 161 | break; |
||
| 162 | case core\AbstractProfile::CERT_STATUS_WARN: |
||
| 163 | $iconData = $uiElements->iconData('CERT_STATUS_WARN'); |
||
| 164 | $buffer_headline .= "<br/>" . $uiElements->catIcon(($iconData)); |
||
| 165 | break; |
||
| 166 | case core\AbstractProfile::CERT_STATUS_ERROR: |
||
| 167 | $iconData = $uiElements->iconData('CERT_STATUS_ERROR'); |
||
| 168 | $buffer_headline .= "<br/>" . $uiElements->catIcon(($iconData)); |
||
| 169 | break; |
||
| 170 | } |
||
| 171 | $buffer_headline .= "</div>"; |
||
| 172 | |||
| 173 | echo $buffer_headline; |
||
| 174 | echo $buffer_eaptypediv; |
||
| 175 | |||
| 176 | $has_eaptypes = count($theProfile->getEapMethodsInOrderOfPreference(1)); |
||
| 177 | $hasRealmArray = $theProfile->getAttributes("internal:realm"); |
||
| 178 | $has_realm = $hasRealmArray[0]['value']; |
||
| 179 | |||
| 180 | // our own base location, to give to diag URLs |
||
| 181 | if (isset($_SERVER['HTTPS'])) { |
||
| 182 | $link = 'https://'; |
||
| 183 | } else { |
||
| 184 | $link = 'http://'; |
||
| 185 | } |
||
| 186 | $link .= $_SERVER['SERVER_NAME']; |
||
| 187 | ?> |
||
| 188 | <div class='profilemodulebuttons' style='float:right;'> |
||
| 189 | <?php |
||
| 190 | if (\config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] !== NULL) { |
||
| 191 | if (\config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] == "LOCAL") { |
||
| 192 | $diagUrl = "../diag/"; |
||
| 193 | } else { |
||
| 194 | $diagUrl = \config\Master::FUNCTIONALITY_LOCATIONS['DIAGNOSTICS'] . "/diag/"; |
||
| 195 | } |
||
| 196 | ?> |
||
| 197 | <form action='<?php echo $diagUrl . "action_realmcheck.php?inst_id=" . $theProfile->institution . "&profile_id=" . $theProfile->identifier ?>' method='post' accept-charset='UTF-8'> |
||
| 198 | <input type='hidden' name='comefrom' value='<?php echo htmlspecialchars($link . $_SERVER['SCRIPT_NAME']); ?>'/> |
||
| 199 | <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!"); ?>'> |
||
| 200 | <?php echo _("Check realm reachability"); ?> |
||
| 201 | </button> |
||
| 202 | </form> |
||
| 203 | <?php |
||
| 204 | } |
||
| 205 | ?> |
||
| 206 | <form action='overview_installers.php?inst_id=<?php echo $theProfile->institution; ?>&profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 207 | <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!"); ?>'> |
||
| 208 | <?php echo _("Installer Fine-Tuning and Download"); ?> |
||
| 209 | </button> |
||
| 210 | </form> |
||
| 211 | </div> |
||
| 212 | <div class='buttongroupprofilebox' style='clear:both; display: flex;'> |
||
| 213 | <?php |
||
| 214 | if ($editMode == 'readonly') { |
||
| 215 | $editLabel = _("View"); |
||
| 216 | } |
||
| 217 | if ($editMode == 'fullaccess') { |
||
| 218 | $editLabel = _("Edit"); |
||
| 219 | } |
||
| 220 | if ($readonly === FALSE) { ?> |
||
| 221 | <div style='margin-right: 200px; display: ruby'> |
||
| 222 | <form action='edit_profile.php?inst_id=<?php echo $theProfile->institution; ?>&profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 223 | <hr/> |
||
| 224 | <button type='submit' name='profile_action' value='edit'><?php echo $editLabel; ?></button> |
||
|
|
|||
| 225 | </form> |
||
| 226 | <?php if ($editMode == 'fullaccess') { ?> |
||
| 227 | <form action='edit_profile_result.php?inst_id=<?php echo $theProfile->institution; ?>&profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 228 | <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); ?>')"> |
||
| 229 | <?php echo _("Delete") ?> |
||
| 230 | </button> |
||
| 231 | </form> |
||
| 232 | <form action='duplicate_profile.php?inst_id=<?php echo $theProfile->institution; ?>&profile_id=<?php echo $theProfile->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 233 | <button type='submit' name='profile_duplicate'> |
||
| 234 | <?php echo _("Duplicate this profile"); ?> |
||
| 235 | </button> |
||
| 236 | </form> |
||
| 237 | <?php } ?> |
||
| 238 | </div> |
||
| 239 | <?php |
||
| 240 | } |
||
| 241 | if ($readiness == core\AbstractProfile::READINESS_LEVEL_SHOWTIME) { |
||
| 242 | ?> |
||
| 243 | <div style='display: flex;'> |
||
| 244 | <?php |
||
| 245 | $idpLevelUrl = $link . dirname(dirname($_SERVER['SCRIPT_NAME'])) . "?idp=" . $theProfile->institution; |
||
| 246 | $displayurl = $idpLevelUrl . "&profile=" . $theProfile->identifier; |
||
| 247 | $QRurl = $idpLevelUrl . "&profile=" . $theProfile->identifier; |
||
| 248 | $qrCode = new \chillerlan\QRCode\QRCode(new \chillerlan\QRCode\QROptions([ |
||
| 249 | 'outputType' => \chillerlan\QRCode\QRCode::OUTPUT_IMAGE_PNG, |
||
| 250 | 'eccLevel' => \chillerlan\QRCode\QRCode::ECC_H, |
||
| 251 | 'scale' => web\lib\admin\UIElements::QRCODE_PIXELS_PER_SYMBOL, |
||
| 252 | 'imageBase64' => false, |
||
| 253 | ])); |
||
| 254 | echo "<a href='$displayurl' style='white-space: nowrap; text-align: center;'>"; |
||
| 255 | $rawQr = $qrCode->render($QRurl); |
||
| 256 | if (empty($rawQr)) { |
||
| 257 | throw new Exception("Something went seriously wrong during QR code generation!"); |
||
| 258 | } |
||
| 259 | $uri = "data:image/png;base64," . base64_encode($uiElements->pngInjectConsortiumLogo($rawQr, web\lib\admin\UIElements::QRCODE_PIXELS_PER_SYMBOL)); |
||
| 260 | $size = getimagesize($uri); |
||
| 261 | echo "<img width='" . ($size[0] / 4) . "' height='" . ($size[1] / 4) . "' src='$uri' alt='QR-code'/>"; |
||
| 262 | |||
| 263 | //echo "<nobr>$displayurl</nobr></a>"; |
||
| 264 | echo "<p>$displayurl</p></a>"; |
||
| 265 | ?> |
||
| 266 | </div> |
||
| 267 | <?php |
||
| 268 | } |
||
| 269 | ?> |
||
| 270 | </div> |
||
| 271 | </div> |
||
| 492 |