/** * 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 Registration */ function executeRegistration() { // Load the registrar module and verify that it is enabled $this->serviceDBO = load_DomainServiceDBO($this->purchaseDBO->getTLD()); $registry = ModuleRegistry::getModuleRegistry(); $module = $registry->getModule($this->purchaseDBO->getModuleName()); // Set the time of purchase $this->purchaseDBO->setDate(DBConnection::format_datetime(time())); // Prepare contact info $contacts['admin'] = new ContactDBO($this->accountDBO->getContactName(), $this->accountDBO->getBusinessName(), $this->accountDBO->getContactEmail(), $this->accountDBO->getAddress1(), $this->accountDBO->getAddress2(), null, $this->accountDBO->getCity(), $this->accountDBO->getState(), $this->accountDBO->getPostalCode(), $this->accountDBO->getCountry(), $this->accountDBO->getPhone(), null, $this->accountDBO->getFax()); $contacts['tech'] = $contacts['admin']; $contacts['billing'] = $contacts['admin']; // Execute the registration at the Registrar $module->registerNewDomain($this->purchaseDBO->getDomainName(), $this->purchaseDBO->getTLD(), intval($this->purchaseDBO->getTerm() / 12), $contacts, $this->accountDBO); // Store the purchase in database add_DomainServicePurchaseDBO($this->purchaseDBO); // Registration complete $this->setMessage(array("type" => "[DOMAIN_REGISTERED]", "args" => array($this->purchaseDBO->getFullDomainName()))); $this->gotoPage("domains_browse", null, null); }
/** * 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; }