From 48b86f6257bd0c79f26ee5e111bfa1488a28e6fb Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 13 Jun 2013 12:17:47 -0400 Subject: Add the ability to disable Growl or SMTP notifications but keep their settings intact. Remove automatic test messages on save. Add individual test buttons for Growl and SMTP that work even if the service(s) are disabled. --- usr/local/www/system_advanced_notifications.php | 63 +++++++++++++++++++++---- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'usr/local/www/system_advanced_notifications.php') diff --git a/usr/local/www/system_advanced_notifications.php b/usr/local/www/system_advanced_notifications.php index 50278f9..5d15fea 100644 --- a/usr/local/www/system_advanced_notifications.php +++ b/usr/local/www/system_advanced_notifications.php @@ -41,6 +41,7 @@ require("guiconfig.inc"); require_once("notices.inc"); // Growl +$pconfig['disable_growl'] = isset($config['notifications']['growl']['disable']); if($config['notifications']['growl']['password']) $pconfig['password'] = $config['notifications']['growl']['password']; if($config['notifications']['growl']['ipaddress']) @@ -58,6 +59,7 @@ else // SMTP +$pconfig['disable_smtp'] = isset($config['notifications']['smtp']['disable']); if($config['notifications']['smtp']['ipaddress']) $pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress']; if($config['notifications']['smtp']['port']) @@ -102,6 +104,11 @@ if ($_POST) { $config['notifications']['growl']['name'] = $_POST['name']; $config['notifications']['growl']['notification_name'] = $_POST['notification_name']; + if($_POST['disable_growl'] == "yes") + $config['notifications']['growl']['disable'] = true; + else + unset($config['notifications']['growl']['disable']); + // SMTP $config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress']; $config['notifications']['smtp']['port'] = $_POST['smtpport']; @@ -111,6 +118,11 @@ if ($_POST) { $config['notifications']['smtp']['password'] = $_POST['smtppassword']; $config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress']; + if($_POST['disable_smtp'] == "yes") + $config['notifications']['smtp']['disable'] = true; + else + unset($config['notifications']['smtp']['disable']); + // System Sounds if($_POST['disablebeep'] == "yes") $config['system']['disablebeep'] = true; @@ -118,23 +130,26 @@ if ($_POST) { unset($config['system']['disablebeep']); write_config(); + pfSenseHeader("system_advanced_notifications.php"); + return; + } + if ($_POST['test_growl'] == gettext("Test Growl")) { // Send test message via growl if($config['notifications']['growl']['ipaddress'] && - $config['notifications']['growl']['password'] = $_POST['password']) { + $config['notifications']['growl']['password'] = $_POST['password'] && + !isset($config['notifications']['growl']['disable'])) { unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt"); register_via_growl(); - notify_via_growl(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name'])); + notify_via_growl(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name']), true); } - + } + if ($_POST['test_smtp'] == gettext("Test SMTP")) { // Send test message via smtp if(file_exists("/var/db/notices_lastmsg.txt")) unlink("/var/db/notices_lastmsg.txt"); - $savemsg = notify_via_smtp(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name'])); - - pfSenseHeader("system_advanced_notifications.php"); - exit; - } + $savemsg = notify_via_smtp(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name']), true); + } } $pgtitle = array(gettext("System"),gettext("Advanced: Notifications")); @@ -177,6 +192,13 @@ include("head.inc"); + + + checked="checked" />
+ + + + ' />
@@ -205,6 +227,15 @@ include("head.inc"); + +   + + + +
+ + +   @@ -212,6 +243,13 @@ include("head.inc"); + + + checked="checked" />
+ + + + ' />
@@ -255,6 +293,15 @@ include("head.inc"); + +   + + + +
+ + +   -- cgit v1.1