factory() public static method

Creates a new mailbox driver instance.
public static factory ( string $driver = null, array $params = null ) : Vilma_MailboxDriver
$driver string The name of the driver to create an instance of.
$params array Driver-specific parameters.
return Vilma_MailboxDriver The new driver instance.
Example #1
0
File: Sql.php Project: horde/horde
 /**
  * Deletes a user.
  *
  * @param integer $user_id  The id of the user to delete.
  *
  * @throws Vilma_Exception
  */
 public function deleteUser($user_id)
 {
     $user = $this->getUser($user_id);
     try {
         $this->_db->beginDbTransaction();
         /* Delete all virtual emails for this user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?';
         $values = array($user['user_name']);
         $this->_db->delete($sql, $values);
         /* Delete the actual user. */
         $sql = 'DELETE FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_id') . ' = ?';
         $values = array((int) $user_id);
         $this->_db->delete($sql, $values);
         $this->_db->commitDbTransaction();
     } catch (Horde_Db_Exception $e) {
         $this->_db->rollbackDbTransaction();
         throw new Vilma_Exception($e);
     }
     Vilma_MailboxDriver::factory()->deleteMailbox(Vilma::stripUser($user['user_name']), Vilma::stripDomain($user['user_name']));
 }
Example #2
0
 /**
  * @throws Vilma_Exception
  */
 public function saveUser($info)
 {
     $create = empty($info['user_id']);
     $info['user_id'] = $this->_saveUser($info);
     if ($create) {
         try {
             Vilma_MailboxDriver::factory()->createMailbox(Vilma::stripUser($info['user_name']), Vilma::stripDomain($info['user_name']));
         } catch (Exception $e) {
             $this->_deleteUser($info['user_id']);
             throw $e;
         }
     }
     if (isset($GLOBALS['conf']['mta']['auth_update_script']) && !empty($info['password'])) {
         $cmd = sprintf('%s set %s %s 2>&1', $GLOBALS['conf']['mta']['auth_update_script'], escapeshellarg($info['user_name']), escapeshellarg($info['password']));
         $msg = system($cmd, $ec);
         if ($msg === false) {
             throw new Vilma_Exception(_("Error running authentication update script."));
         }
         if ($ec != 0) {
             throw new Vilma_Exception(_("Unknown error running authentication update script."));
         }
     }
 }
Example #3
0
 /**
  * Deletes a user.
  *
  * @param integer $user_id  The id of the user to delete.
  *
  * @throws Vilma_Exception
  */
 public function deleteUser($user_id)
 {
     Horde_Exception_Pear::catchError($user = $this->getUser($user_id));
     /* Delete all virtual emails for this user. */
     $sql = 'DELETE FROM ' . $this->_params['tables']['virtuals'] . ' WHERE ' . $this->_getTableField('virtuals', 'virtual_destination') . ' = ?';
     $values = array($user['user_name']);
     Horde::log($sql, 'DEBUG');
     Horde_Exception_Pear::catchError($this->_db->query($sql, $values));
     /* Delete the actual user. */
     $sql = 'DELETE FROM ' . $this->_params['tables']['users'] . ' WHERE ' . $this->_getTableField('users', 'user_id') . ' = ?';
     $values = array((int) $user_id);
     Horde::log($sql, 'DEBUG');
     Horde_Exception_Pear::catchError($this->_db->query($sql, $values));
     Vilma_MailboxDriver::factory()->deleteMailbox(Vilma::stripUser($user['user_name']), Vilma::stripDomain($user['user_name']));
 }