/**
  * 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");
 }
Ejemplo n.º 2
0
/**
 * Delete DomainServiceDBO from database
 *
 * @param DomainServiceDBO &$dbo DomainServiceDBO to delete
 * @return boolean True on success
 */
function delete_DomainServiceDBO(&$dbo)
{
    $DB = DBConnection::getDBConnection();
    // Verify that no purchases exist
    try {
        $tld = $dbo->getTLD();
        load_array_DomainServicePurchaseDBO("tld = '" . $dbo->getTLD() . "'");
        // Can not delete domain service if any purchases exist
        throw new DBException("[PURCHASES_EXIST]");
    } catch (DBNoRowsFoundException $e) {
    }
    // Build SQL
    $sql = $DB->build_delete_sql("domainservice", "tld = " . $DB->quote_smart($dbo->getTLD()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
    // Delete all prices belonging to the deleted domain service.
    $domainPrices = new DomainServicePriceDBO();
    $domainPrices->setTLD($tld);
    deleteAll_DomainServicePriceDBO($domainPrices);
}