add swf and mp3 support
[squirrelmail.git] / plugins / newmail / newmail_opt.php
index a097175105ab4c70169f0d544e6219c110d8456a..4b450c7bd0e25fa414c51d14a8b4b557e407e714 100644 (file)
@@ -1,14 +1,13 @@
 <?php
-
 /**
- * newmails_opt.php
+ * newmails_opt.php - options page
  *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * 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
  *
- * $Id$
+ * @version $Id$
  * @package plugins
  * @subpackage newmail
  */
 define('SM_PATH','../../');
 
 /* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/display_messages.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'include/load_prefs.php');
+include_once(SM_PATH . 'include/validate.php');
+/* sqm_baseuri function */
+include_once(SM_PATH . 'functions/display_messages.php');
+/** Plugin functions (also loads plugin's config) */
+include_once(SM_PATH . 'plugins/newmail/functions.php');
 
 displayPageHeader($color, 'None');
 
@@ -31,6 +30,7 @@ $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)');
+$media_userfile_name = getPref($data_dir,$username,'newmail_userfile_name','');
 
 // Set $allowsound to false if you don't want sound files available
 $allowsound = "true";
@@ -68,12 +68,12 @@ echo '</td></tr>' .
         html_tag( 'tr' ) .
             html_tag( 'td', '', 'center', $color[4] ) . "\n" . '<hr style="width: 25%; height: 1px;" />' . "\n";
 
-echo '<form action="'.sqm_baseuri().'src/options.php" method="post">' . "\n" .
+echo '<form action="'.sqm_baseuri().'src/options.php" method="post" enctype="multipart/form-data">' . "\n" .
         html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n";
 
 // Option: media_allbox
 echo html_tag( 'tr' ) .
