aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php34
-rw-r--r--engine/lib/metadata.php2
2 files changed, 35 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 32be24775..abbd67bab 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -337,6 +337,16 @@
*/
function canEdit($user_guid = 0) {
return can_edit_entity($this->getGUID(),$user_guid);
+ }
+
+ /**
+ * Determines whether or not the specified user (by default the current one) can edit metadata on the entity
+ *
+ * @param int $user_guid The user GUID, optionally (defaults to the currently logged in user)
+ * @return true|false
+ */
+ function canEditMetadata($user_guid = 0) {
+ return can_edit_entity_metadata($this->getGUID(), $user_guid);
}
/**
@@ -1329,6 +1339,30 @@
}
+ }
+
+ /**
+ * Determines whether or not the specified user can edit metadata on the specified entity.
+ *
+ * This is extendible by registering a plugin hook taking in the parameters 'entity' and 'user',
+ * which are the entity and user entities respectively
+ *
+ * @see register_plugin_hook
+ *
+ * @param int $entity_guid The GUID of the entity
+ * @param int $user_guid The GUID of the user
+ * @return true|false Whether the specified user can edit the specified entity.
+ */
+ function can_edit_entity_metadata($entity_guid, $user_guid = 0) {
+
+ if ($entity = get_entity($entity_guid)) {
+ $return = can_edit_entity($entity_guid, $user_guid);
+ $return = trigger_plugin_hook('permissions_check:metadata',$entity->type,null,$return);
+ return $return;
+ } else {
+ return false;
+ }
+
}
/**
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 36c2e65c7..130749bdd 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -77,7 +77,7 @@
function canEdit() {
if ($entity = get_entity($this->get('entity_guid'))) {
- return $entity->canEdit();
+ return $entity->canEditMetadata();
}
return false;