mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-09 14:16:08 +00:00
a02be51969
Incremental Refactor Templates
144 lines
3.4 KiB
Smarty
144 lines
3.4 KiB
Smarty
<?php
|
|
#################################################################################
|
|
## -= TravianZ Alliance Options (incremental refactor) =- ##
|
|
## - preserves permission logic ##
|
|
## - reduces duplication ##
|
|
## - improves readability ##
|
|
## - adds safety ##
|
|
#################################################################################
|
|
|
|
// -------------------------------------------------
|
|
// SAFE ALLIANCE ID
|
|
// -------------------------------------------------
|
|
|
|
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
|
|
|
|
// -------------------------------------------------
|
|
// LOAD DATA
|
|
// -------------------------------------------------
|
|
|
|
$allianceinfo = $database->getAlliance($aid);
|
|
|
|
// -------------------------------------------------
|
|
// HEADER
|
|
// -------------------------------------------------
|
|
|
|
echo "<h1>" .
|
|
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
|
|
" - " .
|
|
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
|
|
"</h1>";
|
|
|
|
include_once("alli_menu.tpl");
|
|
?>
|
|
|
|
<!-- ERROR OUTPUT -->
|
|
<p class="error">
|
|
<?php echo $form->getError("perm"); ?>
|
|
</p>
|
|
|
|
<form method="POST" action="allianz.php">
|
|
|
|
<input type="hidden" name="s" value="5">
|
|
|
|
<table cellpadding="1" cellspacing="1" id="options" class="small_option">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th colspan="2">Options</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php
|
|
// -------------------------------------------------
|
|
// PERMISSION SHORTCUT
|
|
// -------------------------------------------------
|
|
|
|
$perm = $alliance->userPermArray;
|
|
|
|
// -------------------------------------------------
|
|
// OPTIONS MAP (reduces duplication)
|
|
// -------------------------------------------------
|
|
|
|
$options = [
|
|
|
|
1 => [
|
|
'perm' => 'opt1',
|
|
'label' => 'Assign to position'
|
|
],
|
|
|
|
100 => [
|
|
'perm' => 'opt3',
|
|
'label' => 'Change name'
|
|
],
|
|
|
|
2 => [
|
|
'perm' => 'opt2',
|
|
'label' => 'Kick player'
|
|
],
|
|
|
|
3 => [
|
|
'perm' => 'opt3',
|
|
'label' => 'Change alliance description'
|
|
],
|
|
|
|
6 => [
|
|
'perm' => 'opt6',
|
|
'label' => 'Alliance diplomacy'
|
|
],
|
|
|
|
4 => [
|
|
'perm' => 'opt4',
|
|
'label' => 'Invite a player into the alliance'
|
|
],
|
|
|
|
5 => [
|
|
'perm' => 'opt5',
|
|
'label' => 'Link to the forum'
|
|
]
|
|
];
|
|
|
|
// -------------------------------------------------
|
|
// DYNAMIC OPTIONS RENDER
|
|
// -------------------------------------------------
|
|
|
|
foreach ($options as $value => $optData) {
|
|
|
|
if (!empty($perm[$optData['perm']]) && $perm[$optData['perm']] == 1) {
|
|
|
|
echo "<tr>
|
|
<td class=\"sel\">
|
|
<input class=\"radio\" type=\"radio\" name=\"o\" value=\"" . (int)$value . "\">
|
|
</td>
|
|
<td class=\"val\">" . $optData['label'] . "</td>
|
|
</tr>";
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!-- ALWAYS AVAILABLE OPTION -->
|
|
<tr>
|
|
<td class="sel">
|
|
<input class="radio" type="radio" name="o" value="11">
|
|
</td>
|
|
<td class="val">Quit alliance</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- SUBMIT -->
|
|
<p>
|
|
<button
|
|
type="submit"
|
|
name="s1"
|
|
id="btn_ok"
|
|
class="trav_buttons"
|
|
onclick="this.disabled=true;this.form.submit();">
|
|
Ok
|
|
</button>
|
|
</p>
|
|
|
|
</form> |