Пример #1
0
 /**
  * Validate an User
  *
  * Verifies that the user exists.
  *
  * @param string $data Field data
  * @return UserDBO User DBO for this User ID
  * @throws RecordNotFoundException
  */
 public function validate($data)
 {
     $data = parent::validate($data);
     try {
         $userDBO = load_UserDBO($data);
     } catch (DBNoRowsFoundException $e) {
         throw new RecordNotFoundException("User");
     }
     return $userDBO;
 }
Пример #2
0
 /**
  * Login
  *
  * Validate the login.  Store the UserDBO in the session if OK, or display an error
  * if the login failed.
  */
 function login()
 {
     try {
         $user_dbo = load_UserDBO($this->post['username']);
         if ($user_dbo->getPassword() == $this->post['password'] && ($user_dbo->getType() == "Administrator" || $user_dbo->getType() == "Account Manager")) {
             // Login success
             if (isset($this->post['theme'])) {
                 $user_dbo->setTheme($this->post['theme']);
             }
             $_SESSION['client']['userdbo'] = $user_dbo;
             log_notice("Login", "User: "******" logged in");
             $_SESSION['jsFunction'] = "reloadMenu()";
             $this->gotoPage("home");
         }
     } catch (DBNoRowsFoundException $e) {
     }
     // Login failure
     log_security("Login", "Login failed for " . $this->post['username']);
     throw new SWUserException("[LOGIN_FAILED]");
 }
Пример #3
0
 /**
  * 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");
 }
 /**
  * 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");
 }
Пример #5
0
 /**
  * Save Changes
  *
  * Write any changes made to the order to the database
  *
  * @return boolean True for success
  */
 function saveChanges()
 {
     if ($this->get['order']->getAccountType() == "New Account") {
         if (!isset($this->post['username'])) {
             throw new FieldMissingException("username");
         }
         try {
             load_UserDBO($this->post['username']);
             throw new SWUserException("[DB_USER_EXISTS]");
         } catch (DBNoRowsFoundException $e) {
         }
         $this->get['order']->setUsername($this->post['username']);
         if (isset($this->post['password'])) {
             $this->get['order']->setPassword($this->post['password']);
         }
     }
     // Update OrderDBO
     $this->get['order']->setContactName($this->post['contactname']);
     $this->get['order']->setContactEmail($this->post['contactemail']);
     $this->get['order']->setAddress1($this->post['address1']);
     $this->get['order']->setAddress2($this->post['address2']);
     $this->get['order']->setCity($this->post['city']);
     $this->get['order']->setState($this->post['state']);
     $this->get['order']->setCountry($this->post['country']);
     $this->get['order']->setPostalCode($this->post['postalcode']);
     $this->get['order']->setPhone($this->post['phone']);
     $this->get['order']->setMobilePhone($this->post['mobilephone']);
     $this->get['order']->setFax($this->post['fax']);
     $acceptedItems = is_array($this->post['items']) ? $this->post['items'] : array();
     foreach ($this->get['order']->getItems() as $itemDBO) {
         if (in_array($itemDBO, $acceptedItems)) {
             $this->get['order']->acceptItem($itemDBO->getOrderItemID());
         } else {
             $this->get['order']->rejectItem($itemDBO->getOrderItemID());
         }
     }
     // Save changes to database
     update_OrderDBO($this->get['order']);
 }
Пример #6
0
 /**
  * Process the Customer Information Form
  */
 function process()
 {
     if ($this->session['order']->getAccountID() == null) {
         // Verify password
         if ($this->post['password'] != $this->post['repassword']) {
             $this->setError(array("type" => "[PASSWORD_MISMATCH]"));
             return;
         }
         // Verify e-mail
         if ($this->post['contactemail'] != $this->post['verifyemail']) {
             $this->setError(array("type" => "[EMAIL_MISMATCH]"));
             return;
         }
         // Check for a duplicate username
         try {
             load_UserDBO($this->post['username']);
             throw new SWUserException("[USERNAME_EXISTS]");
         } catch (DBNoRowsFoundException $e) {
         }
         $this->session['order']->setNote($this->post['note']);
         // Stuff the contact info into the order
         $this->session['order']->setBusinessName($this->post['businessname']);
         $this->session['order']->setContactname($this->post['contactname']);
         $this->session['order']->setContactEmail($this->post['contactemail']);
         $this->session['order']->setAddress1($this->post['address1']);
         $this->session['order']->setAddress2($this->post['address2']);
         $this->session['order']->setCity($this->post['city']);
         $this->session['order']->setState($this->post['state']);
         $this->session['order']->setCountry($this->post['country']);
         $this->session['order']->setPostalCode($this->post['postalcode']);
         $this->session['order']->setPhone($this->post['phone']);
         $this->session['order']->setMobilePhone($this->post['mobilephone']);
         $this->session['order']->setFax($this->post['fax']);
         $this->session['order']->setUsername($this->post['username']);
         $this->session['order']->setPassword($this->post['password']);
     }
     $domainItems = $this->session['order']->getDomainItems();
     if (!empty($domainItems) && ($this->session['customer_information']['domaincontact'] == "same" || $this->session['repeat_customer']['domaincontact'] == "same")) {
         // Contact information for all domains is the same as customer's contact info
         $contactDBO = new ContactDBO($this->session['order']->getContactName(), $this->session['order']->getBusinessName(), $this->session['order']->getContactEmail(), $this->session['order']->getAddress1(), $this->session['order']->getAddress2(), null, $this->session['order']->getCity(), $this->session['order']->getState(), $this->session['order']->getPostalCode(), $this->session['order']->getCountry(), $this->session['order']->getPhone(), $this->session['order']->getMobilePhone(), $this->session['order']->getFax());
         foreach ($domainItems as $domainItem) {
             $this->session['order']->setDomainContact($domainItem->getOrderItemID(), $contactDBO, $contactDBO, $contactDBO);
         }
     }
     $this->gotoPage("domaincontact");
 }
Пример #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();
 }