Example #1
0
 /**
  * @param	Domain $domain The domain object to add.
  */
 protected function doAddDomain($domain)
 {
     $this->collDomains[] = $domain;
     $domain->setAccount($this);
 }
Example #2
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();
 }