From 89d7876bea9efd5369744a1ea70067e974499e6f Mon Sep 17 00:00:00 2001 From: ralf Date: Mon, 25 Jul 2022 11:06:40 +0200 Subject: [PATCH] * 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 --- mail/inc/class.mail_acl.inc.php | 37 ++++++++++++++++++++++++--------- mail/lang/egw_de.lang | 1 + mail/lang/egw_en.lang | 1 + 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/mail/inc/class.mail_acl.inc.php b/mail/inc/class.mail_acl.inc.php index 2e58aa2f5d..6462fecae7 100644 --- a/mail/inc/class.mail_acl.inc.php +++ b/mail/inc/class.mail_acl.inc.php @@ -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; } diff --git a/mail/lang/egw_de.lang b/mail/lang/egw_de.lang index a97a819a14..351b9426c5 100644 --- a/mail/lang/egw_de.lang +++ b/mail/lang/egw_de.lang @@ -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 diff --git a/mail/lang/egw_en.lang b/mail/lang/egw_en.lang index 8ae3953d82..c636fd1d15 100644 --- a/mail/lang/egw_en.lang +++ b/mail/lang/egw_en.lang @@ -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