コード例 #1
0
 function setacl($params)
 {
     $old_users = $this->getacl();
     $new_users = unserialize($params['acls']);
     $mbox_stream = $this->open_mbox();
     $serverString = "{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}";
     $mailboxes_list = imap_getmailboxes($mbox_stream, $serverString, "user" . $this->imap_delimiter . $this->username . "*");
     foreach ($new_users as $user => $value) {
         if (isset($old_users[$user]) && $value['acls'] == $old_users[$user]['acls']) {
             unset($old_users[$user]);
             unset($new_users[$user]);
         }
     }
     $aclLog = '';
     foreach ($new_users as $user => $value) {
         if (is_array($mailboxes_list)) {
             foreach ($mailboxes_list as $key => $val) {
                 $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
                 //$folder = str_replace("&-", "&", $folder);
                 $trashFolder = explode($this->imap_delimiter, $folder);
                 $acls = $trashFolder[count($trashFolder) - 1] == "Trash" ? $value['acls'] . "i" : $value['acls'];
                 $folder = imap_utf7_encode($folder);
                 imap_setacl($mbox_stream, $folder, "{$user}", $acls);
             }
         }
         $aclLog .= "({$user} -> [{$acls}])";
         if (isset($old_users[$user])) {
             unset($old_users[$user]);
         }
     }
     if ($aclLog != '') {
         Logger::info('expressomail', 'setacl', $this->username . " TO " . $aclLog);
     }
     foreach ($old_users as $user => $value) {
         if (is_array($mailboxes_list)) {
             foreach ($mailboxes_list as $key => $val) {
                 $folder = str_replace($serverString, "", imap_utf7_decode($val->name));
                 //$folder = str_replace("&-", "&", $folder);
                 $folder = imap_utf7_encode($folder);
                 imap_setacl($mbox_stream, $folder, "{$user}", "");
             }
         }
         Logger::info('expressomail', 'SETACL', $this->username . " TO " . $user . " ACL[]");
     }
     return true;
 }
コード例 #2
0
 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
         }
     }
 }
コード例 #3
0
ファイル: Cclient.php プロジェクト: jubinpatel/horde
 /**
  * Set the access rights for a folder.
  *
  * @param string $folder  The folder to act upon.
  * @param string $user    The user to set the ACL for.
  * @param string $acl     The ACL.
  *
  * @return NULL
  */
 public function setAcl($folder, $user, $acl)
 {
     $result = imap_setacl($this->getBackend(), $this->encodePath($folder), $user, $acl);
     if (!$result) {
         throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Failed setting ACL on folder %s for user %s to %s.") . ' ' . Horde_Kolab_Storage_Translation::t("Error: %s"), $folder, $user, $acl, imap_last_error()));
     }
     return $result;
 }