/**
  * Process New Account
  *
  * Prepare an AccountDBO, then prompt the client to confirm the new account
  */
 function process_new_account()
 {
     // Make sure the username is available
     try {
         load_UserDBO($this->post['username']);
         throw new SWUserException("[DB_USER_EXISTS]");
     } catch (DBNoRowsFoundException $e) {
     }
     // Prepare AccountDBO
     $account_dbo = new AccountDBO();
     $account_dbo->load($this->post);
     $user_dbo = new UserDBO();
     $user_dbo->setUsername($this->post['username']);
     $user_dbo->setPassword($this->post['password']);
     $user_dbo->setEmail($this->post['contactemail']);
     $user_dbo->setContactName($this->post['contactname']);
     $user_dbo->setType("Client");
     // Place DBO in the session for confirm page
     $this->session['new_account_dbo'] = $account_dbo;
     $this->session['user_dbo'] = $user_dbo;
     // Ask client to confirm
     $this->setTemplate("confirm");
 }
 /**
  * Execute Hosting Service Order
  *
  * Create a new Hosting Service Purchase for this order item
  *
  * @param AccountDBO $accountDBO Account object
  * @return boolean True for success
  */
 public function execute($accountDBO)
 {
     // Create a hosting service purchase record
     $purchaseDBO = new HostingServicePurchaseDBO();
     $purchaseDBO->setAccountID($accountDBO->getID());
     $purchaseDBO->setHostingServiceID($this->getServiceID());
     $purchaseDBO->setTerm($this->getTerm());
     $purchaseDBO->setDate(DBConnection::format_datetime(time()));
     $purchaseDBO->setDomainName($this->getDomainName());
     $purchaseDBO->setPrevInvoiceID(-1);
     $purchaseDBO->incrementNextBillingDate();
     add_HostingServicePurchaseDBO($purchaseDBO);
     // Fulfill the order and return
     $this->setStatus("Fulfilled");
     update_OrderHostingDBO($this);
     // Success
     return true;
 }
 /**
  * Check Out
  */
 function checkout()
 {
     // The module must have been picked if this is not an existing customer
     if ($this->session['order']->getAccountType() == "New Account" && !isset($this->post['module'])) {
         throw new SWUserException("[YOU_MUST_SELECT_PAYMENT]");
     }
     // If required, make sure that the TOS box was checked
     if ($this->conf['order']['tos_required'] && !isset($this->post['accept_tos'])) {
         throw new SWUserException("[YOU_MUST_ACCEPT_THE_TERMS_OF_SERVICE]");
     }
     $this->session['order']->setRemoteIP(ip2long($_SERVER['REMOTE_ADDR']));
     $this->session['order']->setDateCreated(DBConnection::format_datetime(time()));
     $this->session['order']->setAcceptedTOS($this->post['accept_tos'] == "true" ? "Yes" : "No");
     /*
     if ( $this->session['order']->getAccountType() == "Existing Account" ) {
     	// Send existing accounts off to the receipt page
     	$this->session['order']->complete();
     	$this->gotoPage( "receipt" );
     }
     */
     // Register the new user
     if ($this->session['order']->getAccountType() == "New Account") {
         $order = $this->session['order'];
         $user_dbo = new UserDBO();
         // User-defined data
         $user_dbo->setUsername($order->getUsername());
         $user_dbo->setPassword($order->getPassword());
         $user_dbo->setContactName($order->getContactName());
         $user_dbo->setEmail($order->getContactEmail());
         // Admin-defined data
         $user_dbo->setType("Client");
         $user_dbo->setLanguage("english");
         // could change to user-defined
         $user_dbo->setTheme("default");
         add_UserDBO($user_dbo);
         // Add account info to accountDBO
         $account_dbo = new AccountDBO();
         $account_dbo->setStatus("Active");
         $account_dbo->setType("Individual Account");
         $account_dbo->setBillingStatus("Bill");
         $account_dbo->setBillingDay(1);
         $account_dbo->setBusinessName($order->getBusinessName());
         $account_dbo->setContactName($order->getContactName());
         $account_dbo->setContactEmail($order->getContactEmail());
         $account_dbo->setAddress1($order->getAddress1());
         $account_dbo->setAddress2($order->getAddress2());
         $account_dbo->setCity($order->getCity());
         $account_dbo->setState($order->getState());
         $account_dbo->setCountry($order->getCountry());
         $account_dbo->setPostalCode($order->getPostalCode());
         $account_dbo->setPhone($order->getPhone());
         $account_dbo->setMobilePhone($order->getMobilePhone());
         $account_dbo->setFax($order->getFax());
         $account_dbo->setUsername($order->getUsername());
         add_AccountDBO($account_dbo);
         $this->session['order']->setAccountID($account_dbo->getID());
     }
     // If the order does not have an ID already, save it to the database
     if ($this->session['order']->getID() == null) {
         add_OrderDBO($this->session['order']);
     }
     if ($this->session['review']['module'] == "Check") {
         // Record the promise to pay by check
         $checkPayment = new PaymentDBO();
         $checkPayment->setOrderID($this->session['order']->getID());
         $checkPayment->setAmount($this->session['order']->getTotal());
         $checkPayment->setStatus("Pending");
         $checkPayment->setDate(DBConnection::format_datetime(time()));
         $checkPayment->setType("Check");
         add_PaymentDBO($checkPayment);
         // Goto the receipt page
         $this->session['order']->complete();
         $this->gotoPage("receipt", null, "payByCheck=1");
     }
     // Collect Payment
     $registry = ModuleRegistry::getModuleRegistry();
     $paymentModule = $registry->getModule($this->post['module']);
     $checkoutPage = $paymentModule->getType() == "payment_processor" ? $paymentModule->getOrderCheckoutPage() : "ccpayment";
     // Redirect to the module's checkout page
     $_SESSION['module'] = $paymentModule;
     $this->gotoPage($checkoutPage);
 }
