/** * @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.")); } } }
/** * 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'])); }
/** * Constructor. * * @param array $params Any parameters needed for this driver. */ public function __construct(array $params = array()) { parent::__construct($params); $this->_imap = new Horde_Imap_Client_Socket(array('username' => $this->_params['admin_user'], 'password' => $this->_params['admin_password'], 'hostspec' => $this->_params['hostspec'], 'port' => $this->_params['port'])); }
/** * 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'])); }