Add RFC 2231 support. Thanks to Piotr Pawlow. (#2501379)
[squirrelmail.git] / plugins / mail_fetch / options.php
index 81780f19e94a4803d60c2170309f2646ed7c52d4..e74766f4cb119ee1d9d9f3f111e9da48d24de13e 100644 (file)
@@ -20,6 +20,11 @@ include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
 include_once(SM_PATH . 'functions/imap_general.php');
 include_once(SM_PATH . 'functions/forms.php');
 
+// don't load this page if this plugin is not enabled
+//
+global $plugins;
+if (!in_array('mail_fetch', $plugins)) exit;
+
 /* globals */
 sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 
@@ -55,7 +60,7 @@ sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST);
 
 /* end globals */
 
-displayPageHeader( $color, 'None' );
+displayPageHeader( $color );
 
 switch( $mf_action ) {
  case 'add':
@@ -65,7 +70,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 )    :""));
+     $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:""));
@@ -83,8 +97,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 )    :""));
-     setPref($data_dir,$username,"mailfetch_cypher", ($mf_cypher == 'on' ? '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:""));