Beispiel #4
0
 public function testGetUsername()
 {
     $this->assertNull($this->object->getUsername());
     $this->object->setUsername('radboy');
     $this->assertEquals($this->object->getUsername(), 'radboy');
 }
 /**
  * Prepare Customer and Contacts
  *
  * Queries the customer ID, or creates a new customer if necessary.  Then adds
  * or edits the contacts as necessary.
  *
  * @param array $contacts An array of ContactDBO's
  * @param AccountDBO $accountDBO The account DBO
  * @return array ID's in an associative array with keys: customerid, adminid, techid, billingid
  */
 function prepareCustomerContacts($contacts, $accountDBO)
 {
     // Reseller Club uses e-mail addresses as customer usernames
     $customer = $accountDBO->getContactEmail();
     // Query the customer's ID
     if (!($customerID = $this->queryCustomerID($customer))) {
         // Add a new customer
         if (!($customerID = $this->addCustomer($accountDBO->getContactEmail(), $this->getDefaultCustomerPassword(), $accountDBO->getContactName(), $accountDBO->getBusinessName(), $accountDBO->getAddress1(), $accountDBO->getAddress2(), null, $accountDBO->getCity(), $accountDBO->getState(), $accountDBO->getCountry(), $accountDBO->getPostalCode(), $accountDBO->getPhone(), $accountDBO->getMobilePhone(), $accountDBO->getFax()))) {
             fatal_error("ResellerClub::registerNewDomain()", "There was an error when trying to add a new Reseller Club customer");
         }
     }
     // Enter Admin contact
     $adminID = $this->addOrEditContact($customerID, $contacts['admin']);
     if (!is_numeric($adminID) || $adminID < 0) {
         fatal_error("ResellerClub::registerDomain", "could not add Admin contact for domain registration at Reseller Club!");
     }
     // Enter Technical contact
     $techID = $this->addOrEditContact($customerID, $contacts['tech']);
     if (!is_numeric($techID) || $techID < 0) {
         fatal_error("ResellerClub::registerDomain", "could not add Tech contact for domain registration at Reseller Club!");
     }
     // Enter Billing contact
     $billingID = $this->addOrEditContact($customerID, $contacts['billing']);
     if (!is_numeric($billingID) || $billingID < 0) {
         fatal_error("ResellerClub::registerDomain", "could not add Billing contact for domain registration at Reseller Club!");
     }
     return array("customerid" => $customerID, "adminid" => $adminID, "techid" => $techID, "billingid" => $billingID);
 }
