diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-21 02:35:43 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-21 02:35:43 +0000 |
commit | 0030fe2d63684b6612316b5162d34bfaa5dbfee1 (patch) | |
tree | 187a1d912d73addcbab72cf191b6f81ecc0778c8 /engine | |
parent | 25587657328ca8b492a497e385a2fc3887925848 (diff) | |
download | elgg-0030fe2d63684b6612316b5162d34bfaa5dbfee1.tar.gz elgg-0030fe2d63684b6612316b5162d34bfaa5dbfee1.tar.bz2 |
fixes #2885 #2569 likes controlled by canAnnotate() with plugin hook
git-svn-id: http://code.elgg.org/elgg/trunk@8382 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/classes/ElggEntity.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 0298d6d6e..69401a7e5 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -935,9 +935,9 @@ abstract class ElggEntity extends ElggData implements } /** - * Can a user comment on an entity + * Can a user comment on an entity? * - * @tip Can be overridden vy registering for the permissions_check:comment, + * @tip Can be overridden by registering for the permissions_check:comment, * <entity type> plugin hook. * * @param int $user_guid User guid (default is logged in user) @@ -957,6 +957,39 @@ abstract class ElggEntity extends ElggData implements } /** + * Can a user annotate an entity? + * + * @tip Can be overridden by registering for the permissions_check:annotate, + * <entity type> plugin hook. + * + * @tip If you want logged out users to annotate an object, do not call + * canAnnotate(). It's easier than using the plugin hook. + * + * @param int $user_guid User guid (default is logged in user) + * @param string $annotation_name The name of the annotation (default is unspecified) + * + * @return bool + */ + public function canAnnotate($user_guid = 0, $annotation_name = '') { + if ($user_guid == 0) { + $user_guid = elgg_get_logged_in_user_guid(); + } + $user = get_entity($user_guid); + + $return = true; + if (!$user) { + $return = false; + } + + $params = array( + 'entity' => $this, + 'user' => $user, + 'annotation_name' => $annotation_name, + ); + return elgg_trigger_plugin_hook('permissions_check:annotate', $this->type, $params, $return); + } + + /** * Returns the access_id. * * @return int The access ID |