1) Corrected errors with relative paths that prevented sounds from
authorebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 31 Mar 2003 04:18:21 +0000 (04:18 +0000)
committerebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 31 Mar 2003 04:18:21 +0000 (04:18 +0000)
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

plugins/newmail/newmail_opt.php
plugins/newmail/setup.php
plugins/newmail/testsound.php

index c463fec0a2345ee40915d62a8c15bf53b9303d81..24924db1f0e39a45ca7590d14a92e1edb4b8751a 100644 (file)
@@ -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');
 
 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', '<b>' . _("Options") . ' - ' . _("New Mail Notification") . '</b>', 'center', $color[0] )
                  html_tag( 'td', '<b>' . _("Options") . ' - ' . _("New Mail Notification") . '</b>', 'center', $color[0] )
-             ) . "\n" .
+            ) . "\n" .
              html_tag( 'tr' ) . "\n" .
                  html_tag( 'td', '', 'left' );
              html_tag( 'tr' ) . "\n" .
                  html_tag( 'td', '', 'left' );
-    if ($allowsound == "true") {
-        echo html_tag( 'p',
+if ($allowsound == "true") {
+     echo html_tag( 'p',
             _("Select <b>Enable Media Playing</b> 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.")
             _("Select <b>Enable Media Playing</b> 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 <b>Check all boxes, not just INBOX</b> 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 <b>Check all boxes, not just INBOX</b> option will check ALL of your folders for unseen mail, not just the inbox for notification.")
+           ) . "\n" .
+           html_tag( 'p',
                _("Selecting the <b>Show popup</b> option will enable the showing of a popup window when unseen mail is in your folders (requires JavaScript).")
            ) . "\n" .
            html_tag( 'p',
                _("Selecting the <b>Show popup</b> 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',
            );
     if ($allowsound == "true") {
         echo html_tag( 'p',
-                    _("Select from the list of <b>server files</b> the media file to play when new mail arrives.  Selecting <b>local media</b> will play the file specified in the <b>local media file</b> 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 <b>server files</b> the media file to play when new mail arrives.  If no file is specified, \"(none)\", no sound will be used.")
                ) . "\n";
     }
                ) . "\n";
     }
-    echo '<form action="../../src/options.php" method=post>'.
+    echo '<form action="'.sqm_baseuri().'src/options.php" method=post>'.
          html_tag( 'table', '', '', '', 'width="100%" cellpadding="0" cellspacing="2" border="0"' ) . "\n" .
              html_tag( 'tr' ) . "\n" .
                  html_tag( 'td', '&nbsp;', 'right', '', 'nowrap' ) . "\n";
     if ($allowsound == "true") {
          html_tag( 'table', '', '', '', 'width="100%" cellpadding="0" cellspacing="2" border="0"' ) . "\n" .
              html_tag( 'tr' ) . "\n" .
                  html_tag( 'td', '&nbsp;', 'right', '', 'nowrap' ) . "\n";
     if ($allowsound == "true") {
-                echo html_tag( 'td', '', 'left' ) .
-                            '<input type="checkbox" ';
+                echo html_tag( 'td', '', 'left' ) . 
+                     '<input type="checkbox" ';
         if ($media_enable == 'on') {
                 echo 'checked ';
         }
         if ($media_enable == 'on') {
                 echo 'checked ';
         }
@@ -113,35 +113,34 @@ require_once(SM_PATH . 'include/load_prefs.php');
             echo html_tag( 'tr' ) . "\n" .
                         html_tag( 'td', _("Select server file:"), 'right', '', 'nowrap' ) . "\n" .
                         html_tag( 'td', '', 'left' ) .
             echo html_tag( 'tr' ) . "\n" .
                         html_tag( 'td', _("Select server file:"), 'right', '', 'nowrap' ) . "\n" .
                         html_tag( 'td', '', 'left' ) .
-                            '<select name="media_sel">'.  "\n" .
-                            '<option value="(local media)">' . _("(local media)") . '</option>' .  "\n";
+                            '<select name="media_sel">'.  "\n".
+                            '<option value="(none)"';
+            if ( $media == '(none)') {
+                echo 'selected ';
+            }
+            echo '>' . _("(none)") . '</option>' .  "\n";
 
     // Iterate sound files for options
 
     // Iterate sound files for options
-
     $d = dir(SM_PATH . 'plugins/newmail/sounds');
     while($entry=$d->read()) {
     $d = dir(SM_PATH . 'plugins/newmail/sounds');
     while($entry=$d->read()) {
-        $fname = $d->path . "/" . $entry;
-        if ($entry != '..' && $entry != '.') {
-            echo "<option ";
+        $fname = get_location () . '/sounds/' . $entry;
+        if ($entry != '..' && $entry != '.' && $entry != 'CVS') {
+            echo '<option ';
             if ($fname == $media) {
             if ($fname == $media) {
-                echo "selected ";
+                echo 'selected ';
             }
             }
-            echo "value=\"" . $fname . "\">" . $entry . "</option>\n";
+            echo 'value="' . $fname . '">' . $entry . "</option>\n";
         }
     }
     $d->close();
     echo '</select>'.
                '<input type="submit" value=" ' . _("Try") . ' " name="test" onClick="'.
                     "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound',".
         }
     }
     $d->close();
     echo '</select>'.
                '<input type="submit" value=" ' . _("Try") . ' " name="test" onClick="'.
                     "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound',".
-                       "'width=150,height=30,scrollbars=no');".
+                    "'width=150,height=30,scrollbars=no');".
                     'return false;'.
                '">'.
             '</td>'.
          '</tr>'.
                     'return false;'.
                '">'.
             '</td>'.
          '</tr>'.
-         html_tag( 'tr', "\n" .
-             html_tag( 'td', _("Local Media File:"), 'right', '', 'nowrap' ) .
-             html_tag( 'td', '<input type="file" size="40" name="media_file">', 'left' )
-         ) . "\n" .
          html_tag( 'tr', "\n" .
              html_tag( 'td', _("Current File:"), 'right', '', 'nowrap' ) .
              html_tag( 'td', '<input type="hidden" value="' . $media . '" name="media_default">' . $media . '', 'left' )
          html_tag( 'tr', "\n" .
              html_tag( 'td', _("Current File:"), 'right', '', 'nowrap' ) .
              html_tag( 'td', '<input type="hidden" value="' . $media . '" name="media_default">' . $media . '', 'left' )
index ecc7af3c5128cdac0f24960bba4a406d3add6402..d925f57fc191da52b9bf4d11b7a68be321ce75f7 100644 (file)
@@ -24,6 +24,7 @@
     *
     * $Id$
     */
     *
     * $Id$
     */
+    include_once(SM_PATH . 'functions/display_messages.php');
 
     function CheckNewMailboxSound($imapConnection, $mailbox, $real_box, $delimeter, $unseen, &$total_new) {
     
 
     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"),
            /* 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
             );
                'desc' => _("This configures settings for playing sounds and/or showing popup windows when new mail arrives."),
                'js'   => TRUE
             );
     }
 
     function newmail_sav() {
     }
 
     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 {
             } 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' );
         }
             }
             echo html_tag( 'p', _("New Mail Notification options saved"), 'center' );
         }
         
         $newmail_recent = getPref($data_dir,$username,'newmail_recent');
         $newmail_enable = getPref($data_dir,$username,'newmail_enable');
         
         $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');
         $newmail_popup = getPref($data_dir, $username, 'newmail_popup');
         $newmail_allbox = getPref($data_dir, $username, 'newmail_allbox');
         $newmail_changetitle = getPref($data_dir, $username, 'newmail_changetitle');
                $newmail_media, $newmail_enable, $newmail_popup,
                $newmail_recent, $newmail_changetitle, $imapConnection, $PHP_SELF;
 
                $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) {
         if ($newmail_enable == 'on' ||
             $newmail_popup == 'on' ||
             $newmail_changetitle) {
                     "</script>\n";
             }
 
                     "</script>\n";
             }
 
-            if ($totalNew > 0 && $newmail_enable == 'on') {
+            if ($totalNew > 0 && $newmail_enable == 'on' && $newmail_media != '' ) {
                 echo "<EMBED SRC=\"$newmail_media\" HIDDEN=TRUE AUTOSTART=TRUE>\n";
             }
             if ($totalNew > 0 && $newmail_popup == 'on') {
                 echo "<SCRIPT LANGUAGE=\"JavaScript\">\n".
                     "<!--\n".
                     "function PopupScriptLoad() {\n".
                 echo "<EMBED SRC=\"$newmail_media\" HIDDEN=TRUE AUTOSTART=TRUE>\n";
             }
             if ($totalNew > 0 && $newmail_popup == 'on') {
                 echo "<SCRIPT LANGUAGE=\"JavaScript\">\n".
                     "<!--\n".
                     "function PopupScriptLoad() {\n".
-                        'window.open("../plugins/newmail/newmail.php", "SMPopup",'.
+                        'window.open("'.sqm_baseuri().'plugins/newmail/newmail.php", "SMPopup",'.
                                      "\"width=200,height=130,scrollbars=no\");\n".
                         "if (BeforePopupScript != null)\n".
                             "BeforePopupScript();\n".
                                      "\"width=200,height=130,scrollbars=no\");\n".
                         "if (BeforePopupScript != null)\n".
                             "BeforePopupScript();\n".
                     // More code from Tyler Akins
                     "// End -->\n".
                     "</script>\n";
                     // More code from Tyler Akins
                     "// End -->\n".
                     "</script>\n";
-
             }
         }
     }
             }
         }
     }
index b52c365103435ea3b916ace7b3dfb7b4af7cc030..d52b5ba5bbb0c2b6b012554f788d3e0d7c4dbe46 100644 (file)
@@ -13,27 +13,30 @@ define('SM_PATH','../../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/html.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 '<body bgcolor="'.$color[4].'" topmargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0>'."\n";
 
 
-   displayHtmlHeader( _("Test Sound"), '', FALSE );
+if ( ! sqgetGlobalVar('sound', $sound, SQ_GET) ) {
+    $sound = 'Click.wav';
+} elseif ( $sound == '(none)' ) {
+    echo '<center><form><br /><br />'.
+         '<b>' . _("No sound specified") . '</b><br /><br />'.
+         '<input type="button" name="close" value="' . _("Close") . '" onClick="window.close()">'.
+         '</form></center>'.
+         '</body></html>';
+    return;
+}
 
 
-   echo "<body bgcolor=\"$color[4]\" topmargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0>\n".
-        html_tag( 'table',
-            html_tag( 'tr',
-                html_tag( 'td',
+echo html_tag( 'table',
+         html_tag( 'tr',
+             html_tag( 'td',
                     "<embed src=\"$sound\" hidden=true autostart=true>".
                     '<br>'.
                     "<embed src=\"$sound\" hidden=true autostart=true>".
                     '<br>'.
-                    '<b>' . _("Loading the sound...") . '</b><br><br>'.
+                    '<b>' . _("Loading the sound...") . '</b><br>'.
                     '<form>'.
                     '<input type="button" name="close" value="  ' .
                     _("Close") .
                     '<form>'.
                     '<input type="button" name="close" value="  ' .
                     _("Close") .
@@ -43,5 +46,4 @@ $sound = str_replace("..\\", '', $sound);
             ) ,
         'center' ) .
         '</body></html>';
             ) ,
         'center' ) .
         '</body></html>';
-
 ?>
 ?>