From 6a6aaa7b6a70930f3c22097eeb9b2f9aa6457fb9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 16 Aug 2014 10:26:02 +0000 Subject: [PATCH] * EMailAdmin/Admin/Cyrus: deleting of users did not delete mailbox on managed Cyrus server --- emailadmin/inc/class.emailadmin_hooks.inc.php | 12 ++++++++++++ emailadmin/inc/class.emailadmin_imap_cyrus.inc.php | 7 +++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/emailadmin/inc/class.emailadmin_hooks.inc.php b/emailadmin/inc/class.emailadmin_hooks.inc.php index 59a62292c0..8626445a7f 100644 --- a/emailadmin/inc/class.emailadmin_hooks.inc.php +++ b/emailadmin/inc/class.emailadmin_hooks.inc.php @@ -64,6 +64,8 @@ class emailadmin_hooks */ static function deleteaccount(array $data) { + self::run_plugin_hooks('deleteAccount', $data); + // as mail accounts contain credentials, we do NOT assign them to user users emailadmin_account::delete(0, $data['account_id']); } @@ -91,7 +93,17 @@ class emailadmin_hooks static function addaccount(array $data) { $method = $data['location'] == 'addaccount' ? 'addAccount' : 'updateAccount'; + self::run_plugin_hooks($method, $data); + } + /** + * Run hook on plugins of all mail-accounts of given account_id + * + * @param string $method plugin method to run + * @param array $data hook-data incl. value for key account_id + */ + protected static function run_plugin_hooks($method, array $data) + { foreach(emailadmin_account::search((int)$data['account_id'], 'params') as $params) { if (!emailadmin_account::is_multiple($params)) continue; // no need to waste time on personal accounts diff --git a/emailadmin/inc/class.emailadmin_imap_cyrus.inc.php b/emailadmin/inc/class.emailadmin_imap_cyrus.inc.php index f652b0abb8..e04dbd25d4 100644 --- a/emailadmin/inc/class.emailadmin_imap_cyrus.inc.php +++ b/emailadmin/inc/class.emailadmin_imap_cyrus.inc.php @@ -82,16 +82,15 @@ class emailadmin_imap_cyrus extends emailadmin_imap $this->adminConnection(); $mailboxName = $this->getUserMailboxString($username); - list($reference,$restriction) = explode($username,$mailboxName,2); try { - $mboxes = $this->getMailboxes($reference,$username.$restriction); + $mboxes = (array)$this->getMailboxes($mailboxName, 1); //error_log(__METHOD__."('$username') getMailboxes('$reference','$username$restriction') = ".array2string($mboxes)); - foreach($mboxes as $mbox) + foreach(array_keys($mboxes) as $mbox) { // give the admin account the rights to delete this mailbox - $this->setACL($mbox, $this->adminUsername, 'lrswipcda'); + $this->setACL($mbox, $this->acc_imap_admin_username, array('rights' => 'aeiklprstwx')); $this->deleteMailbox($mbox); } }