don't list index.php in sound options. issue specific to 1.5.1cvs and 1.4.6cvs
[squirrelmail.git] / plugins / newmail / newmail_opt.php
index f028ec60a37a2cb8be54e171652090e20fa435ad..5b418c9344940708052896e115b496dd02a1973c 100644 (file)
@@ -1,12 +1,12 @@
 <?php
+
 /**
  * newmails_opt.php - options page
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * Displays all options relating to new mail sounds
  *
+ * @copyright &copy; 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage newmail
@@ -105,14 +105,14 @@ echo 'name="media_popup" />&nbsp;<small>('._("requires JavaScript to work").')</
 
 echo html_tag( 'tr' )
      . html_tag('td',_("Width of popup window:"),'right','', 'style="white-space: nowrap;"')
-     . html_tag('td','<input type="text" name="popup_width" value="' 
+     . html_tag('td','<input type="text" name="popup_width" value="'
                 . (int)$newmail_popup_width . '" size="3" maxlengh="3" />'
                 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
      . "</tr>\n";
 
 echo html_tag( 'tr' )
      . html_tag('td',_("Height of popup window:"),'right','', 'style="white-space: nowrap;"')
-     . html_tag('td','<input type="text" name="popup_height" value="' 
+     . html_tag('td','<input type="text" name="popup_height" value="'
                 . (int)$newmail_popup_height . '" size="3" maxlengh="3" />'
                 . '&nbsp;<small>(' . _("If set to 0, reverts to default value") . ')</small>','left')
      . "</tr>\n";
@@ -141,13 +141,13 @@ if ($newmail_allowsound) {
     // Iterate sound files for options
     $d = dir(SM_PATH . 'plugins/newmail/sounds');
     while($entry=$d->read()) {
-        $fname = get_location () . '/sounds/' . $entry;
-        if ($entry != '..' && $entry != '.' && $entry != 'CVS') {
+        // $fname = get_location () . '/sounds/' . $entry;
+        if ($entry != '..' && $entry != '.' && $entry != 'CVS' && $entry != 'index.php') {
             echo '<option ';
-            if ($fname == $newmail_media) {
+            if ($entry == $newmail_media) {
                 echo 'selected="selected" ';
             }
-            echo 'value="' . htmlspecialchars($fname) . '">' .
+            echo 'value="' . htmlspecialchars($entry) . '">' .
                 htmlspecialchars($entry) . "</option>\n";
         }
     }
@@ -161,14 +161,17 @@ if ($newmail_allowsound) {
         echo 'value="mmedia_' . $newmail_mm_name . '">'
             .htmlspecialchars($newmail_mm_name) . "</option>\n";
     }
-    // display local file option
-    echo '<option ';
-    if ($newmail_media=='(userfile)') {
-        echo 'selected="selected" ';
+
+    if($newmail_uploadsounds) {
+        // display local file option
+        echo '<option ';
+        if ($newmail_media=='(userfile)') {
+            echo 'selected="selected" ';
+        }
+        echo 'value="(userfile)">'.
+            _("uploaded media file") . "</option>\n";
+        // end of local file option
     }
-    echo 'value="(userfile)">'.
-        _("uploaded media file") . "</option>\n";
-    // end of local file option
 
     // Set media file name
     if ($newmail_media == '(none)') {
@@ -178,7 +181,7 @@ if ($newmail_allowsound) {
     } elseif (preg_match("/^mmedia_+/",$newmail_media)) {
         $media_output = preg_replace("/^mmedia_/",'',$newmail_media);
     } else {
-        $media_output = substr($newmail_media, strrpos($newmail_media, '/')+1);
+        $media_output = basename($newmail_media);
     }
 
     echo '</select>'.
@@ -187,21 +190,24 @@ if ($newmail_allowsound) {
             "'width=150,height=30,scrollbars=no');" .
             'return false;' .
             '" /></td></tr>';
-    echo  html_tag('tr')
-        . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
-        . html_tag('td','<input type="file" size="40" name="media_file">')
-        . "</tr>\n";
-
-    echo  html_tag('tr')
-        . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
-        . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
-        ."</tr>\n";
-
-    if ($newmail_userfile_name!='') {
-        echo '<tr>'
-            .'<td colspan="2" align="center">'
-            .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
-            .'</td></tr>';
+    if ($newmail_uploadsounds) {
+        // upload form
+        echo  html_tag('tr')
+            . html_tag('td',_("Upload Media File:"),'right','','style="white-space: nowrap;"')
+            . html_tag('td','<input type="file" size="40" name="media_file">')
+            . "</tr>\n";
+        // display currently uploaded file information
+        echo  html_tag('tr')
+            . html_tag('td',_("Uploaded Media File:"),'right','','style="white-space: nowrap;"')
+            . html_tag('td',($newmail_userfile_name!='' ? htmlspecialchars($newmail_userfile_name) : _("unavailable")))
+            ."</tr>\n";
+    
+        if ($newmail_userfile_name!='') {
+            echo '<tr>'
+                .'<td colspan="2" align="center">'
+                .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($newmail_userfile_name))
+                .'</td></tr>';
+        }
     }
     echo html_tag( 'tr', "\n" .
                 html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .