Merge pull request #1567 from MPOS/donation-percentage

[IMPROVED] Added donation minimum and rounding
This commit is contained in:
Sebastian Grewe 2014-01-24 01:09:34 -08:00
commit 30fcc42e7d
5 changed files with 19 additions and 7 deletions

View File

@ -382,6 +382,7 @@ class User extends Base {
public function updateAccount($userID, $address, $threshold, $donate, $email, $is_anonymous, $strToken) {
$this->debug->append("STA " . __METHOD__, 4);
$bUser = false;
$donate = round($donate, 2);
// number validation checks
if (!is_numeric($threshold)) {
$this->setErrorMessage('Invalid input for auto-payout');
@ -396,8 +397,8 @@ class User extends Base {
if (!is_numeric($donate)) {
$this->setErrorMessage('Invalid input for donation');
return false;
} else if ($donate < 0) {
$this->setErrorMessage('Donation below allowed 0% limit');
} else if ($donate < $this->config['donate_threshold']['min'] && $donate != 0) {
$this->setErrorMessage('Donation below allowed ' . $this->config['donate_threshold']['min'] . '% limit');
return false;
} else if ($donate > 100) {
$this->setErrorMessage('Donation above allowed 100% limit');

View File

@ -7,7 +7,7 @@ if (!defined('SECURITY')) die('Hacking attempt');
* This is used in the version check to ensure you run the latest version of the configuration file.
* Once you upgraded your config, change the version here too.
**/
$config['version'] = '0.0.5';
$config['version'] = '0.0.6';
// Our include directory for additional features
define('INCLUDE_DIR', BASEPATH . 'include');
@ -135,7 +135,7 @@ $config['twofactor']['options']['changepw'] = true;
*
* Options:
* enabled = Whether or not we will generate/check for valid CSRF tokens
* disabled_forms = Which forms you want to disable csrf protection on, if enabled
* disabled_forms = Which forms you want to disable csrf protection on, if enabled
* * Valid options : login, contact, accountedit, workers, notifications, invite, register, passreset, unlockaccount
* Default:
* enabled = true
@ -216,6 +216,16 @@ $config['price']['currency'] = 'USD';
$config['ap_threshold']['min'] = 1;
$config['ap_threshold']['max'] = 250;
/**
* Donation thresholds
*
* You can define a min and max values for you users
* donation settings here.
*
* Defaults:
* `min` = `1`
**/
$config['donate_threshold']['min'] = 1;
/**
* Account specific settings

View File

@ -193,6 +193,7 @@ $smarty->assign("DETAILSUNLOCKED", $ea_editable);
$smarty->assign("CHANGEPASSSENT", $cp_sent);
$smarty->assign("WITHDRAWSENT", $wf_sent);
$smarty->assign("DETAILSSENT", $ea_sent);
$smarty->assign("DONATE_THRESHOLD", $config['donate_threshold']);
if ($csrfenabled && !in_array('accountedit', $config['csrf']['disabled_forms'])) {
$token = $csrftoken->getBasic($user->getCurrentIP(), 'editaccount');
$smarty->assign('CTOKEN', $token);

View File

@ -5,7 +5,7 @@ if (!defined('SECURITY')) die('Hacking attempt');
define('MPOS_VERSION', '0.0.2');
define('DB_VERSION', '0.0.4');
define('CONFIG_VERSION', '0.0.5');
define('CONFIG_VERSION', '0.0.6');
// Fetch installed database version
$db_version = $setting->getValue('DB_VERSION');

View File

@ -29,8 +29,8 @@
</fieldset>
<fieldset>
<label>Donation Percentage</label>
<font size="1"> Donation amount in percent (example: 0.5)</font>
{nocache}<input type="text" name="donatePercent" value="{$smarty.request.donatePercent|default:$GLOBAL.userdata.donate_percent|escape}" size="4" {if $GLOBAL.twofactor.enabled && $GLOBAL.twofactor.options.details && !$DETAILSUNLOCKED}disabled{/if}/>{/nocache}
<font size="1"> Donation amount in percent ({$DONATE_THRESHOLD.min}-100%)</font>
{nocache}<input type="text" name="donatePercent" value="{$smarty.request.donatePercent|default:$GLOBAL.userdata.donate_percent|escape|number_format:"2"}" size="4" {if $GLOBAL.twofactor.enabled && $GLOBAL.twofactor.options.details && !$DETAILSUNLOCKED}disabled{/if}/>{/nocache}
</fieldset>
<fieldset>
<label>Automatic Payout Threshold</label>