/**
  * 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");
 }
Example #2
0
/**
 * Update UserDBO
 *
 * @param UserDBO &$dbo UserDBO to update
 * @return boolean True on success
 */
function update_UserDBO(UserDBO $dbo)
{
    $DB = DBConnection::getDBConnection();
    // Build UPDATE query
    $sql = $DB->build_update_sql("user", "username = "******"password" => $dbo->getPassword(), "contactname" => $dbo->getContactName(), "email" => $dbo->getEmail(), "type" => $dbo->getType(), "language" => $dbo->getLanguage(), "theme" => $dbo->getTheme()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
}
Example #3
0
 /**
  * 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);
 }
 /**
  * Process New User
  *
  * Verify the username requested does not already exist, then
  * ask the client to confirm the new User.
  */
 function process_new_user()
 {
     if ($this->post['password'] != $this->post['repassword']) {
         // Destroy the password values so they're not echoed to the form
         unset($this->session['new_user']['password']);
         unset($this->session['new_user']['repassword']);
         // Password not entered correctly
         throw new SWUserException("[PASSWORD_MISMATCH]");
     }
     // Verify this username does not already exist
     try {
         load_UserDBO($this->post['username']);
         // Username already exists
         throw new SWUserException("[DB_USER_EXISTS]");
     } catch (DBNoRowsFoundException $e) {
     }
     // Prepare UserDBO for database insertion
     $user_dbo = new UserDBO();
     $user_dbo->load($this->post);
     // MAY CHANGE
     $user_dbo->setPassword($this->post['password']);
     // Place DBO in the session for the confirm & receipt page
     $this->session['new_user_dbo'] = $user_dbo;
     // Ask client to confirm
     $this->setTemplate("confirm");
 }
Example #5
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();
 }