/**
  * Add Account
  *
  * Add the AccountDBO to the database
  */
 function add_account()
 {
     // Extract AccountDBO from the session
     $account_dbo =& $this->session['new_account_dbo'];
     // Insert UserBO into database
     add_UserDBO($this->session['user_dbo']);
     // Insert AccountDBO into database
     $account_dbo->setUsername($this->session['user_dbo']->getUsername());
     try {
         add_AccountDBO($account_dbo);
     } catch (DBMySQLException $e) {
         // Unable to add product to database
         delete_UserDBO($this->session['user_dbo']);
         throw $e;
     }
     // Jump to View Account page
     $this->setMessage(array("type" => "[ACCOUNT_ADDED]"));
     $this->gotoPage("accounts_view_account", null, "account=" . $account_dbo->getID());
 }
 /**
  * Delete User
  *
  * Remove UserDBO from database
  */
 function delete_user()
 {
     // Remove DBO from the database
     delete_UserDBO($this->get['user']);
     // Jump to 'Users' page, pass confirmation message
     $this->setMessage(array("type" => "[USER_DELETED]"));
     $this->gotoPage('config_users');
 }
Example #3
0
/**
 * Delete AccountDBO from database
 *
 * @param AccountDBO &$dbo Account DBO to delete
 * @return boolean True on success
 */
function delete_AccountDBO(&$dbo)
{
    $DB = DBConnection::getDBConnection();
    $id = intval($dbo->getID());
    // Delete any HostingSericePurchases assigned to this account
    try {
        $hosting_array = load_array_HostingServicePurchaseDBO("accountid=" . $id);
        foreach ($hosting_array as $hosting_dbo) {
            delete_HostingServicePurchaseDBO($hosting_dbo);
        }
    } catch (DBNoRowsFoundException $e) {
    }
    // Delete any DomainSericePurchases assigned to this account
    try {
        $domain_array = load_array_DomainServicePurchaseDBO("accountid=" . $id);
        foreach ($domain_array as $domain_dbo) {
            delete_DomainServicePurchaseDBO($domain_dbo);
        }
    } catch (DBNoRowsFoundException $e) {
    }
    // Delete any ProductPurchases assigned to this account
    try {
        $product_array = load_array_ProductPurchaseDBO("accountid=" . $id);
        foreach ($product_array as $product_dbo) {
            delete_ProductPurchaseDBO($product_dbo);
        }
    } catch (DBNoRowsFoundException $e) {
    }
    // Delete any Invoices assigned to this account
    try {
        $invoice_array = load_array_InvoiceDBO("accountid=" . $id);
        foreach ($invoice_array as $invoice_dbo) {
            delete_InvoiceDBO($invoice_dbo);
        }
    } catch (DBNoRowsFoundException $e) {
    }
    // Delete any Orders assigned to this account
    try {
        $orders = load_array_OrderDBO("accountid=" . $id);
        foreach ($orders as $orderDBO) {
            delete_OrderDBO($orderDBO);
        }
    } catch (DBNoRowsFoundException $e) {
    }
    // Delete the account's user
    delete_UserDBO($dbo->getUserDBO());
    // Build SQL
    $sql = $DB->build_delete_sql("account", "id = " . $id);
    // Delete the AccountDBO
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
}