Browse Source

Preferences bugfix

philippe_mingo 23 years ago
parent
commit
04c07e532c
2 changed files with 60 additions and 77 deletions
  1. 60 32
      plugins/translate/options.php
  2. 0 45
      plugins/translate/setup.php

+ 60 - 32
plugins/translate/options.php

@@ -9,35 +9,61 @@
    chdir('..');
 
    session_start();
-
-   if (!isset($config_php))
-      include_once('../config/config.php');
-   if (!isset($strings_php))
-      include_once('../functions/strings.php');
-   if (!isset($page_header_php))
-      include_once('../functions/page_header.php');
-   if (!isset($display_messages_php))
-      include_once('../functions/display_messages.php');
-   if (!isset($imap_php))
-      include_once('../functions/imap.php');
-   if (!isset($array_php))
-      include_once('../functions/array.php');
-   if (!isset($i18n_php))
-      include_once('../functions/i18n.php');
-
-
+   
+   require_once('../config/config.php');
+   require_once('../functions/strings.php');
+   require_once('../functions/page_header.php');
+   require_once('../functions/display_messages.php');
+   require_once('../functions/imap.php');
+   require_once('../functions/array.php');
+   require_once('../functions/i18n.php');
    require_once('../src/load_prefs.php');
    displayPageHeader($color, 'None');
 
-  $translate_server = getPref($data_dir, $username, 'translate_server');
-  if ($translate_server == '')
+    if ($submit_translate) {
+        if (isset($translate_translate_server)) {
+            setPref($data_dir, $username, 'translate_server', $translate_translate_server);
+        } else {
+            setPref($data_dir, $username, 'translate_server', 'babelfish');
+        }
+
+        if (isset($translate_translate_location)) {
+            setPref($data_dir, $username, 'translate_location', $translate_translate_location);
+        } else {
+            setPref($data_dir, $username, 'translate_location', 'center');
+        }
+
+        if (isset($translate_translate_show_read)) {
+            setPref($data_dir, $username, 'translate_show_read', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_show_read', '');
+        }
+
+        if (isset($translate_translate_show_send)) {
+            setPref($data_dir, $username, 'translate_show_send', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_show_send', '');
+        }
+
+        if (isset($translate_translate_same_window)) {
+           setPref($data_dir, $username, 'translate_same_window', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_same_window', '');
+        }
+    }
+
+    $translate_server = getPref($data_dir, $username, 'translate_server');
+    if ($translate_server == '') {
     $translate_server = 'babelfish';
-  $translate_location = getPref($data_dir, $username, 'translate_location');
-  if ($translate_location == '')
+    }
+    $translate_location = getPref($data_dir, $username, 'translate_location');
+    if ($translate_location == '') {
     $translate_location = 'center';
-  $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
-  $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
-  $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
+    }
+    $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
+    $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
+    $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
+  
 
    function ShowOption($Var, $value, $Desc)
    {
@@ -90,14 +116,14 @@
    </ul>
    <p>
 <?php
-   echo _("You also decide if you want the translation box displayed, and where it will be located.");
-?></p>
-
-   <form action="../../src/options.php" method=post>
-   <table border=0 cellpadding=0 cellspacing=2>
-   <tr><td align=right nowrap><?php echo _("Select your translator:"); ?></td>
-       <td><select name="translate_translate_server">
-<?PHP
+   echo _("You also decide if you want the translation box displayed, and where it will be located.") .
+        "<form action=\"$PHP_SELF\" method=post>".
+        '<table border=0 cellpadding=0 cellspacing=2>'.
+            '<tr><td align=right nowrap>' .
+             _("Select your translator:") .
+             '</td>'.
+            '<td><select name="translate_translate_server">';
+
     ShowOption('server', 'babelfish', 'Babelfish');
     ShowOption('server', 'go', 'Go.com');
     ShowOption('server', 'dictionary', 'Dictionary.com');
@@ -135,3 +161,5 @@
    '</table>'.
    '</form>'.
 "</body></html>\n";
+
+?>

+ 0 - 45
plugins/translate/setup.php

@@ -28,7 +28,6 @@ function squirrelmail_plugin_init_translate() {
 
   $squirrelmail_plugin_hooks['read_body_bottom']['translate'] = 'translate_read_form';
   $squirrelmail_plugin_hooks['optpage_register_block']['translate'] = 'translate_optpage_register_block';
-  $squirrelmail_plugin_hooks['options_save']['translate'] = 'translate_sav';
   $squirrelmail_plugin_hooks['loading_prefs']['translate'] = 'translate_pref';
   $squirrelmail_plugin_hooks['compose_button_row']['translate'] = 'translate_button';
 }
@@ -100,50 +99,6 @@ function translate_optpage_register_block() {
     );
 }
 
-function translate_sav() {
-    global $username,$data_dir;
-    global $submit_translate, $translate_translate_server;
-    global $translate_translate_location;
-    global $translate_translate_show_read;
-    global $translate_translate_show_send;
-    global $translate_translate_same_window;
-  
-    if ($submit_translate) {
-        if (isset($translate_translate_server)) {
-            setPref($data_dir, $username, 'translate_server', $translate_translate_server);
-        } else {
-            setPref($data_dir, $username, 'translate_server', 'babelfish');
-        }
-
-        if (isset($translate_translate_location)) {
-            setPref($data_dir, $username, 'translate_location', $translate_translate_location);
-        } else {
-            setPref($data_dir, $username, 'translate_location', 'center');
-        }
-
-        if (isset($translate_translate_show_read)) {
-            setPref($data_dir, $username, 'translate_show_read', '1');
-        } else {
-            setPref($data_dir, $username, 'translate_show_read', '');
-        }
-
-        if (isset($translate_translate_show_send)) {
-            setPref($data_dir, $username, 'translate_show_send', '1');
-        } else {
-            setPref($data_dir, $username, 'translate_show_send', '');
-        }
-
-        if (isset($translate_translate_same_window)) {
-           setPref($data_dir, $username, 'translate_same_window', '1');
-        } else {
-            setPref($data_dir, $username, 'translate_same_window', '');
-        }
-
-        echo '<center>Translation options saved.</center>';
-    }
-}
-
-
 function translate_pref() { 
     global $username, $data_dir;
     global $translate_server, $translate_location;