From 4dbb0df8faeb37b3bbd33fa1c4047c7cb99c2098 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Tue, 7 Sep 2004 07:05:22 +0000 Subject: [PATCH] suppress the errormessage --- emailadmin/inc/class.cyrusimap.inc.php | 166 +++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 emailadmin/inc/class.cyrusimap.inc.php diff --git a/emailadmin/inc/class.cyrusimap.inc.php b/emailadmin/inc/class.cyrusimap.inc.php new file mode 100644 index 0000000000..fea68bea7d --- /dev/null +++ b/emailadmin/inc/class.cyrusimap.inc.php @@ -0,0 +1,166 @@ +profileData); + $imapAdminUsername = $this->profileData['imapAdminUsername']; + $imapAdminPW = $this->profileData['imapAdminPW']; + + $folderNames = array( + "user.$username", + "user.$username.Trash", + "user.$username.Sent" + ); + + // create the mailbox + if($mbox = @imap_open ($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) + { + // create the users folders + foreach($folderNames as $mailBoxName) + { + if(imap_createmailbox($mbox,imap_utf7_encode("{".$this->profileData['imapServer']."}$mailBoxName"))) + { + if(!imap_setacl($mbox, $mailBoxName, $username, "lrswipcd")) + { + # log error message + } + } + } + imap_close($mbox); + } + else + { + _debug_array(imap_errors()); + return false; + } + + // subscribe to the folders + if($mbox = @imap_open($this->getMailboxString(), $username, $userPassword)) + { + imap_subscribe($mbox,$this->getMailboxString('INBOX')); + imap_subscribe($mbox,$this->getMailboxString('INBOX.Sent')); + imap_subscribe($mbox,$this->getMailboxString('INBOX.Trash')); + imap_close($mbox); + } + else + { + # log error message + } + } + + function deleteAccount($_hookValues) + { + $username = $_hookValues['account_lid']; + + $imapAdminUsername = $this->profileData['imapAdminUsername']; + $imapAdminPW = $this->profileData['imapAdminPW']; + + if($mbox = @imap_open($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) + { + $mailBoxName = "user.$username"; + // give the admin account the rights to delete this mailbox + if(imap_setacl($mbox, $mailBoxName, $imapAdminUsername, "lrswipcda")) + { + if(imap_deletemailbox($mbox, + imap_utf7_encode("{".$this->profileData['imapServer']."}$mailBoxName"))) + { + return true; + } + else + { + // not able to delete mailbox + return false; + } + } + else + { + // not able to set acl + return false; + } + } + else + { + // imap open failed + return false; + } + } + + function updateAccount($_hookValues) + { + #_debug_array($_hookValues); + $username = $_hookValues['account_lid']; + if(isset($_hookValues['new_passwd'])) + $userPassword = $_hookValues['new_passwd']; + + #_debug_array($this->profileData); + $imapAdminUsername = $this->profileData['imapAdminUsername']; + $imapAdminPW = $this->profileData['imapAdminPW']; + + $folderNames = array( + "user.$username", + "user.$username.Trash", + "user.$username.Sent" + ); + + // create the mailbox + if($mbox = @imap_open ($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) + { + // create the users folders + foreach($folderNames as $mailBoxName) + { + if(imap_createmailbox($mbox,imap_utf7_encode("{".$this->profileData['imapServer']."}$mailBoxName"))) + { + if(!imap_setacl($mbox, $mailBoxName, $username, "lrswipcd")) + { + # log error message + } + } + } + imap_close($mbox); + } + else + { + return false; + } + + // we can only subscribe to the folders, if we have the users password + if(isset($_hookValues['new_passwd'])) + { + if($mbox = @imap_open($this->getMailboxString(), $username, $userPassword)) + { + imap_subscribe($mbox,$this->getMailboxString('INBOX')); + imap_subscribe($mbox,$this->getMailboxString('INBOX.Sent')); + imap_subscribe($mbox,$this->getMailboxString('INBOX.Trash')); + imap_close($mbox); + } + else + { + # log error message + } + } + } + } +?>