mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-09 14:38:27 +03:00
added new config options to overwrite the mail address
This commit is contained in:
parent
8b8b0fc7e4
commit
30e3a8cc0f
2 changed files with 68 additions and 23 deletions
|
|
@ -18,6 +18,10 @@ class LdapMailAccountsConfig
|
|||
public const CONFIG_FIELD_USERNAME = "field_username";
|
||||
public const CONFIG_SEARCH_STRING = "search_string";
|
||||
public const CONFIG_FIELD_MAIL_DOMAIN = "field_domain";
|
||||
public const CONFIG_FIELD_MAIL_ADDRESS_MAIN_ACCOUNT = "field_mail_address_main_account";
|
||||
public const CONFIG_FIELD_MAIL_ADDRESS_ADDITIONAL_ACCOUNT = "field_mail_address_additional_account";
|
||||
public const CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_MAIN_ACCOUNT = "bool_overwrite_mail_address_main_account";
|
||||
public const CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_ADDITIONAL_ACCOUNT = "bool_overwrite_mail_address_additional_account";
|
||||
|
||||
public $server;
|
||||
public $protocol;
|
||||
|
|
@ -30,6 +34,10 @@ class LdapMailAccountsConfig
|
|||
public $field_username;
|
||||
public $search_string;
|
||||
public $field_domain;
|
||||
public $field_mail_address_main_account;
|
||||
public $field_mail_address_additional_account;
|
||||
public $bool_overwrite_mail_address_main_account;
|
||||
public $bool_overwrite_mail_address_additional_account;
|
||||
|
||||
public static function MakeConfig(Plugin $config): LdapMailAccountsConfig
|
||||
{
|
||||
|
|
@ -45,6 +53,10 @@ class LdapMailAccountsConfig
|
|||
$ldap->field_username = trim($config->Get("plugin", self::CONFIG_FIELD_USERNAME));
|
||||
$ldap->search_string = trim($config->Get("plugin", self::CONFIG_SEARCH_STRING));
|
||||
$ldap->field_domain = trim($config->Get("plugin", self::CONFIG_FIELD_MAIL_DOMAIN));
|
||||
$ldap->bool_overwrite_mail_address_main_account = $config->Get("plugin", self::CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_MAIN_ACCOUNT);
|
||||
$ldap->field_mail_address_main_account = trim($config->Get("plugin", self::CONFIG_FIELD_MAIL_ADDRESS_MAIN_ACCOUNT));
|
||||
$ldap->bool_overwrite_mail_address_additional_account = $config->Get("plugin", self::CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_ADDITIONAL_ACCOUNT);
|
||||
$ldap->field_mail_address_additional_account = trim($config->Get("plugin", self::CONFIG_FIELD_MAIL_ADDRESS_ADDITIONAL_ACCOUNT));
|
||||
|
||||
return $ldap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,73 +55,106 @@ class LdapMailAccountsPlugin extends AbstractPlugin
|
|||
*/
|
||||
protected function configMapping(): array
|
||||
{
|
||||
$groupOverwriteMainAccount = new \RainLoop\Plugins\PropertyCollection('Overwrite mail address of main account');
|
||||
$groupOverwriteMainAccount->exchangeArray([
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_MAIN_ACCOUNT)->SetLabel('Enabled')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(false),
|
||||
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_MAIL_ADDRESS_MAIN_ACCOUNT)
|
||||
->SetLabel("Mail address field for main account")
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The ldap field containing the mail address to use on the SnappyMail main account.
|
||||
\nThe value found inside ldap will overwrite the mail address of the SnappyMail main account (the account the user logged in at SnappyMail)")
|
||||
->SetDefaultValue("mail"),
|
||||
]);
|
||||
|
||||
$groupOverwriteAdditionalAccount = new \RainLoop\Plugins\PropertyCollection('Overwrite mail address of additional account');
|
||||
$groupOverwriteAdditionalAccount->exchangeArray([
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_BOOL_OVERWRITE_MAIL_ADDRESS_ADDITIONAL_ACCOUNT)->SetLabel('Enabled')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(false),
|
||||
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_MAIL_ADDRESS_ADDITIONAL_ACCOUNT)
|
||||
->SetLabel("Mail address field for additional account")
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The ldap field containing the mail address to use on the found additional mail account.
|
||||
\nThe value found inside ldap will be used as mail address of the additional mail accounts created by this plugin.")
|
||||
->SetDefaultValue("mail"),
|
||||
]);
|
||||
|
||||
return [
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_SERVER)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_SERVER)
|
||||
->SetLabel("LDAP Server URL")
|
||||
->SetPlaceholder("ldap://server:port")
|
||||
->SetType(PluginPropertyType::STRING),
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_PROTOCOL_VERSION)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_PROTOCOL_VERSION)
|
||||
->SetLabel("LDAP Protocol Version")
|
||||
->SetType(PluginPropertyType::SELECTION)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::SELECTION)
|
||||
->SetDefaultValue([2, 3]),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_BIND_USER)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_BIND_USER)
|
||||
->SetLabel("LDAP Username")
|
||||
->SetDescription("The user to use for binding to the LDAP server. Should be a DN or RDN. Leave empty for anonymous bind.")
|
||||
->SetType(PluginPropertyType::STRING),
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_BIND_PASSWORD)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_BIND_PASSWORD)
|
||||
->SetLabel("LDAP Password")
|
||||
->SetDescription("Leave empty for anonymous bind.")
|
||||
->SetType(PluginPropertyType::PASSWORD),
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::PASSWORD),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_OBJECTCLASS)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_OBJECTCLASS)
|
||||
->SetLabel("Object class")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The object class to use when searching for additional mail accounts of the logged in SnappyMail user")
|
||||
->SetDefaultValue("user"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_BASE)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_BASE)
|
||||
->SetLabel("Base DN")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The base DN to search in for additional mail accounts of the logged in SnappyMail user"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_SEARCH)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_SEARCH)
|
||||
->SetLabel("Search field")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The name of the ldap attribute that has to contain the here defined 'LDAP search string'.")
|
||||
->SetDefaultValue("member"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_SEARCH_STRING)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_SEARCH_STRING)
|
||||
->SetLabel("LDAP search string")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The search string used to find ldap objects of mail accounts the user has access to.
|
||||
\nPossible placeholers:\n#USERNAME# - replaced with the username of the actual SnappyMail user
|
||||
\n#BASE_DN# - replaced with the value inside the field 'User base DN'.")
|
||||
->SetDefaultValue("uid=#USERNAME#"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_USERNAME)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_USERNAME)
|
||||
->SetLabel("Username field of additional account")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The field containing the username of the found additional mail account.
|
||||
\nThis username gets used by SnappyMail to login to the additional mail account.
|
||||
\nIf this field contains an email address, only the local-part before the @ is used.")
|
||||
->SetDefaultValue("uid"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_MAIL_DOMAIN)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_MAIL_DOMAIN)
|
||||
->SetLabel("Domain name field of additional account")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The field containing the domain name of the found additional mail account.
|
||||
\nThis domain gets looked up by SnappyMail to choose the right connection parameters at logging in to the additional mail account.
|
||||
\nIf this field contains an email address, only the domain-part after the @ is used.")
|
||||
->SetDefaultValue("mail"),
|
||||
|
||||
Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_NAME)
|
||||
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_FIELD_NAME)
|
||||
->SetLabel("Additional account name field")
|
||||
->SetType(PluginPropertyType::STRING)
|
||||
->SetType(RainLoop\Enumerations\PluginPropertyType::STRING)
|
||||
->SetDescription("The field containing the default sender name of the found additional mail account.")
|
||||
->SetDefaultValue("displayName")
|
||||
->SetDefaultValue("displayName"),
|
||||
|
||||
$groupOverwriteMainAccount,
|
||||
|
||||
$groupOverwriteAdditionalAccount,
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue