Merge branch 'next' of github.com:MPOS/php-mpos into next

This commit is contained in:
Sebastian Grewe 2014-02-14 09:42:16 +01:00
commit 6f706b883d
7 changed files with 33 additions and 5 deletions

View File

@ -153,7 +153,7 @@ if (empty($aAllBlocks)) {
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
if (is_array($aAccounts)) {
$finder = $user->getUserName($aBlock['account_id']);
$finder = $user->getUserName($iAccountId);
foreach ($aAccounts as $aData) {
$aMailData['height'] = $aBlock['height'];
$aMailData['subject'] = 'New Block';
@ -162,6 +162,7 @@ if (empty($aAllBlocks)) {
$aMailData['amount'] = $aBlock['amount'];
$aMailData['difficulty'] = $aBlock['difficulty'];
$aMailData['finder'] = $finder;
$aMailData['currency'] = $config['currency'];
if (!$notification->sendNotification($aData['account_id'], 'new_block', $aMailData))
$log->logError('Failed to notify user of new found block: ' . $user->getUserName($aData['account_id']));
}

View File

@ -10,7 +10,7 @@
PHP_BIN=$( which php )
# List of cruns to execute
CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php liquid_payout.php"
CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php notification_cleanup.php liquid_payout.php"
# Output additional runtime information
VERBOSE="0"

View File

@ -10,7 +10,7 @@
PHP_BIN=$( which php )
# List of cruns to execute
CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php"
CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php notification_cleanup.php"
# Output additional runtime information
VERBOSE="0"

View File

@ -151,6 +151,27 @@ class Notification extends Mail {
$this->setErrorMessage('Error sending mail notification');
return false;
}
/**
* Cleanup old notifications
* @param none
* @return bool true or false
**/
public function cleanupNotifications($days=7) {
$failed = 0;
$this->deleted = 0;
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE time < (NOW() - ? * 24 * 60 * 60)");
if (! ($this->checkStmt($stmt) && $stmt->bind_param('i', $days) && $stmt->execute())) {
$failed++;
} else {
$this->deleted += $stmt->affected_rows;
}
if ($failed > 0) {
$this->setCronMessage('Failed to delete ' . $failed . ' notifications from ' . $this->table . ' table');
return false;
}
return true;
}
}
$notification = new Notification();

View File

@ -390,6 +390,12 @@ $aSettings['monitoring'][] = array(
'name' => 'monitoring_uptimerobot_api_keys', 'value' => $setting->getValue('monitoring_uptimerobot_api_keys'),
'tooltip' => 'Create per-monitor API keys and save them here to propagate your uptime statistics.'
);
$aSettings['notifications'][] = array(
'display' => 'Notification Cleanup Time', 'type' => 'text',
'default' => 7,
'name' => 'notifications_cleanup_time', 'value' => $setting->getValue('notifications_cleanup_time'),
'tooltip' => 'Maximum age in days of notifications before cleaned from database.'
);
$aSettings['notifications'][] = array(
'display' => 'Disable notifications', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes' ),

View File

@ -2,7 +2,7 @@
// Small helper array that may be used on some page controllers to
// fetch the crons we wish to monitor
$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','blockupdate','findblock','notifications','tickerupdate','liquid_payout');
$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','notification_cleanup','blockupdate','findblock','notifications','tickerupdate','liquid_payout');
switch ($config['payout_system']) {
case 'pplns':

View File

@ -1,5 +1,5 @@
<html>
<p>{nocache}Block Number {$DATA.height} has been discovered by {$DATA.finder} with a total value of {$DATA.amount}! The current difficulty is {$DATA.difficulty}.{/nocache}</p>
<p>{nocache}Block Number {$DATA.height} has been discovered by {$DATA.finder} with a total value of {$DATA.amount} {$DATA.currency}! The current difficulty is {$DATA.difficulty}.{/nocache}</p>
<body>
<br/>
<br/>