public function formObject()
 {
     $model = new Domain($this->data->id);
     $this->data->forUpdate = $this->data->id != '';
     $this->data->object = $model->getData();
     $this->data->title = $this->data->forUpdate ? $model->getDescription() : _M("New Domain");
     $this->data->save = "@fnbr20/admin/domain/save/" . $model->getId() . '|formObject';
     $this->data->delete = "@fnbr20/admin/domain/delete/" . $model->getId() . '|formObject';
     $this->render();
 }
Example #2
0
 /**
  * Filter the query by a related Domain object
  *
  * @param   Domain|PropelObjectCollection $domain The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 UserQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByDomain($domain, $comparison = null)
 {
     if ($domain instanceof Domain) {
         return $this->addUsingAlias(UserPeer::DOMAIN_ID, $domain->getId(), $comparison);
     } elseif ($domain instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(UserPeer::DOMAIN_ID, $domain->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByDomain() only accepts arguments of type Domain or PropelCollection');
     }
 }
Example #3
0
 /**
  * Declares an association between this object and a Domain object.
  *
  * @param             Domain $v
  * @return HolidayDomain The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDomain(Domain $v = null)
 {
     if ($v === null) {
         $this->setDomainId(NULL);
     } else {
         $this->setDomainId($v->getId());
     }
     $this->aDomain = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Domain object, it will not be re-added.
     if ($v !== null) {
         $v->addHolidayDomain($this);
     }
     return $this;
 }
Example #4
0
 /**
  * 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."));
     }
 }
Example #5
0
function domain_add($tmp, $page, $domainid = '')
{
    if ('' != $domainid) {
        $domain = Domain::getDomainById($domainid);
    } else {
        $domain = new Domain();
    }
    $msec_conf_a =& ModSecConfiguration::getAllModSecConfigurations();
    $msec_confs = array();
    $msec_id[] = 0;
    $msec_name[] = 'None';
    foreach ($msec_conf_a as $conf) {
        $msec_id[] = $conf->getId();
        $msec_name[] = $conf->getName();
    }
    $tmp->assign(array('did' => $domain->getId(), 'dname' => $domain->getName(), 'sname' => $domain->getServerName(), 'sip' => $domain->getServerIP(), 'sport' => $domain->getServerPort(), 'sadmin' => $domain->getServerAdmin(), 'salias' => $domain->getAlias(), 'other' => $domain->getOther(), 'msec_id' => $msec_id, 'msec_name' => $msec_name, 'mod_sec_conf' => $domain->getModSecConf(), 'validity' => $domain->isActive()));
    $tmp->assign('tab_page', $page);
}
Example #6
0
 /**
  * Updates a domain
  *
  * @param int $intId
  * @param array $arrData
  * @return int The domain ID
  */
 public function do_update($intId, $arrData)
 {
     $domain = null;
     $con = Propel::getConnection();
     if (!$con->beginTransaction()) {
         throw new Exception('Could not start transaction.');
     }
     try {
         $user = $this->requireUser();
         $account = $user->getAccount($con);
         // Validate input data
         $validator = new KickstartValidator();
         $locale = Localizer::getInstance();
         $warnings = $validator->filterErrors($arrData, $this->initFilter($this->filter_basic, $locale));
         if ($warnings) {
             $con->rollBack();
             return array('result' => false, 'warnings' => $warnings);
         }
         $query = DomainQuery::create()->filterByAccount($account);
         if ($intId !== null) {
             $domain = DomainQuery::create()->filterByAccount($account)->findOneById($intId, $con);
             if ($domain === null) {
                 throw new Exception('Domain not found; ID: ' . $intId);
             }
             $query->filterById($intId, Criteria::NOT_EQUAL);
         } else {
             $domain = new Domain();
             $domain->setAccount($account);
         }
         // Check for duplicates
         if ($query->findOneByName($arrData['Name'], $con)) {
             throw new Exception($locale->insert('error.taken', array('value' => '"' . $arrData['Name'] . '"')));
         }
         $domain->fromArray(array_intersect_key($arrData, array('AddressId' => true, 'Name' => true, 'Description' => true, 'Number' => true)));
         $domain->save($con);
         if (!empty($arrData['Properties'])) {
             $domain->setProperties($arrData['Properties'], $con);
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
     if (!$con->commit()) {
         throw new Exception('Could not commit transaction.');
     }
     return $domain->getId();
 }
Example #7
0
 /**
  * Exclude object from result
  *
  * @param   Domain $domain Object to remove from the list of results
  *
  * @return DomainQuery The current query, for fluid interface
  */
 public function prune($domain = null)
 {
     if ($domain) {
         $this->addUsingAlias(DomainPeer::ID, $domain->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Example #8
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Domain $obj A Domain object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         DomainPeer::$instances[$key] = $obj;
     }
 }
Example #9
0
 /**
  * Retrieves the most-specific property value for the specified user, domain or account.
  *
  * If a user does not have a specific value set, the user's domain is
  * searched for the value, and if this does not yield anything, the account
  * will be scanned for the default value.
  *
  * @param string $name The property name.
  * @param Account $account The account defining the properties.
  * @param Domain $domain Optional. Default is NULL.
  * @param User $user Optional. Default is NULL.
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @return mixed The property value, or NULL if no property is found.
  * @see getProperty()
  */
 public static function get($name, Account $account, Domain $domain = null, User $user = null, PropelPDO $con = null)
 {
     $property = PropertyQuery::create()->filterByAccount($account)->findOneByName($name, $con);
     if ($property === null) {
         return null;
     }
     $accountId = $account->getId();
     $domainId = $domain === null ? null : $domain->getId();
     $userId = $user === null ? null : $user->getId();
     $values = self::createPropertyValueQuery($accountId, null, null)->findByPropertyId($property->getId(), $con);
     $result = PropertyPeer::initValue(json_decode($property->getDefaultValue(), true), $property->getType());
     foreach ($values as $value) {
         $valueUserId = $value->getUserId();
         if ($valueUserId !== null and $valueUserId === $userId) {
             return $value->get($con);
         } elseif ($valueUserId !== null) {
             continue;
         } elseif ($value->getDomainId() === $domainId and $domainId !== null) {
             $result = $value->get($con);
         }
     }
     return $result;
 }
Example #10
0
 public function delete(Domain &$domain)
 {
     $this->db->query("delete from Domain where id=" . $domain->getId());
 }