This closes my feature request #474658
[squirrelmail.git] / src / options_folder.php
index a9efbba2eab52999dff296305aff723247727c37..3e86c5bb99d1936ef77078e08c428227b2e0e6b1 100644 (file)
     **
     **  Displays all options relating to folders
     **
+    **  $Id$
     **/
 
-   session_start();
-
-   if (!isset($config_php))
-      include("../config/config.php");
-   if (!isset($strings_php))
-      include("../functions/strings.php");
-   if (!isset($page_header_php))
-      include("../functions/page_header.php");
-   if (!isset($display_messages_php))
-      include("../functions/display_messages.php");
-   if (!isset($imap_php))
-      include("../functions/imap.php");
-   if (!isset($array_php))
-      include("../functions/array.php");
-   if (!isset($i18n_php))
-      include("../functions/i18n.php");
-
-   include("../src/load_prefs.php");
-   displayPageHeader($color, "None");
+   require_once('../src/validate.php');
+   require_once('../functions/display_messages.php');
+   require_once('../functions/imap.php');
+   require_once('../functions/array.php');
+   require_once('../functions/plugin.php');
+   require_once('../functions/options.php');   
+   
+   displayPageHeader($color, 'None');
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   $boxes = sqimap_mailbox_list($imapConnection, $boxes);
+   $boxes = sqimap_mailbox_list($imapConnection);
    sqimap_logout($imapConnection);
 ?>
    <br>
-   <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
-      <center><b><?php echo _("Options") . " - " . _("Folder Preferences"); ?></b></center>
-   </td></tr></table>
+<table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
+<tr><td bgcolor="<?php echo $color[0] ?>" align="center">
 
-   <form action="options.php" method=post>
-      <table width=100% cellpadding=0 cellspacing=2 border=0>
+      <b><?php echo _("Options") . " - " . _("Folder Preferences"); ?></b>
+
+    <table width="100%" border="0" cellpadding="1" cellspacing="1">
+    <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
+
+   <form name="f" action="options.php" method="post"><br>
+
+      <table width="100%" cellpadding="2" cellspacing="0" border="0">
 
 <?php if ($show_prefix_option == true) {   ?>   
          <tr>
             <td align=right nowrap><?php echo _("Folder Path"); ?>:
             </td><td>
 <?php if (isset ($folder_prefix))
-      echo "         <input type=text name=folderprefix value=\"$folder_prefix\" size=35><br>";
+      echo '         <input type="text" name="folderprefix" value="'.$folder_prefix.'" size="35"><br>';
    else
-      echo "         <input type=text name=folderprefix value=\"$default_folder_prefix\" size=35><br>";
+      echo '         <input type="text" name="folderprefix" value="'.$default_folder_prefix.'" size="35"><br>';
 ?>
             </td>
          </tr>
 <?php }          
 