/**
 * Load multiple Account DBO's from database
 *
 * @param string $filter A WHERE clause
 * @param string $sortby Field name to sort results by
 * @param string $sortdir Direction to sort in (ASEC or DESC)
 * @param integer $limit Limit the number of results
 * @param integer $start Record number to start the results at
 * @return array Array of AccountDBO's
 */
function &load_array_AccountDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
    $DB = DBConnection::getDBConnection();
    // Build query
    $sql = $DB->build_select_sql("account", "*", $filter, $sortby, $sortdir, $limit, $start);
    // Run query
    if (!($result = @mysql_query($sql, $DB->handle()))) {
        // Query error
        throw new DBException(mysql_error($DB->handle()));
    }
    if (mysql_num_rows($result) == 0) {
        // No rows found
        throw new DBNoRowsFoundException();
    }
    // Build an array of DBOs from the result set
    $dbo_array = array();
    while ($data = mysql_fetch_array($result)) {
        // Create and initialize a new DBO with the data from the DB
        $dbo = new AccountDBO();
        $dbo->load($data);
        // Add DomainServiceDBO to array
        $dbo_array[] = $dbo;
    }
    return $dbo_array;
}
Beispiel #7
0
 /**
  * Execute New Account Order
  *
  * Create a new account from the OrderDBO
  *
  * @param string $accountType Account type to be created
  * @param string $accountStatus Status for the new account
  * @param string $billingStatus Billing status for the new account
  * @param string $billingDay Billing day for the new account
  * @return boolean True for success
  */
 public function executeNewAccount($accountType, $accountStatus, $billingStatus, $billingDay)
 {
     // Verify that the username is not in use already
     try {
         load_UserDBO($this->getUsername());
         throw new OrderFailedException("[USER_ALREADY_EXISTS]");
     } catch (DBNoRowsFoundException $e) {
     }
     // Create user
     $userDBO = new UserDBO();
     $userDBO->setUsername($this->getUsername());
     $userDBO->setPassword(md5($this->getPassword()));
     $userDBO->setType("Client");
     add_UserDBO($userDBO);
     // Create the account
     $accountDBO = new AccountDBO();
     $accountDBO->setType($accountType);
     $accountDBO->setStatus($accountStatus);
     $accountDBO->setBillingStatus($billingStatus);
     $accountDBO->setBillingDay($billingDay);
     $accountDBO->setBusinessName($this->getBusinessName());
     $accountDBO->setContactName($this->getContactName());
     $accountDBO->setContactEmail($this->getContactEmail());
     $accountDBO->setAddress1($this->getAddress1());
     $accountDBO->setAddress2($this->getAddress2());
     $accountDBO->setCity($this->getCity());
     $accountDBO->setState($this->getState());
     $accountDBO->setCountry($this->getCountry());
     $accountDBO->setPostalCode($this->getPostalCode());
     $accountDBO->setPhone($this->getPhone());
     $accountDBO->setMobilePhone($this->getMobilePhone());
     $accountDBO->setFax($this->getFax());
     $accountDBO->setUsername($userDBO->getUsername());
     add_AccountDBO($accountDBO);
     $this->setAccountID($accountDBO->getID());
     return $this->execute();
 }