Move from IMP to Horde (Horde_Registry::getEmailCharset() requires it).
IMP now correctly honors sending_charset if locked.
*/
public function getEmailCharset()
{
- $charset = $GLOBALS['prefs']->getValue('sending_charset');
- if (!empty($charset)) {
+ if ($charset = $GLOBALS['prefs']->getValue('sending_charset')) {
return $charset;
}
'label' => _("Locale and Time"),
'desc' => _("Set your preferred language, timezone and date preferences."),
'members' => array(
- 'language', 'timezone', 'twentyFour', 'date_format',
+ 'language', 'sending_charset', 'timezone', 'twentyFour', 'date_format',
'date_format_mini', 'time_format', 'first_week_day'
)
);
'desc' => _("Select your preferred language:")
);
+// Select widget for email charsets
+$_prefs['sending_charset'] = array(
+ 'value' => '',
+ 'advanced' => true,
+ 'type' => 'enum',
+ 'enum' => array_merge(
+ array('' => _("Default")),
+ $GLOBALS['registry']->nlsconfig['encodings']
+ ),
+ 'desc' => _("Default charset for sending e-mail messages:")
+);
+
// user time zone
// Timezone list is dynamically built when prefs screen is displayed
$_prefs['timezone'] = array(
'value' => 'a:0:{}'
);
+
+
// *** Remote Servers Preferences ***
$prefGroups['remote'] = array(
'desc' => _("Alternate IMSP Password")
);
+
+
// *** SyncML Preferences ***
$prefGroups['syncml'] = array(
'column' => _("Other Information"),
'type' => 'special'
);
+
+
// *** Internal Preferences ***
// last time login tasks were run.
*/
public function prefsInit($ui)
{
- global $conf;
+ global $conf, $injector, $prefs, $registry;
switch ($ui->group) {
+ case 'language':
+ if (!$prefs->isLocked('sending_charset')) {
+ asort($registry->nlsconfig['encodings']);
+ }
+ break;
+
case 'remote':
Horde::addScriptFile('rpcprefs.js', 'horde');
$ui->nobuttons = true;
/* Hide appropriate prefGroups. */
try {
- $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->hasCapability('update');
+ $injector->getInstance('Horde_Core_Factory_Auth')->create()->hasCapability('update');
} catch (Horde_Exception $e) {
$ui->suppressGroups[] = 'forgotpass';
}
);
try {
- if ($imp_compose->buildAndSendMessage($message, $header, $registry->getEmailCharset(), $options)) {
+ if ($imp_compose->buildAndSendMessage($message, $header, $options)) {
$imp_compose->destroy('send');
$notification->push(_("Message sent successfully."), 'horde.success');
$imp_ui = new IMP_Ui_Compose();
$stationery = $injector->getInstance('IMP_Compose_Stationery');
-/* Set the default charset & encoding.
- * $charset - charset to use when sending messages
- * $encoding - best guessed charset offered to the user as the default value
- * in the charset dropdown list. */
+/* Set charset defaults. */
$charset = $prefs->isLocked('sending_charset')
- ? $registry->getEmailCharset()
+ ? $prefs->getValue('sending_charset')
: $vars->charset;
-$encoding = empty($charset)
- ? $registry->getEmailCharset()
- : $charset;
/* Is this a popup window? */
$isPopup = ($prefs->getValue('compose_popup') || $vars->popup);
}
$title .= ' ' . $header['subject'];
- $encoding = empty($charset) ? $reply_msg['encoding'] : $charset;
+ $charset = $reply_msg['encoding'];
break;
case 'forward_attach':
$format = $fwd_msg['format'];
$rtemode = ($rtemode || (!is_null($rtemode) && ($format == 'html')));
$title = $header['title'];
- $encoding = empty($charset) ? $fwd_msg['encoding'] : $charset;
+ $charset = $fwd_msg['encoding'];
break;
case 'redirect_compose':
}
$options = array(
+ 'charset' => $charset,
'encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $vars->encrypt_options,
'html' => $rtemode,
'identity' => $identity,
);
try {
- $sent = $imp_compose->buildAndSendMessage($message, $header, $charset, $options);
+ $sent = $imp_compose->buildAndSendMessage($message, $header, $options);
$imp_compose->destroy('send');
} catch (IMP_Compose_Exception $e) {
$get_sig = false;
$t->set('charset_tabindex', ++$tabindex);
$charset_array = array();
asort($registry->nlsconfig['encodings']);
- foreach ($registry->nlsconfig['encodings'] as $charset => $label) {
- $charset_array[] = array('value' => $charset, 'selected' => (strtolower($charset) == strtolower($encoding)), 'label' => $label);
+ foreach (array_merge(array('' => _("Default")), $registry->nlsconfig['encodings']) as $encoding => $label) {
+ $charset_array[] = array(
+ 'label' => $label,
+ 'selected' => (strcasecmp($encoding, $charset) === 0),
+ 'value' => $encoding
+ );
}
$t->set('charset_array', $charset_array);
}
'mailto_handler', 'compose_cc', 'compose_bcc', 'compose_spellcheck',
'compose_confirm', 'set_priority', 'compose_popup', 'compose_html',
'compose_html_font_family', 'compose_html_font_size', 'mail_domain',
- 'compose_cursor', 'sending_charset', 'encryptselect',
- 'save_attachments', 'disposition_request_read'
+ 'compose_cursor', 'encryptselect', 'save_attachments',
+ 'disposition_request_read'
)
);
'desc' => _("Where should the cursor be located in the compose text area by default?")
);
-// Select widget for the possible charsets
-$_prefs['sending_charset'] = array(
- 'value' => '',
- 'advanced' => true,
- 'type' => 'enum',
- 'enum' => array_merge(array('' => _("Default")), $GLOBALS['registry']->nlsconfig['encodings']),
- 'desc' => _("Your default charset for sending messages:")
-);
-
// Select widget for the 'default_encrypt' preference
$_prefs['encryptselect'] = array(
'type' => 'special'
Preferences
-----------
-The 'time_format' preference has been moved to Horde.
+The 'sending_charset' and 'time_format' preferences have been moved to Horde.
The following preferences are no longer used and may be safely removed from
your ``config/prefs.php`` file and your preferences backend::
);
try {
- // TODO: Use 'sending_charset'
- $sent = $imp_compose->buildAndSendMessage($this->_vars->message, $headers, $GLOBALS['registry']->getEmailCharset(), $options);
+ $sent = $imp_compose->buildAndSendMessage($this->_vars->message, $headers, $options);
} catch (IMP_Compose_Exception $e) {
$result->success = 0;
$session)
{
/* Set up the base message now. */
- $mime = $this->_createMimeMessage(array(null), $message, $charset, array('html' => $html, 'nofinal' => true, 'noattach' => !$session));
+ $mime = $this->_createMimeMessage(array(null), $message, array(
+ 'charset' => $charset,
+ 'html' => $html,
+ 'noattach' => !$session,
+ 'nofinal' => true
+ ));
$base = $mime['msg'];
$base->isBasePart(true);
*
* @param string $body The message body.
* @param array $header List of message headers.
- * @param string $charset The sending charset.
* @param array $opts An array of options w/the following keys:
* <pre>
+ * charset - (string) The charset to use for sending the message.
+ * DEFAULT: Horde default email charset.
* encrypt - (integer) A flag whether to encrypt or sign the message.
* One of IMP::PGP_ENCRYPT, IMP::PGP_SIGNENC,
* IMP::SMIME_ENCRYPT, or IMP::SMIME_SIGNENC.
* @throws IMP_Compose_Exception
* @throws IMP_Exception
*/
- public function buildAndSendMessage($body, $header, $charset,
- array $opts = array())
+ public function buildAndSendMessage($body, $header, array $opts = array())
{
global $conf, $notification, $prefs, $registry;
* are storing an encrypted message locally. */
$send_msgs = array();
$msg_options = array(
+ 'charset' => empty($opts['charset']) ? null : $opts['charset'],
'encrypt' => $encrypt,
'html' => !empty($opts['html'])
);
if ($prefs->getValue('use_smime') &&
in_array($encrypt, array(IMP::SMIME_ENCRYPT, IMP::SMIME_SIGNENC))) {
foreach ($recip['list'] as $val) {
- $send_msgs[] = $this->_createMimeMessage(array($val), $body, $charset, $msg_options);
+ $send_msgs[] = $this->_createMimeMessage(array($val), $body, $msg_options);
}
/* Must target the encryption for the sender before saving message
* in sent-mail. */
- $save_msg = $this->_createMimeMessage(array($header['from']), $body, $charset, $msg_options);
+ $save_msg = $this->_createMimeMessage(array($header['from']), $body, $msg_options);
} else {
/* Can send in clear-text all at once, or PGP can encrypt
* multiple addresses in the same message. */
$msg_options['from'] = $barefrom;
- $send_msgs[] = $save_msg = $this->_createMimeMessage($recip['list'], $body, $charset, $msg_options);
+ $send_msgs[] = $save_msg = $this->_createMimeMessage($recip['list'], $body, $msg_options);
}
/* Initalize a header object for the outgoing message. */
*
* @param array $to The recipient list.
* @param string $body Message body.
- * @param string $charset The charset of the message body.
* @param array $options Additional options:
* <pre>
+ * 'charset' - (string) The charset of the message body.
+ * DEFAULT: Horde default email charset.
* 'encrypt' - (integer) The encryption flag.
* 'from' - (string) The outgoing from address - only needed for multiple
* PGP encryption.
* @throws Horde_Exception
* @throws IMP_Compose_Exception
*/
- protected function _createMimeMessage($to, $body, $charset,
- $options = array())
+ protected function _createMimeMessage($to, $body, array $options = array())
{
+ $charset = empty($opts['charset'])
+ ? $GLOBALS['registry']->getEmailCharset()
+ : $opts['charset'];
+
$body = Horde_String::convertCharset($body, 'UTF-8', $charset);
if (!empty($options['html'])) {
$ui->suppress[] = 'compose_html_font_family';
$ui->suppress[] = 'compose_html_font_size';
}
-
- /* Sort encodings. */
- if (!$prefs->isLocked('sending_charset')) {
- asort($registry->nlsconfig['encodings']);
- }
break;
case 'delmove':