diff options
Diffstat (limited to 'engine/classes/ElggEntity.php')
-rw-r--r-- | engine/classes/ElggEntity.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 5e43ab582..13b08a122 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -593,6 +593,40 @@ abstract class ElggEntity extends ElggData implements } /** + * Count the number of comments attached to this entity. + * + * @return int Number of comments + * @since 1.8.0 + */ + function countComments() { + $type = $this->getType(); + $params = array('entity' => $this); + $number = elgg_trigger_plugin_hook('comments:count', $type, $params, false); + if ($number) { + return $number; + } else { + return count_annotations($this->getGUID(), "", "", "generic_comment"); + } + } + + /** + * Count how many people have liked this entity. + * + * @return int Number of likes + * @since 1.8.0 + */ + function countLikes() { + $type = $this->getType(); + $params = array('entity' => $this); + $number = elgg_trigger_plugin_hook('likes:count', $type, $params, false); + if ($number) { + return $number; + } else { + return count_annotations($this->getGUID(), "", "", "likes"); + } + } + + /** * Gets an array of entities with a relationship to this entity. * * @param string $relationship Relationship type (eg "friends") @@ -887,8 +921,11 @@ abstract class ElggEntity extends ElggData implements * @param string $size The size its for. * * @return bool + * @deprecated 1.8 See getIconURL() for the plugin hook to use */ public function setIcon($url, $size = 'medium') { + elgg_deprecated_notice("icon_override on an individual entity is deprecated", 1.8); + $url = sanitise_string($url); $size = sanitise_string($size); |