コード例 #1
0
ファイル: Sql.php プロジェクト: 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']));
 }