Verified Commit 6bccac69 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(cyrus) Move cyrus autocreate folders option to cyrus service

issue #6042
parent b040756b
......@@ -38,9 +38,11 @@ class serviceCyrus extends simpleMailMethodService
*/
static function getAttributesInfo (): array
{
global $config;
return [
'cyrus' => [
'name' => _('Cyrus settings'),
'name' => _('Connection'),
'attrs' => [
new CompositeAttribute(
_('Connect URL for Cyrus server'),
......@@ -78,15 +80,10 @@ class serviceCyrus extends simpleMailMethodService
_('Password'), _('Admin user password'),
'fdCyrusPassword', TRUE
),
new BooleanAttribute(
_('Use UNIX style'), _('Determines if "foo/bar" or "foo.bar" should be used as namespaces in IMAP'),
'fdCyrusUseSlashes', FALSE,
($config->get_cfg_value('CyrusUseSlashes') === 'TRUE')
),
]
],
'sieve' => [
'name' => _('Sieve settings'),
'name' => _('Sieve'),
'attrs' => [
new CompositeAttribute(
_('Sieve connect URL for Cyrus server'),
......@@ -110,8 +107,25 @@ class serviceCyrus extends simpleMailMethodService
'/^{(.*):(\\d+)\\/([^\\/]+)}$/',
'{%s:%d/%s}'
)
]
]
],
],
'settings' => [
'name' => _('Settings'),
'attrs' => [
new BooleanAttribute(
_('Use UNIX style'), _('Determines if "foo/bar" or "foo.bar" should be used as namespaces in IMAP'),
'fdCyrusUseSlashes', FALSE,
($config->get_cfg_value('CyrusUseSlashes') === 'TRUE')
),
new SetAttribute(
new StringAttribute(
_('Autocreate folders'), _('List of personal IMAP folders that should be created along initial account creation.'),
'fdCyrusAutocreateFolders', FALSE
),
$config->get_cfg_value('CyrusAutocreateFolders', [])
),
],
],
];
}
}
......@@ -39,4 +39,4 @@ attributetype ( 1.3.6.1.4.1.38414.14.1.6 NAME 'fdCyrusAcl'
objectclass (1.3.6.1.4.1.38414.14.2.1 NAME 'fdCyrusServer' SUP top AUXILIARY
DESC 'FusionDirectory - Cyrus server description'
MUST ( cn $ fdCyrusConnect $ fdCyrusAdmin $ fdCyrusPassword )
MAY ( fdCyrusUseSlashes $ fdCyrusSieveServer ))
MAY ( fdCyrusUseSlashes $ fdCyrusAutocreateFolders $ fdCyrusSieveServer ))
......@@ -259,19 +259,16 @@ class mailMethodCyrus extends mailMethod
$list = imap_listmailbox($this->imap_handle, $cfg['connect'], $this->account_id);
if ($list === FALSE) {
@DEBUG(DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, $this->account_id,
"<b>IMAP: Add account</b> on server :".$this->parent->gosaMailServer);
if (!imap_createmailbox($this->imap_handle, $cfg["connect"].$this->account_id)) {
'IMAP: Add account on server '.$this->parent->gosaMailServer);
if (!imap_createmailbox($this->imap_handle, $cfg['connect'].$this->account_id)) {
$this->error = imap_last_error();
return FALSE;
}
/* Autocreate configured default folders */
$folders = $config->get_cfg_value('cyrusAutocreateFolders', NULL);
if ($folders !== NULL) {
// Walk thru list of specified folders
foreach ($folders as $folder) {
@DEBUG(DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, '<b>'.$this->account_id.'</b>',
'<b>IMAP: Add/Update account folder '.$folder.'</b> on server :'.$this->parent->gosaMailServer);
foreach ($cfg['autocreate'] as $folder) {
@DEBUG(DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, $folder,
'IMAP: Add account folder on server '.$this->parent->gosaMailServer);
if (!imap_createmailbox($this->imap_handle, $cfg['connect'].$this->create_folder_id($folder))) {
$this->error = imap_last_error();
return FALSE;
......@@ -279,7 +276,6 @@ class mailMethodCyrus extends mailMethod
}
}
}
}
return TRUE;
}
......@@ -627,7 +623,10 @@ class mailMethodCyrus extends mailMethod
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search('(objectClass=fdCyrusServer)',
['cn','fdCyrusConnect','fdCyrusAdmin','fdCyrusPassword','fdCyrusSieveServer','fdCyrusUseSlashes']);
[
'cn','fdCyrusConnect','fdCyrusAdmin','fdCyrusPassword',
'fdCyrusSieveServer','fdCyrusUseSlashes','fdCyrusAutocreateFolders'
]);
while ($attrs = $ldap->fetch()) {
sscanf($attrs['fdCyrusSieveServer'][0], '{%[^{}:]:%d/%[^{}]}', $sieve_server, $sieve_port, $sieve_option);
......@@ -637,6 +636,7 @@ class mailMethodCyrus extends mailMethod
'admin' => $attrs['fdCyrusAdmin'][0],
'password' => $attrs['fdCyrusPassword'][0],
'useSlashes' => ($attrs['fdCyrusUseSlashes'][0] ?? 'FALSE'),
'autocreate' => ($attrs['fdCyrusAutocreateFolders'] ?? []),
'sieve_server' => $sieve_server,
'sieve_option' => $sieve_option,
'sieve_port' => $sieve_port
......
......@@ -60,13 +60,6 @@ class mailPluginConfig extends simplePlugin
_('Determines if the mailbox should be removed from your IMAP server after the account is deleted in LDAP.'),
'fdCyrusDeleteMailbox'
),
new SetAttribute(
new StringAttribute(
_('Cyrus autocreate folders'),
_('List of personal IMAP folders that should be created along initial account creation.'),
'fdCyrusAutocreateFolders'
)
),
new IntAttribute(
_('IMAP timeout'),
_('Sets the connection timeout for imap actions.'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment