/**
  * Assign Domain Service
  *
  * Create a DomainServicePurchaseDBO and add it to the database
  */
 public function assign_service()
 {
     // The domain name is required but not configured as such.  This is to allow the
     // page to update the price dynamically
     if (!isset($this->post['domainname'])) {
         throw new FieldMissingException("domainname");
     }
     // Create new DomainServicePurchase DBO
     $purchase_dbo = new DomainServicePurchaseDBO();
     $purchase_dbo->setAccountID($this->get['account']->getID());
     $purchase_dbo->setTLD($this->post['tld']->getTLD());
     $purchase_dbo->setTerm($this->post['term'] ? $this->post['term']->getTermLength() : null);
     $purchase_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $purchase_dbo->setDomainName($this->post['domainname']);
     $purchase_dbo->setNote($this->post['note']);
     // Save purchase
     add_DomainServicePurchaseDBO($purchase_dbo);
     // Success
     $this->setMessage(array("type" => "[DOMAIN_ASSIGNED]"));
     $this->gotoPage("accounts_view_account", null, "action=domains&account=" . $this->get['account']->getID());
 }
/**
 * Load multiple DomainServicePurchaseDBO'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 DomainServicePurchaseDBO's
 */
function &load_array_DomainServicePurchaseDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
    $DB = DBConnection::getDBConnection();
    // Build query
    $sql = $DB->build_select_sql("domainservicepurchase", "*", $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 services 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 DomainServicePurchaseDBO();
        $dbo->load($data);
        // Add HostingServiceDBO to array
        $dbo_array[] = $dbo;
    }
    return $dbo_array;
}
Пример #3
0
 /**
  * Execute Domain Order
  *
  * Register or Transfer the domain and create a new Domain Service Purchase
  * for this order item
  *
  * @param AccountDBO $accountDBO Account object
  * @return boolean True for success
  */
 function execute($accountDBO)
 {
     switch ($this->getType()) {
         case "Existing":
             // Do nothing
             return true;
             break;
         case "New":
             if (!$this->registerDomain($accountDBO)) {
                 return false;
             }
             break;
         case "Transfer":
             if (!$this->transferDomain($accountDBO)) {
                 return false;
             }
             break;
         default:
             fatal_error("OrderDomainDBO::execute()", "Domain order type not supported: " . $this->getType());
     }
     // Create a new domain service purchase record
     $purchaseDBO = new DomainServicePurchaseDBO();
     $purchaseDBO->setAccountID($accountDBO->getID());
     $purchaseDBO->setTLD($this->getTLD());
     $purchaseDBO->setTerm($this->getTerm());
     $purchaseDBO->setDomainName($this->getDomainName());
     $purchaseDBO->setDate(DBConnection::format_datetime(time()));
     $purchaseDBO->setPrevInvoiceID(-1);
     $purchaseDBO->incrementNextBillingDate();
     add_DomainServicePurchaseDBO($purchaseDBO);
     // Fulfill this order item
     $this->setStatus("Fulfilled");
     update_OrderDomainDBO($this);
     // Success
     return true;
 }