- Fix disabling password encryption in mail_fetch (#1738001).
[squirrelmail.git] / plugins / mail_fetch / options.php
index 4f9abd17e8db460b7b5ad3fa641176d6bbbe366e..35eb094e0e6e6ad7b8cc5e185a2fd138145f80fa 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Setup of the mailfetch plugin.
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -55,7 +55,7 @@ sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST);
 
 /* end globals */
 
-displayPageHeader( $color, 'None' );
+displayPageHeader( $color );
 
 switch( $mf_action ) {
  case 'add':
@@ -65,8 +65,16 @@ switch( $mf_action ) {
      setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
      setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
      setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
-     setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass )    :""));
-     if( isset($mf_cypher) && $mf_cypher <> 'on' ) SetPref($data_dir,$username,'mailfetch_cypher',    'on');
+     $pass = "";
+     if ( isset($mf_pass) ) {
+        if ( isset($mf_cypher) && $mf_cypher == 'on' ) {
+            setPref($data_dir,$username,"mailfetch_cypher", ($mf_cypher == 'on' ? 'on' : ''));
+            $pass = encrypt($mf_pass);
+        } else {
+            $pass = $mf_pass;
+        }
+     }
+     setPref($data_dir,$username,"mailfetch_pass_$mf_sn",$pass);
      setPref($data_dir,$username,"mailfetch_lmos_$mf_sn",(isset($mf_lmos)?$mf_lmos:""));
      setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
      setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
@@ -84,8 +92,17 @@ switch( $mf_action ) {
      setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
      setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
      setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
-     setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass )    :""));
-     if( $mf_cypher <> 'on' ) setPref($data_dir,$username,"mailfetch_cypher", 'on');
+     $pass = "";
+     if ( isset($mf_pass) ) {
+        if ( isset($mf_cypher) && $mf_cypher == 'on' ) {
+            setPref($data_dir,$username,"mailfetch_cypher", 'on');
+            $pass = encrypt($mf_pass);
+        } else {
+            setPref($data_dir,$username,"mailfetch_cypher", '');
+            $pass = $mf_pass;
+        }
+     }
+     setPref($data_dir,$username,"mailfetch_pass_$mf_sn",$pass);
      setPref($data_dir,$username,"mailfetch_lmos_$mf_sn",(isset($mf_lmos)?$mf_lmos:""));
      setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
      setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
@@ -426,4 +443,4 @@ switch( $mf_action ) {
                    'center', '', 'width="70%"' );
 }
 
-$oTemplate->display('footer.tpl');
\ No newline at end of file
+$oTemplate->display('footer.tpl');