/** * Add Price */ protected function addPrice() { if ($this->post['type'] == "Onetime" && $this->post['termlength'] != 0) { throw new SWUserException("[TERMLENGTH_FOR_ONETIME_MUST_BE_ZERO]"); } if ($this->post['type'] == "Recurring" && $this->post['termlength'] == 0) { throw new SWUserException("[TERMLENGTH_FOR_RECURRING_MUST_NOT_BE_ZERO]"); } $priceDBO = new DomainServicePriceDBO(); $priceDBO->setTLD($this->get['dservice']->getTLD()); $priceDBO->setType($this->post['type']); $priceDBO->setTermLength($this->post['termlength']); $priceDBO->setPrice($this->post['price']); $priceDBO->setTaxable($this->post['taxable']); try { $this->get['dservice']->addPrice($priceDBO); add_DomainServicePriceDBO($priceDBO); $this->setMessage(array("type" => "[PRICE_ADDED]")); } catch (DuplicatePriceException $e) { update_DomainServicePriceDBO($priceDBO); $this->setMessage(array("type" => "[PRICE_UPDATED]")); } $this->reload("&sstab=pricing"); }
/** * Insert DomainServiceDBO into database * * @param DomainServiceDBO &$dbo DomainServiceDBO to add to database * @return boolean True on success */ function add_DomainServiceDBO(&$dbo) { $DB = DBConnection::getDBConnection(); // Build SQL $sql = $DB->build_insert_sql("domainservice", array("tld" => $dbo->getTLD(), "modulename" => $dbo->getModuleName(), "description" => $dbo->getDescription(), "public" => $dbo->getPublic())); // Run query if (!mysql_query($sql, $DB->handle())) { throw new DBException(mysql_error($DB->handle())); } // Add all the PriceDBO's for this object foreach ($dbo->getPricing() as $price) { add_DomainServicePriceDBO($price); } return true; }