From: ebullient Date: Mon, 31 Mar 2003 04:18:21 +0000 (+0000) Subject: 1) Corrected errors with relative paths that prevented sounds from X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=692ca6b773e1ec2de37435671b0da106327a7ff1;p=squirrelmail.git 1) Corrected errors with relative paths that prevented sounds from being played correctly for notification/test. 2) Removed local file option. As it existed, it didn't function properly on windows, possibly also not on Unix. This function should be revisited, , possibly changing to support a single uploaded sound (less than a certain size) per user, which would live in the prefs dir (?). This allows users to supply their own sound of choice that will work regardless of which PC they're using, which is more the point of SquirrelMail anyway. Didn't want to try to squeeze the change to upload in under 1.4, so I just removed it entirely. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4703 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/plugins/newmail/newmail_opt.php b/plugins/newmail/newmail_opt.php index c463fec0..24924db1 100644 --- a/plugins/newmail/newmail_opt.php +++ b/plugins/newmail/newmail_opt.php @@ -20,33 +20,33 @@ require_once(SM_PATH . 'functions/display_messages.php'); require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'include/load_prefs.php'); - displayPageHeader($color, 'None'); +displayPageHeader($color, 'None'); - $media_enable = getPref($data_dir,$username, 'newmail_enable', 'FALSE' ); - $media_popup = getPref($data_dir, $username,'newmail_popup'); - $media_allbox = getPref($data_dir,$username,'newmail_allbox'); - $media_recent = getPref($data_dir,$username,'newmail_recent'); - $media_changetitle = getPref($data_dir,$username,'newmail_changetitle'); - $media = getPref($data_dir,$username,'newmail_media', '../plugins/newmail/sounds/Notify.wav'); +$media_enable = getPref($data_dir,$username, 'newmail_enable', 'FALSE' ); +$media_popup = getPref($data_dir, $username,'newmail_popup'); +$media_allbox = getPref($data_dir,$username,'newmail_allbox'); +$media_recent = getPref($data_dir,$username,'newmail_recent'); +$media_changetitle = getPref($data_dir,$username,'newmail_changetitle'); +$media = getPref($data_dir,$username,'newmail_media', '(none)'); - // Set $allowsound to false if you don't want sound files available - $allowsound = "true"; +// Set $allowsound to false if you don't want sound files available +$allowsound = "true"; - echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "\n" . - html_tag( 'tr', "\n" . +echo html_tag( 'table', '', 'center', '', 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "\n" . + html_tag( 'tr', "\n" . html_tag( 'td', '' . _("Options") . ' - ' . _("New Mail Notification") . '', 'center', $color[0] ) - ) . "\n" . + ) . "\n" . html_tag( 'tr' ) . "\n" . html_tag( 'td', '', 'left' ); - if ($allowsound == "true") { - echo html_tag( 'p', +if ($allowsound == "true") { + echo html_tag( 'p', _("Select Enable Media Playing to turn on playing a media file when unseen mail is in your folders. When enabled, you can specify the media file to play in the provided file box.") - ) . "\n"; - } - echo html_tag( 'p', - _("The Check all boxes, not just INBOX option will check ALL of your folders for unseen mail, not just the inbox for notification.") - ) . "\n" . - html_tag( 'p', + ) . "\n"; +} + echo html_tag( 'p', + _("The Check all boxes, not just INBOX option will check ALL of your folders for unseen mail, not just the inbox for notification.") + ) . "\n" . + html_tag( 'p', _("Selecting the Show popup option will enable the showing of a popup window when unseen mail is in your folders (requires JavaScript).") ) . "\n" . html_tag( 'p', @@ -57,16 +57,16 @@ require_once(SM_PATH . 'include/load_prefs.php'); ); if ($allowsound == "true") { echo html_tag( 'p', - _("Select from the list of server files the media file to play when new mail arrives. Selecting local media will play the file specified in the local media file box to play from the local computer. If no file is specified, the system will use a default from the server.") + _("Select from the list of server files the media file to play when new mail arrives. If no file is specified, \"(none)\", no sound will be used.") ) . "\n"; } - echo '
'. + echo ''. html_tag( 'table', '', '', '', 'width="100%" cellpadding="0" cellspacing="2" border="0"' ) . "\n" . html_tag( 'tr' ) . "\n" . html_tag( 'td', ' ', 'right', '', 'nowrap' ) . "\n"; if ($allowsound == "true") { - echo html_tag( 'td', '', 'left' ) . - ''. "\n" . - '' . "\n"; + ''. ''. ''. ''. - html_tag( 'tr', "\n" . - html_tag( 'td', _("Local Media File:"), 'right', '', 'nowrap' ) . - html_tag( 'td', '', 'left' ) - ) . "\n" . html_tag( 'tr', "\n" . html_tag( 'td', _("Current File:"), 'right', '', 'nowrap' ) . html_tag( 'td', '' . $media . '', 'left' ) diff --git a/plugins/newmail/setup.php b/plugins/newmail/setup.php index ecc7af3c..d925f57f 100644 --- a/plugins/newmail/setup.php +++ b/plugins/newmail/setup.php @@ -24,6 +24,7 @@ * * $Id$ */ + include_once(SM_PATH . 'functions/display_messages.php'); function CheckNewMailboxSound($imapConnection, $mailbox, $real_box, $delimeter, $unseen, &$total_new) { @@ -77,7 +78,7 @@ /* Register Squirrelspell with the $optionpages array. */ $optpage_blocks[] = array( 'name' => _("NewMail Options"), - 'url' => '../plugins/newmail/newmail_opt.php', + 'url' => SM_PATH . 'plugins/newmail/newmail_opt.php', 'desc' => _("This configures settings for playing sounds and/or showing popup windows when new mail arrives."), 'js' => TRUE ); @@ -85,44 +86,33 @@ } function newmail_sav() { - - global $data_dir, $username, $_POST; - - if ( isset($_POST['submit_newmail']) ) { - - if(isset($_POST['media_enable'])) { - setPref($data_dir,$username,'newmail_enable',$_POST['media_enable']); - } else { - setPref($data_dir,$username,'newmail_enable',''); - } - if(isset($_POST['media_popup'])) { - setPref($data_dir,$username,'newmail_popup',$_POST['media_popup']); - } else { - setPref($data_dir,$username,'newmail_popup',''); - } - if(isset($_POST['media_allbox'])) { - setPref($data_dir,$username,'newmail_allbox',$_POST['media_allbox']); - } else { - setPref($data_dir,$username,'newmail_allbox',''); - } - if(isset($_POST['media_recent'])) { - setPref($data_dir,$username,'newmail_recent',$_POST['media_recent']); - } else { - setPref($data_dir,$username,'newmail_recent',''); - } - if(isset($_POST['media_changetitle'])) { - setPref($data_dir,$username,'newmail_changetitle',$_POST['media_changetitle']); - } else { - setPref($data_dir,$username,'newmail_changetitle',''); - } - if(isset($_POST['media_sel'])) { - if($_POST['media_sel'] == '(local media)') { - setPref($data_dir,$username,'newmail_media',StripSlashes($_POST['media_file'])); - } else { - setPref($data_dir,$username,'newmail_media',$_POST['media_sel']); - } + global $data_dir, $username; + + if ( sqgetGlobalVar('submit_newmail', $submit, SQ_POST) ) { + $media_enable = ''; + $media_popup = ''; + $media_allbox = ''; + $media_recent = ''; + $media_changetitle = ''; + $media_sel = ''; + + sqgetGlobalVar('media_enable', $media_enable, SQ_POST); + sqgetGlobalVar('media_popup', $media_popup, SQ_POST); + sqgetGlobalVar('media_allbox', $media_allbox, SQ_POST); + sqgetGlobalVar('media_recent', $media_recent, SQ_POST); + sqgetGlobalVar('media_changetitle', $media_changetitle, SQ_POST); + + setPref($data_dir,$username,'newmail_enable',$media_enable); + setPref($data_dir,$username,'newmail_popup', $media_popup); + setPref($data_dir,$username,'newmail_allbox',$media_allbox); + setPref($data_dir,$username,'newmail_recent',$media_recent); + setPref($data_dir,$username,'newmail_changetitle',$media_changetitle); + + if( sqgetGlobalVar('media_sel', $media_sel, SQ_POST) && + ($media_sel == '(none)' || $media_sel == '(local media)') ) { + removePref($data_dir,$username,'newmail_media'); } else { - setPref($data_dir,$username,'newmail_media',''); + setPref($data_dir,$username,'newmail_media',$media_sel); } echo html_tag( 'p', _("New Mail Notification options saved"), 'center' ); } @@ -136,7 +126,7 @@ $newmail_recent = getPref($data_dir,$username,'newmail_recent'); $newmail_enable = getPref($data_dir,$username,'newmail_enable'); - $newmail_media = getPref($data_dir, $username, 'newmail_media', '../plugins/newmail/sounds/Notify.wav'); + $newmail_media = getPref($data_dir, $username, 'newmail_media', '(none)'); $newmail_popup = getPref($data_dir, $username, 'newmail_popup'); $newmail_allbox = getPref($data_dir, $username, 'newmail_allbox'); $newmail_changetitle = getPref($data_dir, $username, 'newmail_changetitle'); @@ -149,8 +139,6 @@ $newmail_media, $newmail_enable, $newmail_popup, $newmail_recent, $newmail_changetitle, $imapConnection, $PHP_SELF; - /* temp hack to locate the sounds correct from the src dir */ - $newmail_media = SM_PATH . 'plugins/newmail/' . $newmail_media; if ($newmail_enable == 'on' || $newmail_popup == 'on' || $newmail_changetitle) { @@ -222,14 +210,14 @@ "\n"; } - if ($totalNew > 0 && $newmail_enable == 'on') { + if ($totalNew > 0 && $newmail_enable == 'on' && $newmail_media != '' ) { echo "\n"; } if ($totalNew > 0 && $newmail_popup == 'on') { echo "\n"; - } } } diff --git a/plugins/newmail/testsound.php b/plugins/newmail/testsound.php index b52c3651..d52b5ba5 100644 --- a/plugins/newmail/testsound.php +++ b/plugins/newmail/testsound.php @@ -13,27 +13,30 @@ define('SM_PATH','../../'); /* SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/global.php'); require_once(SM_PATH . 'functions/html.php'); -if (!isset($_GET['sound'])) { - $sound = 'Click.wav'; -} else { - $sound = $_GET['sound']; -} +displayHtmlHeader( _("Test Sound"), '', FALSE ); -$sound = str_replace('../plugins/newmail/', '', $sound); -$sound = str_replace('../', '', $sound); -$sound = str_replace("..\\", '', $sound); +echo ''."\n"; - displayHtmlHeader( _("Test Sound"), '', FALSE ); +if ( ! sqgetGlobalVar('sound', $sound, SQ_GET) ) { + $sound = 'Click.wav'; +} elseif ( $sound == '(none)' ) { + echo '


'. + '' . _("No sound specified") . '

'. + ''. + '
'. + ''; + return; +} - echo "\n". - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', +echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', "". '
'. - '' . _("Loading the sound...") . '

'. + '' . _("Loading the sound...") . '
'. '
'. ''; - ?>