/** * Fetch Average Rating * Will create a unstored one if none could be fetched ( it will have rating_avrage and rating_count of 0 ) * * @return ezsrRatingObject */ function getAverageRating() { $avgRating = ezsrRatingObject::fetchByObjectId($this->attribute('contentobject_id'), $this->attribute('contentobject_attribute_id')); if (!$avgRating instanceof ezsrRatingObject) { $avgRating = ezsrRatingObject::create(array('contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $this->attribute('contentobject_attribute_id'))); } return $avgRating; }
function objectAttributeContent( $contentObjectAttribute ) { $objectId = $contentObjectAttribute->attribute('contentobject_id'); $attributeId = $contentObjectAttribute->attribute('id'); $ratingObj = null; if ( $objectId && $attributeId ) { $ratingObj = ezsrRatingObject::fetchByObjectId( $objectId, $attributeId ); // Create empty object if none could be fetched if ( !$ratingObj instanceof ezsrRatingObject ) { $ratingObj = ezsrRatingObject::create( array('contentobject_id' => $objectId, 'contentobject_attribute_id' => $attributeId ) ); } } return $ratingObj; }