* Mail: do NOT fail setting ACL recursive on folders, if single folder fail (eg. wrongly in subscription file)

reporting number of succeeded folders and names of failed folders plus error
This commit is contained in:
ralf 2022-07-25 11:06:40 +02:00
parent 1058347c0a
commit 89d7876bea
3 changed files with 29 additions and 10 deletions

View File

@ -380,7 +380,7 @@ class mail_acl
}
else
{
$msg = lang('Error while setting ACL for folder %1!', $content['mailbox']).' '.$msg;
$msg = lang('Error while setting ACL for folder %1!', $content['mailbox'])."\n".$msg;
}
}
else
@ -442,7 +442,7 @@ class mail_acl
$identifier = $u;
}
//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive,$msg)))
{
unset($content['grid'][$row_num]);
unset($content['grid']['delete']);
@ -459,7 +459,7 @@ class mail_acl
}
else
{
$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier)."\n".$msg;
return false;
}
}
@ -471,10 +471,10 @@ class mail_acl
* @param String $identifier The identifier to delete.
* @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
* the mailbox including all its subfolders will be considered.
*
* @param String& $msg=null on return error-message
* @return Boolean FALSE in case of any exceptions and TRUE in case of success
*/
function deleteACL ($mailbox, $identifier, $recursive)
function deleteACL ($mailbox, $identifier, $recursive, &$msg=null)
{
if ($recursive)
{
@ -484,18 +484,27 @@ class mail_acl
{
$folders = (array)$mailbox;
}
$errors = [];
$success = 0;
foreach($folders as $sbFolders)
{
try
{
$this->imap->deleteACL($sbFolders, $identifier);
$success++;
}
catch (Exception $e)
{
error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ."." .$e->getMessage());
return false;
$errors[] = $sbFolders.': '.$e->getMessage();
error_log(__METHOD__. "Could not delete ACL rights of folder " . $sbFolders . " for account ". $identifier ."." .$e->getMessage());
}
}
if ($errors)
{
$msg = lang("Succeeded on %1 folders, failed on %2", $success, count($errors)).":\n- ".
implode("\n- ", $errors);
return false;
}
return true;
}
@ -545,19 +554,27 @@ class mail_acl
{
$folders = (array)$mailbox;
}
$errors = [];
$success = 0;
foreach($folders as $sbFolders)
{
try
{
$this->imap->setACL($sbFolders,$identifier,$options);
$success++;
}
catch (Exception $e)
{
$msg = $e->getMessage();
error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . "." .$e->getMessage());
return false;
$errors[] = $sbFolders.': '.$e->getMessage();
error_log(__METHOD__. "Could not set ACL rights on folder " . $sbFolders . " for account ". $identifier . "." .$e->getMessage());
}
}
if ($errors)
{
$msg = lang("Succeeded on %1 folders, failed on %2", $success, count($errors)).":\n- ".
implode("\n- ", $errors);
return false;
}
return true;
}

View File

@ -604,6 +604,7 @@ subscribe folder ... mail de Ordner abonnieren ...
subscribe to folder %1 mail de Ordner %1 abonieren
subscription folders mail de Ordner abonnieren
subscription successfully saved. mail de Das Abonnieren der Ordner wurde erfolgreich gespeichert.
succeeded on %1 folders, failed on %2 mail de Erfolgreich bei %1 Ordnern, fehlgeschlagen bei %2
successfully connected mail de erfolgreich verbunden
switch off encryption? mail de Verschlüsselung ausschalten?
template folder mail de Vorlagen Ordner

View File

@ -604,6 +604,7 @@ subscribe folder ... mail en Subscribe folder ...
subscribe to folder %1 mail en Subscribe to Folder %1
subscription folders mail en Subscription folders
subscription successfully saved. mail en Subscription successfully saved.
succeeded on %1 folders, failed on %2 mail en Succeeded on %1 folders, failed on %2
successfully connected mail en Successfully connected
switch off encryption? mail en Switch off encryption?
template folder mail en template folder