Moving template util file
[squirrelmail.git] / include / options / folder.php
index d0dbd55807ca8db9b3546a84f081b40a7ceca41a..4ac4f42b2603254d10ad358067a1235d99e61f73 100644 (file)
@@ -3,18 +3,16 @@
 /**
  * options_folder.php
  *
- * 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 folders
  *
+ * @copyright © 1999-2006 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');
+include(SM_PATH . 'functions/imap_general.php');
 
 /* Define the group constants for the folder options page. */
 define('SMOPT_GRP_SPCFOLDER', 0);
@@ -35,12 +33,11 @@ define('SMOPT_GRP_FOLDERSELECT', 2);
  * @return array all option information
  */
 function load_optpage_data_folder() {
-    global $username, $key, $imapServerAddress, $imapPort;
+    global $username, $imapServerAddress, $imapPort;
     global $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. */
@@ -99,6 +96,13 @@ function load_optpage_data_folder() {
         'save'    => 'save_option_sent_folder'
     );
 
+    $optvals[SMOPT_GRP_SPCFOLDER][] = array(
+        '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"),
@@ -250,44 +254,63 @@ function load_optpage_data_folder() {
 
 /**
  * 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);
+    }
 }
-
-?>
\ No newline at end of file