Add option that allows users to have replies to their own messages sent to the recipi...
[squirrelmail.git] / include / options / folder.php
index 38f5bd130b72e70d632c3f17955651884f4aa972..e5abbdea8f608d5d5c3ed7c75d676a8dc2c40e0b 100644 (file)
@@ -3,31 +3,41 @@
 /**
  * options_folder.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * Displays all options relating to folders
  *
- * $Id$
+ * @copyright 1999-2012 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
  */
 
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/imap_general.php');
+/** SquirrelMail required files. */
+include(SM_PATH . 'functions/imap_general.php');
 
-/* Define the group constants for the folder options page. */   
+/* Define the group constants for the folder options page. */
 define('SMOPT_GRP_SPCFOLDER', 0);
 define('SMOPT_GRP_FOLDERLIST', 1);
 define('SMOPT_GRP_FOLDERSELECT', 2);
 
-/* Define the optpage load function for the folder options page. */
+/**
+ * This function builds an array with all the information about
+ * the options available to the user, and returns it. The options
+ * are grouped by the groups in which they are displayed.
+ * For each option, the following information is stored:
+ * - name: the internal (variable) name
+ * - caption: the description of the option in the UI
+ * - type: one of SMOPT_TYPE_*
+ * - refresh: one of SMOPT_REFRESH_*
+ * - size: one of SMOPT_SIZE_*
+ * - save: the name of a function to call when saving this option
+ * @return array all option information
+ */
 function load_optpage_data_folder() {
-    global $username, $key, $imapServerAddress, $imapPort;
-    global $folder_prefix, $default_folder_prefix, $show_prefix_option;
+    global $username, $imapServerAddress, $imapPort, $oTemplate, $nbsp,
+           $folder_prefix, $default_folder_prefix, $show_prefix_option;
 
     /* Get some imap data we need later. */
-    $imapConnection =
-        sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+    $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
     $boxes = sqimap_mailbox_list($imapConnection);
 
     /* Build a simple array into which we will build options. */
@@ -54,7 +64,7 @@ function load_optpage_data_folder() {
     }
 
     $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
-                                 'whatever'  => $boxes);
+                                 'ignore'  => $boxes);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'trash_folder',
         'caption' => _("Trash Folder"),
@@ -63,9 +73,20 @@ function load_optpage_data_folder() {
         'posvals' => $trash_folder_values,
         'save'    => 'save_option_trash_folder'
     );
-    
+
+    $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
+                                 'ignore'  => $boxes);
+    $optvals[SMOPT_GRP_SPCFOLDER][] = array(
+        'name'    => 'draft_folder',
+        'caption' => _("Draft Folder"),
+        'type'    => SMOPT_TYPE_FLDRLIST,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST,
+        'posvals' => $draft_folder_values,
+        'save'    => 'save_option_draft_folder'
+    );
+
     $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
-                                'whatever'  => $boxes);
+                                'ignore'  => $boxes);
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
         'name'    => 'sent_folder',
         'caption' => _("Sent Folder"),
@@ -74,16 +95,19 @@ function load_optpage_data_folder() {
         'posvals' => $sent_folder_values,
         'save'    => 'save_option_sent_folder'
     );