-   // TRASH FOLDER
-   echo "<tr><td nowrap align=right>";
-   echo _("Trash Folder:");
-   echo "</td><td>";
-      echo "<TT><SELECT NAME=trash>\n";
-      if ($move_to_trash == true)
-         echo "<option value=none>" . _("Don't use Trash");
-      else
-         echo "<option value=none selected>" . _("Do not use Trash");
-      for ($i = 0; $i < count($boxes); $i++) {
-         $use_folder = true;
-         if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
-            $use_folder = false;
-         }
-         if ($use_folder == true) {
-            $box = $boxes[$i]["unformatted-dm"];
-            $box2 = replace_spaces($boxes[$i]["formatted"]);
-            if (($boxes[$i]["unformatted"] == $trash_folder) && ($move_to_trash == true))
-               echo "         <OPTION SELECTED VALUE=\"$box\">$box2\n";
-            else
-               echo "         <OPTION VALUE=\"$box\">$box2\n";
-         }
-      }
-      echo "</SELECT></TT>\n";
-   echo "</td></tr>";  
-
-
-   // SENT FOLDER
-   echo "<tr><td nowrap align=right>";
-   echo _("Sent Folder:");
-   echo "</td><td>";
-      echo "<TT><SELECT NAME=sent>\n";
-      if ($move_to_sent == true)
-         echo "<option value=none>" . _("Don't use Sent");
-      else
-         echo "<option value=none selected>" . _("Do not use Sent");
-      for ($i = 0; $i < count($boxes); $i++) {
-         $use_folder = true;
-         if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
-            $use_folder = false;
-         }
-         if ($use_folder == true) {
-            $box = $boxes[$i]["unformatted-dm"];
-            $box2 = replace_spaces($boxes[$i]["formatted"]);
-            if (($boxes[$i]["unformatted"] == $sent_folder) && ($move_to_sent == true))
-               echo "         <OPTION SELECTED VALUE=\"$box\">$box2\n";
-            else
-               echo "         <OPTION VALUE=\"$box\">$box2\n";
-         }
-      }
-      echo "</SELECT></TT>\n";
-   echo "</td></tr>";  
-?>
-         <tr>
-            <td valign=top align=right>
-               <br>
-               <?php echo _("Unseen message notification"); ?>:
-            </td>
-            <td>
-               <input type=radio name=unseennotify value=1<?php if ($unseen_notify == 1) echo " checked"; ?>> <?php echo _("No notification") ?><br>
-               <input type=radio name=unseennotify value=2<?php if ($unseen_notify != 1 && $unseen_notify != 3) echo " checked"; ?>> <?php echo _("Only INBOX") ?><br>
-               <input type=radio name=unseennotify value=3<?php if ($unseen_notify == 3) echo " checked"; ?>> <?php echo _("All Folders") ?><br>
-               <br>
-            </td>
-         </tr>
-         <tr>
-            <td valign=top align=right>
-               <br>
-               <?php echo _("Unseen message notification type"); ?>:
-            </td>
-            <td>
-               <input type=radio name=unseentype value=1<?php if ($unseen_type < 2 || $unseen_type > 2) echo " checked"; ?>> <?php echo _("Only unseen"); ?> - (4)<br> 
-               <input type=radio name=unseentype value=2<?php if ($unseen_type == 2) echo " checked"; ?>> <?php echo _("Unseen and Total"); ?> - (4/27)
-            </td>
-         </tr>
-         <tr>
-            <td>&nbsp;
-            </td><td>
-               <input type="submit" value="Submit" name="submit_folder">
-            </td>
-         </tr>
+    /* Build a simple array into which we will build options. */
+    $optvals = array();
+
+    $special_folder_values = array();
+    foreach ($boxes as $folder) {
+        if (strtolower($folder['unformatted']) != 'inbox') {
+            $real_value = $folder['unformatted-dm'];
+            $disp_value = str_replace(' ', '&nbsp;', $folder['formatted']);
+            $special_folder_values[$real_value] = $disp_value;
+        }
+    }
+
+    $trash_none = array(SMPREF_NONE => _("Do not use Trash"));
+    $trash_folder_values = array_merge($trash_none, $special_folder_values);
+    $optvals[] = array(
+        'name'    => 'trash_folder',
+        'caption' => _("Trash Folder"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => $trash_folder_values
+    );
+    
+    $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
+    $sent_folder_values = array_merge($sent_none, $special_folder_values);
+    $optvals[] = array(
+        'name'    => 'sent_folder',
+        'caption' => _("Sent Folder"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => $sent_folder_values
+    );
+    
+    $drafts_none = array(SMPREF_NONE => _("Do not use Drafts"));
+    $draft_folder_values = array_merge($draft_none, $special_folder_values);
+    $optvals[] = array(
+        'name'    => 'draft_folder',
+        'caption' => _("Draft Folder"),
+        'type'    => SMOPT_TYPE_STRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => $draft_folder_values
+    );
+
+    /* Build all these values into an array of SquirrelOptions objects. */
+    $options = createOptionArray($optvals);
+
+    /* Print the row for each option. */
+    foreach ($options as $option) {
+        if ($option->type != SMOPT_TYPE_HIDDEN) {
+            echo "<TR>\n";
+            echo '  <TD ALIGN="RIGHT" VALIGN="MIDDLE" NOWRAP>'
+               . $option->caption . ":</TD>\n";
+            echo '  <TD>' . $option->createHTMLWidget() . "</TD>\n";
+            echo "</TR>\n";
+        } else {
+            echo $option->createHTMLWidget();
+        }
+    }
+
+   // if( $unseen_notify == '' )
+   //   $unseen_notify = '2';
+   OptionRadio( _("Unseen message notification"),
+                'unseennotify',
+                array( 1 => _("No notification"),
+                       2 => _("Only INBOX"),
+                       3 => _("All Folders") ),
+                $unseen_notify, '', '',
+                '<br>' );
+    OptionRadio( _("Unseen message notification type"),
+                 'unseentype',
+                 array( 1 => _("Only unseen"),
+                        2 => _("Unseen and Total") ),
+                 $unseen_type, '', '',
+                 '<br>' );
+    OptionCheck( _("Collapseable folders"),
+                 'collapsefolders',
+                 $collapse_folders,
+                 _("Enable Collapseable Folders") );
+   OptionSelect( '<b>' . _("Show Clock on Folders Panel") . '</b> ' . _("Date format"),
+                 'dateformat',
+                 array( '1' => 'MM/DD/YY HH:MM',
+                        '2' => 'DD/MM/YY HH:MM',
+                        '3' => 'DDD, HH:MM',
+                        '4' => 'HH:MM:SS',
+                        '5' => 'HH:MM',
+                        '6' => _("No Clock") ),
+                 $date_format );
+   OptionSelect( _("Hour format"),
+                 'hourformat',
+                 array( '1' => _("24-hour clock"),
+                        '2' => _("12-hour clock") ),
+                 $hour_format );     
+                 
+   echo '<tr><td colspan=2><hr noshade></td></tr>';
+   do_hook("options_folders_inside");
+   OptionSubmit( 'submit_folder' );
+?>         
+
       </table>
    </form>
+
+   <?php do_hook('options_folders_bottom'); ?>
+
+    </td></tr>
+    </table>
+
+</td></tr>
+</table>
 </body></html>