/** * Add */ public function executeAdd() { if ($this->isGET()) { return $this->renderJson(array("success" => false, "info" => "POST only.")); } else { $name = $this->getRequestParameter('name'); $domain = new Domain(); $domain->setName($name); $domain->setType($this->template->getType()); $domain->save(); foreach ($this->template->getTemplateRecords() as $tr) { $record = new Record(); $record->setDomainId($domain->getId()); $record->setName(str_replace("%DOMAIN%", $name, $tr->getName())); $record->setType($tr->getType()); if ($tr->getType() == 'SOA') { $content = str_replace("%DOMAIN%", $name, $tr->getContent()); $content = str_replace("%SERIAL%", date("Ymd") . "01", $content); } else { $content = $tr->getContent(); } $record->setContent($content); $record->setTtl($tr->getTtl()); $record->setPrio($tr->getPrio()); $record->save(); } return $this->renderJson(array("success" => true, "info" => "Domain added.")); } }
/** * Set the column type from a string property * (normally a string from an sql input file) * * @deprecated Do not use; this will be removed in next release. */ public function setTypeFromString($typeName, $size) { $tn = strtoupper($typeName); $this->setType($tn); if ($size !== null) { $this->size = $size; } if (strpos($tn, "CHAR") !== false) { $this->domain->setType(PropelTypes::VARCHAR); } elseif (strpos($tn, "INT") !== false) { $this->domain->setType(PropelTypes::INTEGER); } elseif (strpos($tn, "FLOAT") !== false) { $this->domain->setType(PropelTypes::FLOAT); } elseif (strpos($tn, "DATE") !== false) { $this->domain->setType(PropelTypes::DATE); } elseif (strpos($tn, "TIME") !== false) { $this->domain->setType(PropelTypes::TIMESTAMP); } elseif (strpos($tn, "BINARY") !== false) { $this->domain->setType(PropelTypes::LONGVARBINARY); } else { $this->domain->setType(PropelTypes::VARCHAR); } }