Bugfix by "Chiu Wai Pun" <pun@alumni.ust.hk>
[squirrelmail.git] / plugins / mail_fetch / options.php
index 73cf3bece6457ab34b8da3ab561bfa3133b346c8..93937ec0e0cacbfe16da70e7be8a030bf42dfa1a 100644 (file)
@@ -3,7 +3,7 @@
    /**
     **  mail_fetch/options.php
     **
-    **  Copyright (c) 1999-2001 The Squirrelmail Development Team
+    **  Copyright (c) 1999-2002 The SquirrelMail Project Team
     **  Licensed under the GNU GPL. For full terms see the file COPYING.
     **
     **  Setup of the mailfetch plugin.
             $mailfetch_server_number--;
             for ($i=$mf_sn;$i<$mailfetch_server_number;$i++) {
                 $tmp=$i+1;
-                setPref($data_dir,$username,"mailfetch_server_$mf_sn", getPref($data_dir, $username, "mailfetch_server_$tmp"));
-                setPref($data_dir,$username,"mailfetch_alias_$mf_sn", getPref($data_dir, $username, "mailfetch_alias_$tmp"));
-                setPref($data_dir,$username,"mailfetch_user_$mf_sn", getPref($data_dir, $username, "mailfetch_user_$tmp"));
-                setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass ) :""));
+                setPref($data_dir,$username,"mailfetch_server_$i", getPref($data_dir, $username, "mailfetch_server_$tmp"));
+                setPref($data_dir,$username,"mailfetch_alias_$i", getPref($data_dir, $username, "mailfetch_alias_$tmp"));
+                setPref($data_dir,$username,"mailfetch_user_$i", getPref($data_dir, $username, "mailfetch_user_$tmp"));
+                setPref($data_dir,$username,"mailfetch_pass_$i",(isset($mf_pass)?encrypt( $mf_pass ) :""));
                 // if( $mf_cypher <> 'on' ) setPref($data_dir,$username,"mailfetch_cypher", 'on');
-                setPref($data_dir,$username,"mailfetch_lmos_$mf_sn", getPref($data_dir, $username, "mailfetch_lmos_$tmp"));
-                setPref($data_dir,$username,"mailfetch_login_$mf_sn", getPref($data_dir, $username, "mailfetch_login_$tmp"));
-                setPref($data_dir,$username,"mailfetch_fref_$mf_sn", getPref($data_dir, $username, "mailfetch_fref_$tmp"));
-                setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn", getPref($data_dir, $username, "mailfetch_subfolder_$tmp"));
+                setPref($data_dir,$username,"mailfetch_lmos_$i", getPref($data_dir, $username, "mailfetch_lmos_$tmp"));
+                setPref($data_dir,$username,"mailfetch_login_$i", getPref($data_dir, $username, "mailfetch_login_$tmp"));
+                setPref($data_dir,$username,"mailfetch_fref_$i", getPref($data_dir, $username, "mailfetch_fref_$tmp"));
+                setPref($data_dir,$username,"mailfetch_subfolder_$i", getPref($data_dir, $username, "mailfetch_subfolder_$tmp"));
             }
             setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
         }
             '<tr><th align=right>' . _("Store in Folder:") . '</th><td>';
         $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
         $boxes = sqimap_mailbox_list($imapConnection);
-        echo '<SELECT NAME=mf_subfolder><OPTION SELECTED VALUE="">INBOX';
+        echo '<SELECT NAME=mf_subfolder>';
+        $boxes = sqimap_mailbox_list($imapConnection);
         for ($i = 0; $i < count($boxes); $i++) {
-            if (in_array('noinferiors', $boxes[$i]['flags'])) {
-                if ((strtolower($boxes[$i]["unformatted"]) == 'inbox') &&
-                    ($default_sub_of_inbox == true)) {
-                        $box = $boxes[$i]['unformatted'];
-                        $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
-                        echo "<OPTION VALUE=\"$box\">$box2";
-                } else {
-                        $box = $boxes[$i]['unformatted'];
-                        $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
-                        if (strtolower($imap_server_type) != 'courier' ||
-                            strtolower($box) != 'inbox.trash')
-                            echo "<OPTION VALUE=\"$box\">$box2";
+            if (!in_array('noselect', $boxes[$i]['flags'])) {
+                $box = $boxes[$i]['unformatted'];
+                $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+                if ( strtolower( $box2 ) == 'inbox' ) {
+                    $box2 = _("INBOX");
                 }
+                echo "<OPTION VALUE=\"$box\">$box2</option>\n";
             }
-        }
+        }        
         echo '</SELECT></td></tr>' .
             '<tr><th align=right>&nbsp;</th><td><input type=checkbox name=mf_lmos checked>' . _("Leave Mail on Server") . '</td></tr>' .
             '<tr><th align=right>&nbsp;</th><td><input type=checkbox name=mf_login>' . _("Check mail during login") . '</td></tr>' .
         $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
         $boxes = sqimap_mailbox_list($imapConnection);
         echo "<SELECT NAME=mf_subfolder>";
-        echo "<OPTION " . ($mailfetch_subfolder_[$mf_sn]==""?"SELECTED":"") . ' VALUE="">INBOX';
+        $boxes = sqimap_mailbox_list($imapConnection);
         for ($i = 0; $i < count($boxes); $i++) {
-            if (in_array('noinferiors', $boxes[$i]['flags'])) {
-                if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
-                    $default_sub_of_inbox) {
-                        $box = $boxes[$i]['unformatted'];
-                        $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
-                        echo "<OPTION " . (strcmp($mailfetch_subfolder_[$mf_sn],$box)==0?"SELECTED":"") . " VALUE=\"$box\">$box2";
-                } else {
-                        $box = $boxes[$i]['unformatted'];
-                        $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
-                        if (strtolower($imap_server_type) != 'courier' ||
-                            strtolower($box) != 'inbox.trash')
-                            echo "<OPTION " . (strcmp($mailfetch_subfolder_[$mf_sn],$box)==0?"SELECTED":"") . " VALUE=\"$box\">$box2";
+            if (!in_array('noselect', $boxes[$i]['flags'])) {
+                $box = $boxes[$i]['unformatted'];
+                $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+                if ( strtolower( $box2 ) == 'inbox' ) {
+                    $box2 = _("INBOX");
                 }
+                echo '<OPTION ' .
+                     (strcmp($mailfetch_subfolder_[$mf_sn],$box)==0?'SELECTED':'') .
+                     " VALUE=\"$box\">$box2</option>\n";
             }
-        }
+        }                
         echo '</SELECT></td></tr>' .
             '<tr><th align=right>&nbsp;</th>' .
             '<td><input type=checkbox name=mf_lmos ' . (($mailfetch_lmos_[$mf_sn] == 'on')?'checked':'') .
     }
 
     ?>
-</body></html>
\ No newline at end of file
+</body></html>