-        html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'nowrap' ) .
+        html_tag( 'td', _("Check all boxes, not just INBOX").':', 'right', '', 'style="white-space: nowrap;"' ) .
             html_tag( 'td', '', 'left' ) .
                 '<input type="checkbox" ';
 if ($media_allbox == 'on') {
@@ -83,7 +83,7 @@ echo 'name="media_allbox" /></td></tr>' . "\n";
 
 // Option: media_recent
 echo html_tag( 'tr' ) .
-        html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'nowrap' ) .
+        html_tag( 'td', _("Count only messages that are RECENT").':', 'right', '', 'style="white-space: nowrap;"' ) .
             html_tag( 'td', '', 'left' ) .
                 '<input type="checkbox" ';
 if ($media_recent == 'on') {
@@ -93,7 +93,7 @@ echo 'name="media_recent" /></td></tr>' . "\n";
 
 // Option: media_changetitle
 echo html_tag( 'tr' ) .
-        html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'nowrap' ) .
+        html_tag( 'td', _("Change title on supported browsers").':', 'right', '', 'style="white-space: nowrap;"' ) .
             html_tag( 'td', '', 'left' ) .
                 '<input type="checkbox" ';
 if ($media_changetitle == 'on') {
@@ -103,7 +103,7 @@ echo 'name="media_changetitle" />&nbsp;('._("requires JavaScript to work").')</t
 
 // Option: media_popup
 echo html_tag( 'tr' ) .
-        html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'nowrap' ) .
+        html_tag( 'td', _("Show popup window on new mail").':', 'right', '', 'style="white-space: nowrap;"' ) .
             html_tag( 'td', '', 'left' ) .
                 '<input type="checkbox" ';
 if($media_popup == 'on') {
@@ -114,7 +114,7 @@ echo 'name="media_popup" />&nbsp;('._("requires JavaScript to work").')</td></tr
 if ($allowsound == "true") {
 // Option: media_enable
     echo html_tag( 'tr' ) .
-            html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'nowrap' ) .
+            html_tag( 'td', _("Enable Media Playing").':', 'right', '', 'style="white-space: nowrap;"' ) .
                 html_tag( 'td', '', 'left' ) .
                     '<input type="checkbox" ';
     if ($media_enable == 'on') {
@@ -124,7 +124,7 @@ if ($allowsound == "true") {
 
 // Option: media_sel
     echo html_tag( 'tr' ) .
-        html_tag( 'td', _("Select server file").':', 'right', '', 'nowrap' ) .
+        html_tag( 'td', _("Select server file").':', 'right', '', 'style="white-space: nowrap;"' ) .
             html_tag( 'td', '', 'left' ) .
                 '<select name="media_sel">' . "\n" .
                     '<option value="(none)"';
@@ -146,17 +146,65 @@ if ($allowsound == "true") {
         }
     }
     $d->close();
-    $media_output = ($media == '(none)') ? _("(none)") : substr($media, strrpos($media, '/')+1);
+    // display media selection
+    foreach($newmail_mmedia as $newmail_mm_name => $newmail_mm_data) {
+        echo '<option ';
+        if ($media=='mmedia_' . $newmail_mm_name) {
+            echo 'selected="selected" ';
+        }
+        echo 'value="mmedia_' . $newmail_mm_name . '">'
+            .htmlspecialchars($newmail_mm_name) . "</option>\n";
+    }
+    // display local file option
+    echo '<option ';
+    if ($media=='(userfile)') {
+        echo 'selected="selected" ';
+    }
+    echo 'value="(userfile)">'.
+        _("uploaded media file") . "</option>\n";
+    // end of local file option
+
+    // Set media file name
+    if ($media == '(none)') {
+        $media_output = _("none");
+    } elseif ($media == '(userfile)') {
+        $media_output = basename($media_userfile_name);
+    } elseif (preg_match("/^mmedia_+/",$media)) {
+        $media_output = preg_replace("/^mmedia_/",'',$media);
+    } else {
+        $media_output = substr($media, strrpos($media, '/')+1);
+    }
+
     echo '</select>'.
-        '<input type="submit" value="' . _("Try") . '" name="test" onClick="' .
+        '<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');" .
             'return false;' .
-            ' /"></td></tr>' .
-            html_tag( 'tr', "\n" .
-                html_tag( 'td', _("Current File:"), 'right', '', 'nowrap' ) .
+            '" /></td></tr>';
+    echo  '<tr>'.
+        '<td align="right" nowrap>' . _("Upload Media File:") .
+        '</td><td>'.
+        '<input type="file" size="40" name="media_file">'.
+        '</td>'.
+        '</tr>';
+
+    echo  '<tr>'.
+        '<td align="right" nowrap>' . _("Uploaded Media File:") .
+        '</td><td>'.
+        ($media_userfile_name!='' ? htmlspecialchars($media_userfile_name) : _("unavailable")).
+        '</td>'.
+        '</tr>';
+
+    if ($media_userfile_name!='') {
+        echo '<tr>'
+            .'<td colspan="2" align="center">'
+            .sprintf(_("Media file %s will be removed, if you upload other media file."),basename($media_userfile_name))
+            .'</td></tr>';
+    }
+    echo html_tag( 'tr', "\n" .
+                html_tag( 'td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"' ) .
                     html_tag( 'td', '<input type="hidden" value="' .
-                        htmlspecialchars($media) . '" name="media_default">' .
+                        htmlspecialchars($media) . '" name="media_default" />' .
                         htmlspecialchars($media_output) . '', 'left' )
              ) . "\n";
 }
@@ -164,8 +212,9 @@ echo html_tag( 'tr', "\n" .
     html_tag( 'td', '&nbsp;' ) .
         html_tag( 'td',
             '<input type="hidden" name="optmode" value="submit" />' .
+            '<input type="hidden" name="optpage" value="newmail" />' .
             '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />',
         'left' )
      ) . "\n";
 ?>
-</table></form></td></tr></table></td></tr></table></body></html>
+</table></form></td></tr></table></td></tr></table></body></html>
\ No newline at end of file