From 4d77a7d2997da7f3e29697332dd0c9fefad95c91 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 5 Aug 2013 10:02:39 +0200 Subject: [PATCH] Refactored admin panel settings This will allow easier integration of new settings managed by the admin panel. Includes setting types, tooltips, tabs etc. No open ticket, just figured I'd add this. --- public/include/config/admin_settings.inc.php | 68 ++++++++++++++++ public/include/pages/admin/settings.inc.php | 13 ++- .../mmcFE/admin/settings/default.tpl | 80 ++++--------------- 3 files changed, 89 insertions(+), 72 deletions(-) create mode 100644 public/include/config/admin_settings.inc.php diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php new file mode 100644 index 00000000..bd6ece0f --- /dev/null +++ b/public/include/config/admin_settings.inc.php @@ -0,0 +1,68 @@ +isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { + header("HTTP/1.1 404 Page not found"); + die("404 Page not found"); +} + +if (@$_REQUEST['do'] == 'save' && !empty($_REQUEST['data'])) { + foreach($_REQUEST['data'] as $var => $value) { + $setting->setValue($var, $value); + } + $_SESSION['POPUP'][] = array('CONTENT' => 'Settings updated'); +} + +// Load the settings available in this system +$aSettings['system'][] = array( + 'display' => 'Maintenance Mode', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'maintenance', 'value' => $setting->getValue('maintenance'), + 'tooltip' => 'Enable or Disable maintenance mode. Only admins can still login.' +); +$aSettings['system'][] = array( + 'display' => 'Disable registrations', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'lock_registration', 'value' => $setting->getValue('lock_registration'), + 'tooltip' => 'Enable or Disable registrations. Useful to create an invitation only pool.' +); +$aSettings['system'][] = array( + 'display' => 'Disable Invitations', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'disable_invitations', 'value' => $setting->getValue('disable_invitations'), + 'tooltip' => 'Enable or Disable invitations. Users will not be able to invite new users via email if disabled.' +); +$aSettings['system'][] = array( + 'display' => 'Disable Manual Payouts', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'disable_mp', 'value' => $setting->getValue('disable_mp'), + 'tooltip' => 'Enable or Disable the manual payout processing. Users will not be able to withdraw any funds if disabled.' +); +$aSettings['system'][] = array( + 'display' => 'Disable Automatic Payouts', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'disable_ap', 'value' => $setting->getValue('disable_ap'), + 'tooltip' => 'Enable or Disable the automatic payout processing. Users exceeding their thresholds will not be paid out if disabled.' +); +$aSettings['system'][] = array( + 'display' => 'Disable notifications', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'name' => 'disable_notifications', 'value' => $setting->getValue('disable_notifications'), + 'tooltip' => 'Enable or Disable system notifications. This includes new found blocks, monitoring and all other notifications.' +); +$aSettings['other'][] = array( + 'display' => 'Message of the Day', 'type' => 'text', + 'size' => 25, + 'name' => 'system_motd', 'value' => $setting->getValue('system_motd'), + 'tooltip' => 'Display a message of the day as information popup if set.' +); + +// Load onto the template +$smarty->assign("SETTINGS", $aSettings); + +// Tempalte specifics +$smarty->assign("CONTENT", "default.tpl"); +?> diff --git a/public/include/pages/admin/settings.inc.php b/public/include/pages/admin/settings.inc.php index dca050f0..e5dc124e 100644 --- a/public/include/pages/admin/settings.inc.php +++ b/public/include/pages/admin/settings.inc.php @@ -16,14 +16,11 @@ if (@$_REQUEST['do'] == 'save' && !empty($_REQUEST['data'])) { $_SESSION['POPUP'][] = array('CONTENT' => 'Settings updated'); } -// Fetch settings to propagate to template -$smarty->assign("MAINTENANCE", $setting->getValue('maintenance')); -$smarty->assign("LOCKREGISTRATION", $setting->getValue('lock_registration')); -$smarty->assign("DISABLEINVITATIONS", $setting->getValue('disable_invitations')); -$smarty->assign("DISABLEAP", $setting->getValue('disable_ap')); -$smarty->assign("DISABLEMP", $setting->getValue('disable_mp')); -$smarty->assign("DISABLENOTIFICATIONS", $setting->getValue('disable_notifications')); -$smarty->assign("MOTD", $setting->getValue('system_motd')); +// Load our available settings from configuration +require_once(INCLUDE_DIR . '/config/admin_settings.inc.php'); + +// Load onto the template +$smarty->assign("SETTINGS", $aSettings); // Tempalte specifics $smarty->assign("CONTENT", "default.tpl"); diff --git a/public/templates/mmcFE/admin/settings/default.tpl b/public/templates/mmcFE/admin/settings/default.tpl index eb0b7bc0..dd5c5a09 100644 --- a/public/templates/mmcFE/admin/settings/default.tpl +++ b/public/templates/mmcFE/admin/settings/default.tpl @@ -1,4 +1,6 @@ -{include file="global/block_header.tpl" BLOCK_HEADER="Admin Settings"} +{include file="global/block_header.tpl" BLOCK_HEADER="Admin Settings" BUTTONS=array_keys($SETTINGS)} +{foreach item=TAB from=array_keys($SETTINGS)} +
@@ -10,75 +12,25 @@ Value +{section name=setting loop=$SETTINGS.$TAB} - Message of the Day - + {$SETTINGS.$TAB[setting].display} + {if $SETTINGS.$TAB[setting].tooltip|default}{/if} - - - - - Maintenance Mode - - - - - - - Disable Registration - - - - - - - Disable Invitations - - - - - - - Disable Auto Payout - - - - - - - Disable Manual Payout - - - - - - - Disable Notifications - - - + {if $SETTINGS.$TAB[setting].type == 'select'} + {html_options name="data[{$SETTINGS.$TAB[setting].name}]" options=$SETTINGS.$TAB[setting].options selected=$SETTINGS.$TAB[setting].value|default:"0"} + {else if $SETTINGS.$TAB[setting].type == 'text'} + + {else} + Unknown option type: {$SETTINGS.$TAB[setting].type} + {/if} +{/section}
+
+{/foreach} {include file="global/block_footer.tpl"}