diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-21 01:45:21 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-21 01:45:21 +0000 |
commit | 25587657328ca8b492a497e385a2fc3887925848 (patch) | |
tree | 4cdbe86ac86cc9e658cdef254fb82ba447dea5f4 /engine/classes/ElggEntity.php | |
parent | be812b46692dc21dc39932941f421aba32d59b7c (diff) | |
download | elgg-25587657328ca8b492a497e385a2fc3887925848.tar.gz elgg-25587657328ca8b492a497e385a2fc3887925848.tar.bz2 |
Fixes #2971 added canComment() method and implemented it for ElggBlog
git-svn-id: http://code.elgg.org/elgg/trunk@8381 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ElggEntity.php')
-rw-r--r-- | engine/classes/ElggEntity.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index d6c8a1311..0298d6d6e 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -935,6 +935,28 @@ abstract class ElggEntity extends ElggData implements } /** + * Can a user comment on an entity + * + * @tip Can be overridden vy registering for the permissions_check:comment, + * <entity type> plugin hook. + * + * @param int $user_guid User guid (default is logged in user) + * + * @return bool + */ + public function canComment($user_guid = 0) { + if ($user_guid == 0) { + $user_guid = elgg_get_logged_in_user_guid(); + } + $user = get_entity($user_guid); + + // By default, we don't take a position of whether commenting is allowed + // because it is handled by the subclasses of ElggEntity + $params = array('entity' => $this, 'user' => $user); + return elgg_trigger_plugin_hook('permissions_check:comment', $this->type, $params, null); + } + + /** * Returns the access_id. * * @return int The access ID |