aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggEntity.php37
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