/**
  * Process a new service purchase
  */
 protected function process()
 {
     // Build an order item for the hosting service
     $hostingItem = new OrderHostingDBO();
     $hostingItem->setPurchasable($this->post['hostingservice']);
     $hostingItem->setTerm($this->post['hostingterm']->getTermLength());
     switch ($this->post['domainoption']) {
         case "New":
             // Register a new domain for use with this hosting service
             // Verify that the user entered a domain name and TLD
             if (!isset($this->post['registerdomainname'])) {
                 throw new FieldMissingException("registerdomainname");
             }
             if (!isset($this->post['registerdomaintld'])) {
                 throw new FieldMissingException("registerdomaintld");
             }
             $fqdn = sprintf("%s.%s", $this->post['registerdomainname'], $this->post['registerdomaintld']->getTLD());
             // Check the domain availability
             $moduleName = $this->post['registerdomaintld']->getModuleName();
             $registrar = ModuleRegistry::getModuleRegistry()->getModule($moduleName);
             if (!$registrar->checkAvailability($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_NOT_AVAILABLE]");
             }
             // Place the domain name in the hosting item
             $hostingItem->setDomainName($fqdn);
             // Create another order item for the domain purchase
             $domainItem = new OrderDomainDBO();
             $domainItem->setType("New");
             $domainItem->setDomainName($this->post['registerdomainname']);
             $domainItem->setPurchasable($this->post['registerdomaintld']);
             $domainItem->setTerm($this->post['registerdomainterm']->getTermLength());
             break;
         case "Transfer":
             // Transfer a domain for use with this hosting service
             // Verify that the user entered a domain name and TLD
             if (!isset($this->post['transferdomainname'])) {
                 throw new FieldMissingException("transferdomainname");
             }
             if (!isset($this->post['transferdomaintld'])) {
                 throw new FieldMissingException("transferdomaintld");
             }
             $fqdn = sprintf("%s.%s", $this->post['transferdomainname'], $this->post['transferdomaintld']->getTLD());
             // Check the domain transfer-ability
             $moduleName = $this->post['registerdomaintld']->getModuleName();
             $registrar = ModuleRegistry::getModuleRegistry()->getModule($moduleName);
             if (!$registrar->isTransferable($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_TRANSFER_NO_DOMAIN]");
             }
             // Place the domain name in the hosting item
             $hostingItem->setDomainName($fqdn);
             // Create another order item for the domain purchase
             $domainItem = new OrderDomainDBO();
             $domainItem->setType("Transfer");
             $domainItem->setDomainName($this->post['transferdomainname']);
             $domainItem->setPurchasable($this->post['transferdomaintld']);
             $domainItem->setTerm($this->post['transferdomainterm']->getTermLength());
             break;
         case "InCart":
             // Use a domain that is in the customer's cart
             // Verify that the user selected a domain
             if (!isset($this->post['incartdomain'])) {
                 throw new FieldMissingException("incartdomain");
             }
             $hostingItem->setDomainName($this->post['incartdomain']);
             break;
         case "Existing":
             // Use an existing domain for this hosting service
             // Verify that the user entered a domain name
             if (!isset($this->post['existingdomainname'])) {
                 throw new FieldMissingException("existingdomainname");
             }
             $hostingItem->setDomainName($this->post['existingdomainname']);
             break;
         default:
             if ($this->post['hostingservice']->isDomainRequired()) {
                 throw new FieldMissingException("domainoption");
             }
             break;
     }
     // Add the item(s) to the order
     $_SESSION['order']->addItem($hostingItem);
     if (isset($domainItem)) {
         $_SESSION['order']->addItem($domainItem);
     }
     // Proceed to the cart page
     $this->gotoPage("cart");
 }
Пример #2
0
/**
 * Load multiple OrderHostingDBO'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 int $limit Limit the number of results
 * @param int $start Record number to start the results at
 * @return array Array of OrderDBO's
 */
function &load_array_OrderHostingDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
    $DB = DBConnection::getDBConnection();
    // Build query
    $sql = $DB->build_select_sql("orderhosting", "*", $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 OrderHostingDBO();
        $dbo->load($data);
        // Add OrderDBO to array
        $dbo_array[] = $dbo;
    }
    return $dbo_array;
}