-    
-    $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
-                                 'whatever'  => $boxes);
+
     $optvals[SMOPT_GRP_SPCFOLDER][] = array(
-        'name'    => 'draft_folder',
-        'caption' => _("Draft Folder"),
-        'type'    => SMOPT_TYPE_FLDRLIST,
-        'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => $draft_folder_values,
-        'save'    => 'save_option_draft_folder'
+        'name'    => 'translate_special_folders',
+        'caption' => _("Translate Special Folders"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST
+    );
+
+    $optvals[SMOPT_GRP_SPCFOLDER][] = array(
+        'name'    => 'save_reply_with_orig',
+        'caption' => _("Save Replies with Original Message"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST
     );
 
     /*** Load the General Options into the array ***/
@@ -111,15 +135,12 @@ function load_optpage_data_folder() {
         'posvals' => $left_size_values
     );
 
-    $minute_str = _("Minutes");
     $left_refresh_values = array(SMPREF_NONE => _("Never"));
-    foreach (array(30,60,120,180,300,600) as $lr_val) {
+    foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
         if ($lr_val < 60) {
             $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
-        } else if ($lr_val == 60) {
-            $left_refresh_values[$lr_val] = "1 " . _("Minute");
         } else {
-            $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
+            $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
         }
     }
     $optvals[SMOPT_GRP_FOLDERLIST][] = array(
@@ -146,7 +167,7 @@ function load_optpage_data_folder() {
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
         'posvals' => array(SMPREF_UNSEEN_ONLY  => _("Only Unseen"),
-                           SMPREF_UNSEEN_TOTAL => _("Unseen and Total")) 
+                           SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
     );
 
     $optvals[SMOPT_GRP_FOLDERLIST][] = array(
@@ -169,23 +190,15 @@ function load_optpage_data_folder() {
         'caption' => _("Show Clock on Folders Panel"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => array( '1' => 'MM/DD/YY HH:MM',
-                            '2' => 'DD/MM/YY HH:MM',
-                            '3' => 'DDD, HH:MM',
-                            '4' => 'HH:MM:SS',
-                            '5' => 'HH:MM',
+        'posvals' => array( '0' => _("International date and time"),
+                            '1' => _("American date and time"),
+                            '2' => _("European date and time"),
+                            '3' => _("Show weekday and time"),
+                            '4' => _("Show time with seconds"),
+                            '5' => _("Show time"),
                             '6' => _("No Clock")),
     );
 
-    $optvals[SMOPT_GRP_FOLDERLIST][] = array(
-        'name'    => 'hour_format',
-        'caption' => _("Hour Format"),
-        'type'    => SMOPT_TYPE_STRLIST,
-        'refresh' => SMOPT_REFRESH_FOLDERLIST,
-        'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
-                           SMPREF_TIME_24HR => _("24-hour clock")) 
-    );
-
     $optvals[SMOPT_GRP_FOLDERLIST][] = array(
         'name'    => 'search_memory',
         'caption' => _("Memory Search"),
@@ -203,6 +216,12 @@ function load_optpage_data_folder() {
                             9 => '9')
     );
 
+    $optvals[SMOPT_GRP_FOLDERLIST][] = array(
+        'name'    => 'show_only_subscribed_folders',
+        'caption' => _("Show only subscribed folders"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_FOLDERLIST
+    );
 
     /*** Load the General Options into the array ***/
     $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
@@ -214,9 +233,14 @@ function load_optpage_data_folder() {
         'caption' => _("Selection List Style"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_NONE,
-        'posvals' => array( 0 => _("Long: ") . '"Folder' . $delim . 'Subfolder"',
-                            1 => _("Indented: ") .  '"&nbsp;&nbsp;&nbsp;&nbsp;' . 'Subfolder"',
-                            2 => _("Delimited: ") . '".&nbsp;' . 'Subfolder"')
+        'posvals' => array(
+            SMPREF_MAILBOX_SELECT_LONG =>
+                _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
+            SMPREF_MAILBOX_SELECT_INDENTED =>
+                _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"',
+            SMPREF_MAILBOX_SELECT_DELIMITED =>
+                _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'),
+        'htmlencoded' => true
     );
 
     /* Assemble all this together and return it as our result. */
@@ -231,37 +255,66 @@ function load_optpage_data_folder() {
 /******************************************************************/
 /** Define any specialized save functions for this option page. ***/
 /******************************************************************/
+
+/**
+ * Saves the trash folder option.
+ * @param object $option SquirrelOption object
+ * @since 1.3.2
+ */
 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);
+    if (strtolower($option->new_value)=='inbox') {
+        // make sure that it is not INBOX
+        error_option_save(_("You can't select INBOX as Trash folder."));
+    } else {
+        /* 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);
 
-    /* Now just save the option as normal. */
-    save_option($option);
+        /* Now just save the option as normal. */
+        save_option($option);
+    }
 }
 
+/**
+ * Saves the sent folder option.
+ * @param object $option SquirrelOption object
+ * @since 1.3.2
+ */
 function save_option_sent_folder($option) {
     global $data_dir, $username;
 
-    /* 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);
+    if (strtolower($option->new_value)=='inbox') {
+        // make sure that it is not INBOX
+        error_option_save(_("You can't select INBOX as Sent folder."));
+    } else {
+        /* 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);
 
-    /* Now just save the option as normal. */
-    save_option($option);
+        /* Now just save the option as normal. */
+        save_option($option);
+    }
 }
 
+/**
+ * Saves the draft folder option.
+ * @param object $option SquirrelOption object
+ * @since 1.3.2
+ */
 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);
+    if (strtolower($option->new_value)=='inbox') {
+        // make sure that it is not INBOX
+        error_option_save(_("You can't select INBOX as Draft folder."));
+    } else {
+        /* 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);
+    }
 }
-
-?>