Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use global config as default subject value. #36

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

$config = array();

/*
** Plugin will try to guess when a custom e-mail address should be used when
** composing an e-mail if this option is set to "true". If you have too many
** false positives or don't want to use it, set it to false. You can also
** fine-tune this behavior by changing value of the "custom_from_header_rules"
** option.
*/
//$config['custom_from_compose_auto'] = true;

/*
** List of allowed matching rules by header type. This define how addresses
** from various e-mail headers can be used to guess custom address (only if
** option 'custom_from_compose_auto' is enabled).
** Format is 'header1=rule1;header2=rule2;...' where headerX is any e-mail
** header (you can use custom headers here) and ruleX a list of letters, each
** one identifying a matching rule you want to enable. Available rules are:
**
** - e (exact): an address found in headers can be used if it exactly matches
** one of your identities
** - d (domain): an address found in headers can be used if its domain matches
** one of your identities
** - o (other): any address found in header can be used
**
** By default only exact and domain matching rules are enabled on most headers
** known to contain e-mail addresses, except for the "X-Original-To" header
** where all rules are enabled.
*/
//$config['custom_from_header_rules'] = 'X-Original-To=de;To=de;Cc=de;Cci=de;From=de';
14 changes: 13 additions & 1 deletion custom_from.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,24 @@ public function preferences_list($params)

$rcmail = rcmail::get_instance();

// Subject preference, using global configuration as fallback value
$rule = isset($this->rules['to']) ? $this->rules['to'] : '';

if (strpos($rule, 'o') !== false)
$compose_subject_value_default = 'always';
else if (strpos($rule, 'd') !== false)
$compose_subject_value_default = 'domain';
else if (strpos($rule, 'e') !== false)
$compose_subject_value_default = 'exact';
else
$compose_subject_value_default = 'never';

$compose_subject = new html_select(array('id' => self::PREFERENCE_COMPOSE_SUBJECT, 'name' => self::PREFERENCE_COMPOSE_SUBJECT));
$compose_subject->add(self::get_text($rcmail, 'preference_compose_subject_never'), 'never');
$compose_subject->add(self::get_text($rcmail, 'preference_compose_subject_exact'), 'exact');
$compose_subject->add(self::get_text($rcmail, 'preference_compose_subject_domain'), 'domain');
$compose_subject->add(self::get_text($rcmail, 'preference_compose_subject_always'), 'always');
$compose_subject_value = self::get_preference($rcmail, self::PREFERENCE_COMPOSE_SUBJECT, 'never');
$compose_subject_value = self::get_preference($rcmail, self::PREFERENCE_COMPOSE_SUBJECT, $compose_subject_value_default);

$params['blocks'] = array(
'compose' => array(
Expand Down