aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:56:06 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:56:06 +0000
commit1a792bebc590cdcfc1b888a33209df92be51400d (patch)
tree87e913b42593b74713a9280b7a7ea3ca4bb2f93e /engine/classes
parentcfaa89dd2d32bc3c17d55def95a1fd49187e1667 (diff)
downloadelgg-1a792bebc590cdcfc1b888a33209df92be51400d.tar.gz
elgg-1a792bebc590cdcfc1b888a33209df92be51400d.tar.bz2
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
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggEntity.php37
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);