Пример #1
0
 public function test_deletion_from_collection_should_destroy_the_active_record()
 {
     $Property = new Property(array('description' => 'This is a Property'));
     $Picture = $Property->picture->create(array('title' => 'Front'));
     $this->assertTrue($Property->save());
     $this->assertTrue($Picture instanceof AkActiveRecord);
     $Property->picture->delete($Picture);
     $StoredProperty = $this->Property->find('first');
     $this->assertEqual($Property->getId(), $StoredProperty->getId());
     $this->assertFalse($this->Picture->find('first', array('default' => false)));
 }
Пример #2
0
 /**
  * Exclude object from result
  *
  * @param   Property $property Object to remove from the list of results
  *
  * @return PropertyQuery The current query, for fluid interface
  */
 public function prune($property = null)
 {
     if ($property) {
         $this->addUsingAlias(PropertyPeer::ID, $property->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Пример #3
0
 public function test_clean_up_dependencies()
 {
     $Property = new Property('description->', 'Luxury Estate');
     $PropertyType = new PropertyType();
     $this->assertTrue($PropertyType =& $PropertyType->create(array('description' => 'Mansion')));
     $Property->property_type->add($PropertyType);
     $this->assertTrue($Property->save());
     $PropertyType =& $PropertyType->findFirstBy('description', 'Mansion');
     $PropertyType->property->load();
     $this->assertEqual($PropertyType->properties[0]->getId(), $Property->getId());
     $this->assertEqual($PropertyType->property->count(), 1);
     $this->assertTrue($Property->destroy());
     $PropertyType =& $PropertyType->findFirstBy('description', 'Mansion');
     $PropertyType->property->load();
     $this->assertTrue(empty($PropertyType->properties[0]));
     $this->assertEqual($PropertyType->property->count(), 0);
 }
Пример #4
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      Property $value A Property object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Property $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #5
0
 /**
  * Сохраняет свойство в БД. Если идентификатор Свойств (ID) пустой, то 
  * добавляет запись в таблицу
  * @global type $DB
  * @param \Property $property Свойство
  * @param string $tableName название таблицы
  */
 static function saveProperty($property, $tableName)
 {
     if ($property->getId() == null) {
         TDataBaseDocument::insertProperty($property, $tableName);
     } else {
         global $DB;
         $sql = 'UPDATE ' . $tableName . ' SET PARENT_ID = ' . $property->getParentId() . ', TYPE="' . $DB->EscapeString($property->getType()) . '", VALUE="' . $DB->EscapeString($property->getValue()) . '" WHERE ID = ' . $property->getId();
         $DB->Query($sql);
     }
 }
Пример #6
0
 /**
  * Updates a property
  *
  * @param int $id The property ID
  * @param array $data
  * @return int The property ID
  */
 public function do_update($id, $data = null)
 {
     $user = $this->requireUser();
     if (!$user->isAdmin()) {
         throw new Exception('Only administrators are allowed to edit properties.');
     }
     // Validate input data
     $validator = new KickstartValidator();
     $locale = Localizer::getInstance();
     $warnings = $validator->filterErrors($data, $this->initFilter($this->filter_basic, $locale));
     if ($warnings) {
         return array('result' => false, 'warnings' => $warnings);
     }
     $query = PropertyQuery::create()->filterByAccount($user->getAccount());
     if ($id !== null) {
         $query->filterById($id, Criteria::NOT_EQUAL);
         $property = PropertyQuery::create()->filterByAccount($user->getAccount())->findOneById($id);
         if (!$property) {
             throw new Exception('Property not found; ID: ' . $id);
         }
     } else {
         $property = new Property();
     }
     // Check for duplicates
     if (isset($data['Name']) and $query->findOneByName($data['Name'])) {
         throw new Exception($locale->insert('error.taken', array('value' => '"' . $data['Name'] . '"')));
     }
     unset($data['Id']);
     $property->fromArray($data);
     $property->setAccount($user->getAccount());
     $property->save();
     return $property->getId();
 }
Пример #7
0
 public function test_clean_up_dependencies()
 {
     $Property = new Property(array('description' => 'Ruins in Matamon'));
     $this->assertTrue($Property->save());
     $South =& $Property->picture->create(array('title' => 'South views'));
     $this->assertReference($South, $Property->pictures[0]);
     $this->assertFalse($South->isNewRecord());
     $pic_id = $South->getId();
     $Property = new Property($Property->getId());
     $this->assertTrue($Property->destroy());
     $Picture = new Picture();
     $this->assertFalse($Picture->find($pic_id));
 }
Пример #8
0
 /**
  * Filter the query by a related Property object
  *
  * @param   Property|PropelObjectCollection $property The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 PropertyValueQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByProperty($property, $comparison = null)
 {
     if ($property instanceof Property) {
         return $this->addUsingAlias(PropertyValuePeer::PROPERTY_ID, $property->getId(), $comparison);
     } elseif ($property instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(PropertyValuePeer::PROPERTY_ID, $property->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByProperty() only accepts arguments of type Property or PropelCollection');
     }
 }
Пример #9
0
 /**
  * Declares an association between this object and a Property object.
  *
  * @param             Property $v
  * @return PropertyValue The current object (for fluent API support)
  * @throws PropelException
  */
 public function setProperty(Property $v = null)
 {
     if ($v === null) {
         $this->setPropertyId(NULL);
     } else {
         $this->setPropertyId($v->getId());
     }
     $this->aProperty = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Property object, it will not be re-added.
     if ($v !== null) {
         $v->addPropertyValue($this);
     }
     return $this;
 }
Пример #10
0
	<div class="property-viewed property-other-people-also-viewed">
		<h4><?php 
        _e('Other people also viewed', THEME_NAME);
        ?>
</h4>
	<?php 
        echo PropertiesManager::getOtherPeopleAlsoViewedHTML($post);
        ?>
	</div>
	<?php 
    }
    ?>
	
	<?php 
    if (estetico_get_setting('show_recently_viewed') == 'yes') {
        $options = array('exclude' => $property->getId());
        if (PropertiesManager::hasRecentlyViewed($options)) {
            ?>
	<div class="property-viewed property-recently-viewed">
		<h4><?php 
            _e('Recently viewed', THEME_NAME);
            ?>
</h4>
		<?php 
            echo PropertiesManager::getRecentlyViewedHTML($options);
            ?>
	</div>
	<?php 
        }
    }
    ?>