Don't give option to change sending charset in IMP
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Jan 2011 19:14:03 +0000 (12:14 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Jan 2011 19:27:24 +0000 (12:27 -0700)
Always use value from Horde_Registry::getEmailCharset().

imp/compose.php
imp/lib/Compose.php
imp/templates/imp/compose/compose.html

index 3cbdc4c..efc1877 100644 (file)
@@ -128,14 +128,6 @@ try {
 $imp_ui = new IMP_Ui_Compose();
 $stationery = $injector->getInstance('IMP_Compose_Stationery');
 
-/* Set charset defaults. */
-$charset = $prefs->isLocked('sending_charset')
-    ? $prefs->getValue('sending_charset')
-    : $vars->charset;
-if ($charset) {
-    $imp_compose->charset = $charset;
-}
-
 /* Is this a popup window? */
 $isPopup = ($prefs->getValue('compose_popup') || $vars->popup);
 
@@ -234,7 +226,6 @@ case 'draft':
         if (!is_null($rtemode)) {
             $rtemode = ($result['mode'] == 'html');
         }
-        $charset = $result['charset'];
         $msg = $result['msg'];
         $header = array_merge($header, $result['header']);
         if (!is_null($result['identity']) &&
@@ -286,8 +277,6 @@ case 'reply_list':
         break;
     }
     $title .= ' ' . $header['subject'];
-
-    $charset = $reply_msg['charset'];
     break;
 
 case 'forward_attach':
@@ -307,7 +296,6 @@ case 'forward_both':
     $format = $fwd_msg['format'];
     $rtemode = ($rtemode || (!is_null($rtemode) && ($format == 'html')));
     $title = $header['title'];
-    $charset = $fwd_msg['charset'];
     break;
 
 case 'redirect_compose':
@@ -817,22 +805,6 @@ if ($redirect) {
     $t->set('help-subject', Horde_Help::link('imp', 'compose-subject'));
 
     $t->set('set_priority', $prefs->getValue('set_priority'));
-    $t->set('unlocked_charset', !$prefs->isLocked('sending_charset'));
-    if ($t->get('unlocked_charset')) {
-        $t->set('charset_label', Horde::label('charset', _("C_harset")));
-        $t->set('charset_tabindex', ++$tabindex);
-        $charset_array = array();
-        $enc_list = $registry->nlsconfig->encodings;
-        asort($enc_list);
-        foreach (array_merge(array('' => _("Default")), $enc_list) as $encoding => $label) {
-            $charset_array[] = array(
-                'label' => $label,
-                'selected' => (strcasecmp($encoding, $charset) === 0),
-                'value' => $encoding
-            );
-        }
-        $t->set('charset_array', $charset_array);
-    }
     if ($t->get('set_priority')) {
         $t->set('priority_label', Horde::label('priority', _("_Priority")));
         $t->set('priority_tabindex', ++$tabindex);
index 3f8035a..31bae84 100644 (file)
@@ -308,7 +308,6 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
      *
      * @return mixed  An array with the following keys:
      * <pre>
-     * charset - (string) The preferred sending charset.
      * header - (array) A list of headers to add to the outgoing message.
      * identity - (integer) The identity used to create the message.
      * mode - (string) 'html' or 'text'.
@@ -447,8 +446,9 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         $this->_metadata['draft_uid_resume'] = $indices;
         $this->changed = 'changed';
 
+        $this->charset = $charset;
+
         return array(
-            'charset' => $charset,
             'header' => $header,
             'identity' => $identity_id,
             'mode' => $mode,
@@ -1307,7 +1307,6 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
      * @return array  An array with the following keys:
      * <pre>
      * 'body'     - The text of the body part
-     * 'charset'  - The guessed charset to use for the reply
      * 'format'   - The format of the body message
      * 'headers'  - The headers of the message to use for the reply
      * 'identity' - The identity to use for the reply based on the original
@@ -1485,11 +1484,18 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             $this->changed = 'changed';
         }
 
+        $ret = $this->replyMessageText($contents);
+        if ($ret['charset'] != $this->charset) {
+            $this->charset = $ret['charset'];
+            $this->changed = 'changed';
+        }
+        unset($ret['charset']);
+
         return array_merge(array(
             'headers' => $header,
             'identity' => $match_identity,
             'type' => $reply_type
-        ), $this->replyMessageText($contents));
+        ), $ret);
     }
 
     /**
@@ -1589,7 +1595,6 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
      * @return array  An array with the following keys:
      * <pre>
      * 'body'     - The text of the body part
-     * 'charset'  - The guessed charset to use for the reply
      * 'format'   - The format of the body message
      * 'headers'  - The headers of the message to use for the reply
      * 'identity' - The identity to use for the reply based on the original
@@ -1643,16 +1648,16 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             in_array($type, array('forward_attach', 'forward_both'))) {
             try {
                 $this->attachImapMessage(new IMP_Indices($contents));
-            } catch (IMP_Exception $e) {
-            }
+            } catch (IMP_Exception $e) {}
         }
 
         if (in_array($type, array('forward_body', 'forward_both'))) {
             $ret = $this->forwardMessageText($contents);
+            $this->charset = $ret['charset'];
+            unset($ret['charset']);
         } else {
             $ret = array(
                 'body' => '',
-                'charset' => '',
                 'format' => $GLOBALS['prefs']->getValue('compose_html') ? 'html' : 'text'
             );
         }
index 8d1af2b..861149f 100644 (file)
   </td>
  </tr>
 
-<if:unlocked_charset>
- <tr>
-  <td class="light rightAlign">
-   <strong><tag:charset_label /></strong>
-  </td>
-  <td class="item">
-   <select id="charset" name="charset" tabindex="<tag:charset_tabindex />">
-<loop:charset_array>
-    <option value="<tag:charset_array.value />" <if:charset_array.selected>selected="selected" </if:charset_array.selected>><tag:charset_array.label /></option>
-</loop:charset_array>
-   </select>
-  </td>
- </tr>
-</if:unlocked_charset>
-
 <if:set_priority>
  <tr>
   <td class="light rightAlign">