| Conditions | 41 |
| Paths | > 20000 |
| Total Lines | 207 |
| Code Lines | 175 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 58 | function displayDeploymentPropertyWidget(&$deploymentObject, $errormsg=[], $editMode) { |
||
|
|
|||
| 59 | // RADIUS status icons |
||
| 60 | $depId = $deploymentObject->identifier; |
||
| 61 | $radiusMessages = [ |
||
| 62 | \core\AbstractDeployment::RADIUS_OK => ['icon' => '../resources/images/icons/Tabler/square-rounded-check-filled-green.svg', 'text' => _("Successfully set profile")], |
||
| 63 | \core\AbstractDeployment::RADIUS_FAILURE => ['icon' => '../resources/images/icons/Tabler/square-rounded-x-filled-red.svg', 'text' => _("Some problem occurred during profile update")], |
||
| 64 | ]; |
||
| 65 | $radius_status = array(); |
||
| 66 | $radius_status[0] = $deploymentObject->radius_status_1; |
||
| 67 | $radius_status[1] = $deploymentObject->radius_status_2; |
||
| 68 | $cacert = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
||
| 69 | $retry = $deploymentObject->checkRADIUSHostandConfigDaemon(); |
||
| 70 | $isradiusready = radius_ready($deploymentObject); |
||
| 71 | if (is_array($retry)) { |
||
| 72 | foreach ($retry as $id => $stat) { |
||
| 73 | if ($stat) { |
||
| 74 | $response = $deploymentObject->setRADIUSconfig($id, 1); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | ?> |
||
| 79 | <div style='display: table-row_id;'> |
||
| 80 | <div class='profilebox' id="profilebox_<?php echo $depId;?>" style='display: table-cell;'> |
||
| 81 | <h2><?php |
||
| 82 | switch ($deploymentObject->consortium) { |
||
| 83 | case "eduroam": |
||
| 84 | $displayname = config\ConfAssistant::CONSORTIUM['name'] . " " . core\DeploymentManaged::PRODUCTNAME. ": SP$depId-".$deploymentObject->institution; |
||
| 85 | break; |
||
| 86 | case "OpenRoaming": |
||
| 87 | $displayname = "OpenRoaming ANP"; |
||
| 88 | break; |
||
| 89 | default: |
||
| 90 | throw new Exception("We are supposed to operate on a roaming consortium we don't know."); |
||
| 91 | } |
||
| 92 | echo $displayname . " (<span style='color:" . ( $deploymentObject->status == \core\AbstractDeployment::INACTIVE ? "red;'>" . _("inactive") : "green;'>" . _("active") ) . "</span>)"; |
||
| 93 | ?></h2> |
||
| 94 | <table class="deployments"> |
||
| 95 | <caption><?php echo _("Deployment Details"); ?></caption> |
||
| 96 | <tr><td> |
||
| 97 | <?php |
||
| 98 | echo _("Last seen:").' </td><td>'; |
||
| 99 | $when = $deploymentObject->getLastActivity(); |
||
| 100 | if (! $when ) { |
||
| 101 | echo _("never"); |
||
| 102 | } else { |
||
| 103 | echo $when; |
||
| 104 | } |
||
| 105 | ?> |
||
| 106 | </td></tr> |
||
| 107 | <tr> |
||
| 108 | <?php |
||
| 109 | $allRealms = array_values(array_unique(array_column($deploymentObject->getAttributes("managedsp:realmforvlan"), "value"))); |
||
| 110 | $opname = $deploymentObject->getAttributes("managedsp:operatorname")[0]['value'] ?? NULL; |
||
| 111 | $vlan = $deploymentObject->getAttributes("managedsp:vlan")[0]['value'] ?? NULL; |
||
| 112 | $guest_vlan = $deploymentObject->getAttributes("managedsp:guest_vlan")[0]['value'] ?? NULL; |
||
| 113 | |||
| 114 | ?> |
||
| 115 | <tr></tr> |
||
| 116 | <tr><th colspan="2"><?php echo _('Settings');?></th></tr> |
||
| 117 | <tr> |
||
| 118 | <td> |
||
| 119 | <?php |
||
| 120 | if ($opname) { |
||
| 121 | echo _("Custom Operator-Name"); |
||
| 122 | } else { |
||
| 123 | echo _("Default Operator-Name"); |
||
| 124 | } |
||
| 125 | ?> |
||
| 126 | </td> |
||
| 127 | <td> |
||
| 128 | <?php |
||
| 129 | if ($opname) { |
||
| 130 | echo $opname; |
||
| 131 | } else { |
||
| 132 | echo '1sp.'.$depId.'-'.$deploymentObject->institution.'.hosted.eduroam.org'; |
||
| 133 | } |
||
| 134 | ?> |
||
| 135 | </td> |
||
| 136 | </tr> |
||
| 137 | <?php |
||
| 138 | if ($guest_vlan) { |
||
| 139 | ?> |
||
| 140 | <tr> |
||
| 141 | <td><?php echo _("VLAN tag for guests"); ?></td> |
||
| 142 | <td> |
||
| 143 | <?php |
||
| 144 | if ($guest_vlan) { |
||
| 145 | echo $guest_vlan; |
||
| 146 | } |
||
| 147 | ?> |
||
| 148 | </td> |
||
| 149 | </tr> |
||
| 150 | <?php |
||
| 151 | } |
||
| 152 | if (!empty($allRealms) || $vlan) { |
||
| 153 | ?> |
||
| 154 | <tr> |
||
| 155 | <td><?php echo _("VLAN tag for own users"); ?></td> |
||
| 156 | <td> |
||
| 157 | <?php |
||
| 158 | if ($vlan) { |
||
| 159 | echo $vlan; |
||
| 160 | } else { |
||
| 161 | echo _('not set, be aware that realm setting is not used until a VLAN tag is added'); |
||
| 162 | } |
||
| 163 | ?> |
||
| 164 | </td> |
||
| 165 | </tr> |
||
| 166 | <tr> |
||
| 167 | <td><?php echo _("Realm to be considered own users"); ?></td> |
||
| 168 | <td> |
||
| 169 | <?php |
||
| 170 | if (!empty($allRealms)) { |
||
| 171 | echo implode(', ', $allRealms); |
||
| 172 | } else { |
||
| 173 | echo _('not set, be aware that VLAN setting is not used until a realm is added'); |
||
| 174 | } |
||
| 175 | } |
||
| 176 | ?> |
||
| 177 | </td></tr> |
||
| 178 | </form> |
||
| 179 | </table> |
||
| 180 | <div class='buttongroupprofilebox' style='clear:both;'> |
||
| 181 | <form action='overview_sp_wrapper.php?inst_id=<?php echo $deploymentObject->institution; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 182 | <br/> |
||
| 183 | <button type='submit' name='profile_action' value='edit'><?php echo _("Details"); ?></button> |
||
| 184 | </form> |
||
| 185 | <?php if ($isradiusready && $deploymentObject->status == \core\AbstractDeployment::ACTIVE && $editMode === 'fullaccess') { ?> |
||
| 186 | <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 187 | <button class='delete' type='submit' 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); ?>')"> |
||
| 188 | <?php echo _("Deactivate"); ?> |
||
| 189 | </button> |
||
| 190 | <?php |
||
| 191 | if (isset($_GET['res']) && is_array($_GET['res'])) { |
||
| 192 | $res = array_count_values($_GET['res']); |
||
| 193 | if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) { |
||
| 194 | echo '<br>'; |
||
| 195 | if ($res['FAILURE'] == 2) { |
||
| 196 | echo ' <span style="color: red;">' . _("Activation failure.") . '</span>'; |
||
| 197 | } else { |
||
| 198 | if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') { |
||
| 199 | echo ' <span style="color: red;">' . _("Activation failure for your primary RADIUS server.") . '</span>'; |
||
| 200 | } else { |
||
| 201 | echo ' <span style="color: red;">' . _("Activation failure for your backup RADIUS server.") . '</span>'; |
||
| 202 | } |
||
| 203 | } |
||
| 204 | } |
||
| 205 | } |
||
| 206 | ?> |
||
| 207 | </form> |
||
| 208 | <?php |
||
| 209 | } elseif (count($deploymentObject->getAttributes("hiddenmanagedsp:tou_accepted")) == 0) { |
||
| 210 | if ($editMode === 'fullaccess') { |
||
| 211 | ?> |
||
| 212 | <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 213 | <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_TERMSOFUSE_NEEDACCEPTANCE; ?>'> |
||
| 214 | <?php echo _("Accept Terms of Use"); ?> |
||
| 215 | </button> |
||
| 216 | </form> |
||
| 217 | <?php |
||
| 218 | } else { |
||
| 219 | echo "<strong>"._("Terms of Use not accepted.")."</strong>"; |
||
| 220 | } |
||
| 221 | } |
||
| 222 | if ($isradiusready && $deploymentObject->status == \core\AbstractDeployment::INACTIVE && count($deploymentObject->getAttributes("hiddenmanagedsp:tou_accepted"))) { ?> |
||
| 223 | <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 224 | <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_ACTIVATE; ?>'> |
||
| 225 | <?php echo _("Activate"); ?> |
||
| 226 | </button> |
||
| 227 | <?php |
||
| 228 | if (isset($_GET['res']) && is_array($_GET['res'])) { |
||
| 229 | $res = array_count_values($_GET['res']); |
||
| 230 | if (array_key_exists('FAILURE', $res) && $res['FAILURE'] > 0) { |
||
| 231 | echo '<br>'; |
||
| 232 | if ($res['FAILURE'] == 2) { |
||
| 233 | echo ' <span style="color: red;">' . _("Failure during deactivation, your request is queued for handling") . '</span>'; |
||
| 234 | } else { |
||
| 235 | if (isset($_GET['res'][1]) && $_GET['res']['1'] == 'FAILURE') { |
||
| 236 | echo ' <span style="color: red;">' . _("Deactivation failure for your primary RADIUS server, your request is queued.") . '</span>'; |
||
| 237 | } else { |
||
| 238 | echo ' <span style="color: red;">' . _("Deactivation failure for your backup RADIUS server, your request is queued.") . '</span>'; |
||
| 239 | } |
||
| 240 | } |
||
| 241 | } |
||
| 242 | } |
||
| 243 | ?> |
||
| 244 | </form> |
||
| 245 | <?php } |
||
| 246 | if ($deploymentObject->status == \core\AbstractDeployment::INACTIVE && $editMode === 'fullaccess') { ?> |
||
| 247 | <div align="right"> |
||
| 248 | <form action='edit_hotspot.php?inst_id=<?php echo $deploymentObject->institution; ?>&deployment_id=<?php echo $deploymentObject->identifier; ?>' method='post' accept-charset='UTF-8'> |
||
| 249 | <button class='delete' type='submit' name='submitbutton' value='<?php echo web\lib\common\FormElements::BUTTON_REMOVESP; ?>' onclick="return confirm('<?php printf(_("Do you really want to remove this %s deployment?"), core\DeploymentManaged::PRODUCTNAME); ?>')"> |
||
| 250 | <?php echo _("Remove deployment"); ?> |
||
| 251 | </button> |
||
| 252 | </form> |
||
| 253 | </div> |
||
| 254 | <?php } ?> |
||
| 255 | |||
| 256 | </div> |
||
| 257 | <?php |
||
| 258 | if (!$isradiusready) { |
||
| 259 | echo '<p>'. _("We are not able to handle a new configuration request requiring contact with RADIUS servers now.") . '<br>' . _("Check later."); |
||
| 260 | |||
| 261 | } |
||
| 262 | |||
| 263 | ?> |
||
| 264 | |||
| 265 | |||
| 357 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.