Merge pull request #557 from TheSerapher/admin-settings

Refactored admin panel settings
This commit is contained in:
Sebastian Grewe 2013-08-05 01:04:55 -07:00
commit 43d08e0835
3 changed files with 89 additions and 72 deletions

View File

@ -0,0 +1,68 @@
<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Check user to ensure they are admin
if (!$user->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");
?>

View File

@ -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");

View File

@ -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)}
<div class="block_content tab_content" id="{$TAB}" style="padding-left:30px;">
<form method="POST">
<input type="hidden" name="page" value="{$smarty.request.page}" />
<input type="hidden" name="action" value="{$smarty.request.action}" />
@ -10,75 +12,25 @@
<th>Value</th>
</thead>
<tbody>
{section name=setting loop=$SETTINGS.$TAB}
<tr>
<td class="left">Message of the Day</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Set a pool-wide message of the day.'></span></td>
<td class="left">{$SETTINGS.$TAB[setting].display}</td>
<td class="center">{if $SETTINGS.$TAB[setting].tooltip|default}<span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='{$SETTINGS.$TAB[setting].tooltip}.'></span>{/if}</td>
<td>
<input name="data[system_motd]" value="{$MOTD|default:""}">
</td>
</tr>
<tr>
<td class="left">Maintenance Mode</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable Maintenance Mode for mmcfe-ng. Only admins can login.'></span></td>
<td>
<select name="data[maintenance]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$MAINTENANCE} selected{/if}>{/nocache}No</option>
</select>
</td>
</tr>
<tr>
<td class="left">Disable Registration</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable or disable new account registration. Can also be done via configuration option.'></span></td>
<td>
<select name="data[lock_registration]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$LOCKREGISTRATION} selected{/if}{/nocache}>No</option>
</select>
</td>
</tr>
<tr>
<td class="left">Disable Invitations</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable or disable users to invite others. Configuration file defines number of allowed invitations.'></span></td>
<td>
<select name="data[disable_invitations]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$DISABLEINVITATIONS} selected{/if}{/nocache}>No</option>
</select>
</td>
</tr>
<tr>
<td class="left">Disable Auto Payout</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable or disable users to invite others. Configuration file defines number of allowed invitations.'></span></td>
<td>
<select name="data[disable_ap]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$DISABLEAP} selected{/if}{/nocache}>No</option>
</select>
</td>
</tr>
<tr>
<td class="left">Disable Manual Payout</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable or disable users to invite others. Configuration file defines number of allowed invitations.'></span></td>
<td>
<select name="data[disable_mp]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$DISABLEMP} selected{/if}{/nocache}>No</option>
</select>
</td>
</tr>
<tr>
<td class="left">Disable Notifications</td>
<td class="center"><span id='tt'><img src='{$PATH}/images/questionmark.png' height='15px' width='15px' title='Enable or disable the notification system.'></span></td>
<td>
<select name="data[disable_notifications]">
<option value="1">Yes</option>
<option value="0"{nocache}{if !$DISABLENOTIFICATIONS} selected{/if}{/nocache}>No</option>
</select>
{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'}
<input type="text" size="{$SETTINGS.$TAB[setting].size}" name="data[{$SETTINGS.$TAB[setting].name}]" value="{$SETTINGS.$TAB[setting].value|default}" />
{else}
Unknown option type: {$SETTINGS.$TAB[setting].type}
{/if}
</td>
</tr>
{/section}
<tr><td class="center" colspan="3"><input type="submit" value="Save" class="submit small" /></td></tr>
</tbody>
</table>
</form>
</div>
{/foreach}
{include file="global/block_footer.tpl"}