Allow admin to disable notification system

This addresses #497 and allows the admins to disable notifications
through the admin panel. Might be used by those relying on clients using
the API instead.

Once merged it will fix #497.
This commit is contained in:
Sebastian Grewe 2013-07-22 10:58:39 +02:00
parent a6c8d507dc
commit 760f1a679e
7 changed files with 52 additions and 27 deletions

View File

@ -115,6 +115,7 @@ if (empty($aAllBlocks)) {
. $share->share_type . $share->share_type
); );
if ($setting->getValue('disable_notification') != 1) {
// Notify users // Notify users
$aAccounts = $notification->getNotificationAccountIdByType('new_block'); $aAccounts = $notification->getNotificationAccountIdByType('new_block');
if (is_array($aAccounts)) { if (is_array($aAccounts)) {
@ -130,6 +131,7 @@ if (empty($aAllBlocks)) {
} }
} }
} }
}
require_once('cron_end.inc.php'); require_once('cron_end.inc.php');
?> ?>

View File

@ -22,6 +22,12 @@ limitations under the License.
// Include all settings and classes // Include all settings and classes
require_once('shared.inc.php'); require_once('shared.inc.php');
if ($setting->getValue('disable_notifications') == 1) {
$monitoring->setStatus($cron_name . "_active", "yesno", 0);
$monitoring->setStatus($cron_name . "_message", "message", "Cron disabled by admin");
$monitoring->setStatus($cron_name . "_status", "okerror", 0);
exit(0);
}
$log->logDebug(" IDLE Worker Notifications ..."); $log->logDebug(" IDLE Worker Notifications ...");
// Find all IDLE workers // Find all IDLE workers

View File

@ -3,6 +3,10 @@
// Make sure we are called from index.php // Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt'); if (!defined('SECURITY')) die('Hacking attempt');
if ($user->isAuthenticated()) { if ($user->isAuthenticated()) {
if ($setting->getValue('disable_notifications') == 1) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Notification system disabled by admin.', 'TYPE' => 'info');
$smarty->assign('CONTENT', '../../global/empty.tpl');
} else {
if (@$_REQUEST['do'] == 'save') { if (@$_REQUEST['do'] == 'save') {
if ($notification->updateSettings($_SESSION['USERDATA']['id'], $_REQUEST['data'])) { if ($notification->updateSettings($_SESSION['USERDATA']['id'], $_REQUEST['data'])) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Updated notification settings'); $_SESSION['POPUP'][] = array('CONTENT' => 'Updated notification settings');
@ -22,4 +26,5 @@ if ($user->isAuthenticated()) {
$smarty->assign('SETTINGS', $aSettings); $smarty->assign('SETTINGS', $aSettings);
$smarty->assign('CONTENT', 'default.tpl'); $smarty->assign('CONTENT', 'default.tpl');
} }
}
?> ?>

View File

@ -22,6 +22,7 @@ $smarty->assign("LOCKREGISTRATION", $setting->getValue('lock_registration'));
$smarty->assign("DISABLEINVITATIONS", $setting->getValue('disable_invitations')); $smarty->assign("DISABLEINVITATIONS", $setting->getValue('disable_invitations'));
$smarty->assign("DISABLEAP", $setting->getValue('disable_ap')); $smarty->assign("DISABLEAP", $setting->getValue('disable_ap'));
$smarty->assign("DISABLEMP", $setting->getValue('disable_mp')); $smarty->assign("DISABLEMP", $setting->getValue('disable_mp'));
$smarty->assign("DISABLENOTIFICATIONS", $setting->getValue('disable_notifications'));
// Tempalte specifics // Tempalte specifics
$smarty->assign("CONTENT", "default.tpl"); $smarty->assign("CONTENT", "default.tpl");

View File

@ -51,6 +51,7 @@ $aGlobal = array(
'website' => $config['website'], 'website' => $config['website'],
'accounts' => $config['accounts'], 'accounts' => $config['accounts'],
'disable_invitations' => $setting->getValue('disable_invitations'), 'disable_invitations' => $setting->getValue('disable_invitations'),
'disable_notifications' => $setting->getValue('disable_notifications'),
'price' => array( 'currency' => $config['price']['currency'] ), 'price' => array( 'currency' => $config['price']['currency'] ),
'targetdiff' => $config['difficulty'], 'targetdiff' => $config['difficulty'],
'currency' => $config['currency'], 'currency' => $config['currency'],

View File

@ -60,6 +60,16 @@
</select> </select>
</td> </td>
</tr> </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>
</td>
</tr>
<tr><td class="center" colspan="3"><input type="submit" value="Save" class="submit small" /></td></tr> <tr><td class="center" colspan="3"><input type="submit" value="Save" class="submit small" /></td></tr>
</tbody> </tbody>
</table> </table>

View File

@ -6,7 +6,7 @@
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=edit">Edit Account</a></li> <li><a href="{$smarty.server.PHP_SELF}?page=account&action=edit">Edit Account</a></li>
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=workers">My Workers</a></li> <li><a href="{$smarty.server.PHP_SELF}?page=account&action=workers">My Workers</a></li>
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=transactions">Transactions</a></li> <li><a href="{$smarty.server.PHP_SELF}?page=account&action=transactions">Transactions</a></li>
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=notifications">Notifications</a></li> {if !$GLOBAL.config.disable_notifications}<li><a href="{$smarty.server.PHP_SELF}?page=account&action=notifications">Notifications</a></li>{/if}
{if !$GLOBAL.config.disable_invitations}<li><a href="{$smarty.server.PHP_SELF}?page=account&action=invitations">Invitations</a></li>{/if} {if !$GLOBAL.config.disable_invitations}<li><a href="{$smarty.server.PHP_SELF}?page=account&action=invitations">Invitations</a></li>{/if}
</ul> </ul>
</li> </li>