createMailbox() public method

Create a mailbox.
public createMailbox ( mixed $mailbox, array $opts = [] )
$mailbox mixed The mailbox to create. Either a Horde_Imap_Client_Mailbox object or a string (UTF-8).
$opts array Additional options: - special_use: (array) An array of special-use flags to mark the mailbox with. The server MUST support RFC 6154.
示例#1
0
文件: Imap.php 项目: raz0rsdge/horde
 /**
  * Creates a new mailbox.
  *
  * @param string $user    The name of the mailbox to create.
  * @param string $domain  The name of the domain in which to create the
  *                        mailbox.
  *
  * @throws Vilma_Exception
  */
 public function createMailbox($user, $domain)
 {
     try {
         $this->_imap->createMailbox($this->_params['userhierarchy'] . $user . '@' . $domain);
     } catch (Exception $e) {
         throw new Vilma_Exception($e);
     }
 }
示例#2
0
 /**
  * Add a set of authentication credentials.
  *
  * @param string $userId       The userId to add.
  * @param array  $credentials  The credentials to add.
  *
  * @throw Horde_Auth_Exception
  */
 public function addUser($userId, $credentials)
 {
     if (!empty($this->_params['domain_field']) && $this->_params['domain_field'] != 'none') {
         list($name, $domain) = explode('@', $userId);
         $query = sprintf('INSERT INTO %s (%s, %s, %s) VALUES (?, ?, ?)', $this->_params['table'], $this->_params['username_field'], $this->_params['domain_field'], $this->_params['password_field']);
         $values = array($name, $domain, Horde_Auth::getCryptedPassword($credentials['password'], '', $this->_params['encryption'], $this->_params['show_encryption']));
         $query2 = 'INSERT INTO virtual (alias, dest, username, status) VALUES (?, ?, ?, 1)';
         $values2 = array($userId, $userId, $name);
         try {
             $this->_db->insert($query, $values);
             $this->_db->insert($query2, $values2);
         } catch (Horde_Db_Exception $e) {
             throw new Horde_Auth_Exception($e);
         }
     } else {
         parent::addUser($userId, $credentials);
     }
     $mailbox = $this->_params['userhierarchy'];
     try {
         $this->_imap->createMailbox($mailbox);
         $this->_imap->setACL($mailbox, $this->_params['cyradmin'], array('rights' => 'lrswipcda'));
         if (isset($this->_params['quota']) && $this->_params['quota'] >= 0) {
             $this->_imap->setQuota($mailbox, array('storage' => $this->_params['quota']));
         }
     } catch (Horde_Imap_Client_Exception $e) {
         throw new Horde_Auth_Exception($e);
     }
     foreach ($this->_params['folders'] as $val) {
         try {
             $this->_imap->createMailbox($val);
             $this->_imap->setACL($val, $this->_params['cyradmin'], array('rights' => 'lrswipcda'));
         } catch (Horde_Imap_Client_Exception $e) {
         }
     }
 }