/** * 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()); }
/** * 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; }