diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-07-07 16:49:45 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-07-07 16:49:45 +0000 |
commit | 4311996b40c039a647e00d3fde15d9c1c1ee8551 (patch) | |
tree | da5a59f06ce482ad2d0dde7c6f518bd6461daffa | |
parent | b5baeb0969c42055f514903fd19e0648e4b77db7 (diff) | |
download | elgg-4311996b40c039a647e00d3fde15d9c1c1ee8551.tar.gz elgg-4311996b40c039a647e00d3fde15d9c1c1ee8551.tar.bz2 |
Introducing canEditMetadata
git-svn-id: https://code.elgg.org/elgg/trunk@1318 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/entities.php | 34 | ||||
-rw-r--r-- | engine/lib/metadata.php | 2 |
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;
|