From 1a792bebc590cdcfc1b888a33209df92be51400d Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 6 Feb 2011 19:56:06 +0000 Subject: moved the count comments and likes functions into the ElggEntity class git-svn-id: http://code.elgg.org/elgg/trunk@8047 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggEntity.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'engine/classes/ElggEntity.php') 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 @@ -592,6 +592,40 @@ abstract class ElggEntity extends ElggData implements return get_annotations_max($this->getGUID(), "", "", $name); } + /** + * 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. * @@ -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); -- cgit v1.2.3