Usability terminolofy change.
[squirrelmail.git] / src / options_folder.php
index f986b91086c183442adbcd8d96d4d0f0c0345f89..18dc8d4b43ad2ca6058090c683485147c1f3fac6 100644 (file)
@@ -1,54 +1,32 @@
 <?php
-   /**
-    **  options_folder.php
-    **
-    **  Copyright (c) 1999-2000 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    **  Displays all options relating to folders
-    **
-    **  $Id$
-    **/
-
-   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);
-   sqimap_logout($imapConnection);
-?>
-   <br>
-<table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
-<tr><td bgcolor="<?php echo $color[0] ?>" align="center">
-
-      <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>';
-   else
-      echo '         <input type="text" name="folderprefix" value="'.$default_folder_prefix.'" size="35"><br>';
-?>
-            </td>
-         </tr>
-<?php }          
 
+/**
+ * options_folder.php
+ *
+ * Copyright (c) 1999-2001 The SquirrelMail Development Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Displays all options relating to folders
+ *
+ * $Id$
+ */
+
+require_once('../functions/imap.php');
+
+/* Define the group constants for the folder options page. */   
+define('SMOPT_GRP_SPCFOLDER', 0);
+define('SMOPT_GRP_FOLDERLIST', 1);
+
+/* Define the optpage load function for the folder options page. */
+function load_optpage_data_folder() {
+    global $username, $key, $imapServerAddress, $imapPort;
+    global $folder_prefix, $default_folder_prefix;
+
+    /* Get some imap data we need later. */
+    $imapConnection =
+        sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+    $boxes = sqimap_mailbox_list($imapConnection);
+    sqimap_logout($imapConnection);
 
     /* Build a simple array into which we will build options. */
     $optgrps = array();
     /******************************************************/
     /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
     /******************************************************/
-    define('SMOPT_GRP_SPCFOLDER', 0);
-    define('SMOPT_GRP_FOLDERLIST', 1);
 
     /*** Load the General Options into the array ***/
     $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
     $optvals[SMOPT_GRP_SPCFOLDER] = array();
 
+    if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
+    if ($show_prefix_option) {
+        $optvals[SMOPT_GRP_SPCFOLDER][] = array(
+            'name'    => 'folder_prefix',
+            'caption' => _("Folder Path"),
+            'type'    => SMOPT_TYPE_STRING,
+            'refresh' => SMOPT_REFRESH_FOLDERLIST,
+            'size'    => SMOPT_SIZE_LARGE
+        );
+    }
+
     $special_folder_values = array();
     foreach ($boxes as $folder) {
         if (strtolower($folder['unformatted']) != 'inbox') {
@@ -80,7 +67,8 @@
         'caption' => _("Trash Folder"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => $trash_folder_values
+        'posvals' => $trash_folder_values,
+        'save'    => 'save_option_trash_folder'
     );
     
     $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
         'caption' => _("Sent Folder"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => $sent_folder_values
+        'posvals' => $sent_folder_values,
+        'save'    => 'save_option_sent_folder'
     );
     
-    $drafts_none = array(SMPREF_NONE => _("Do not use Drafts"));
+    $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
     $draft_folder_values = array_merge($draft_none, $special_folder_values);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'draft_folder',
         'caption' => _("Draft Folder"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => $draft_folder_values
+        'posvals' => $draft_folder_values,
+        'save'    => 'save_option_draft_folder'
     );
 
     /*** Load the General Options into the array ***/
 
     $optvals[SMOPT_GRP_FOLDERLIST][] = array(
         'name'    => 'unseen_notify',
-        'caption' => _("Enable Unseen Message Notification"),
+        'caption' => _("Enable Unread Message Notification"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => array(SMPREF_UNSEEN_NONE  => _("No Notification"),
 
     $optvals[SMOPT_GRP_FOLDERLIST][] = array(
         'name'    => 'unseen_type',
-        'caption' => _("Unseen Message Notification Type"),
+        'caption' => _("Unread Message Notification Type"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => array(SMPREF_UNSEEN_ONLY  => _("Only Unseen"),
                            SMPREF_TIME_24HR => _("24-hour clock")) 
     );
 
+    /* Assemble all this together and return it as our result. */
+    $result = array(
+        'grps' => $optgrps,
+        'vals' => $optvals
+    );
+    return ($result);
+}
+
+/******************************************************************/
+/** Define any specialized save functions for this option page. ***/
+/******************************************************************/
+function save_option_trash_folder($option) {
+    global $data_dir, $username;
+
+    /* Set move to trash on or off. */
+    $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
+    setPref($data_dir, $username, 'move_to_trash', $trash_on);
 
-    /* Build and output the option groups. */
-    $option_groups = createOptionGroups($optgrps, $optvals);
-    printOptionGroups($option_groups);
-                 
-    echo '<TR><TD ALIGN="CENTER" VALIGN="MIDDLE" COLSPAN="2" NOWRAP><B>'
-         . _("Plugin Options") . "</B></TD></TR>\n";
-    OptionSubmit( 'submit_folder' );
-?>         
+    /* Now just save the option as normal. */
+    save_option($option);
+}
 
-      </table>
-   </form>
+function save_option_sent_folder($option) {
+    global $data_dir, $username;
 
-   <?php do_hook('options_folders_bottom'); ?>
+    /* Set move to sent on or off. */
+    $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
+    setPref($data_dir, $username, 'move_to_sent', $sent_on);
 
-    </td></tr>
-    </table>
+    /* Now just save the option as normal. */
+    save_option($option);
+}
 
-</td></tr>
-</table>
-</body></html>
+function save_option_draft_folder($option) {
+    global $data_dir, $username;
+
+    /* Set move to draft on or off. */
+    $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
+    setPref($data_dir, $username, 'save_as_draft', $draft_on);
+
+    /* Now just save the option as normal. */
+    save_option($option);
+}
+
+?>