diff options
Diffstat (limited to 'engine/lib/extender.php')
-rw-r--r-- | engine/lib/extender.php | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/engine/lib/extender.php b/engine/lib/extender.php index a298671f3..f3f3753bc 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -66,7 +66,7 @@ */ protected function set($name, $value, $value_type = "") { - $this->attributes[$name] = $value;
+ $this->attributes[$name] = $value; if ($name == 'value') $this->attributes['value_type'] = detect_extender_valuetype($value, $value_type); @@ -82,15 +82,15 @@ { return get_user($this->owner_guid); } -
- /**
- * Returns the entity this is attached to
- *
- * @return ElggEntity The enttiy
- */
- public function getEntity() {
- return get_entity($this->entity_guid);
- }
+ + /** + * Returns the entity this is attached to + * + * @return ElggEntity The enttiy + */ + public function getEntity() { + return get_entity($this->entity_guid); + } /** * Save this data to the appropriate database table. @@ -101,15 +101,15 @@ * Delete this data. */ abstract public function delete(); -
- /**
- * Determines whether or not the specified user can edit this
- *
- * @param int $user_guid The GUID of the user (defaults to currently logged in user)
- * @return true|false
- */
- public function canEdit($user_guid = 0) {
- return can_edit_extender($this->id,$this->type,$user_guid);
+ + /** + * Determines whether or not the specified user can edit this + * + * @param int $user_guid The GUID of the user (defaults to currently logged in user) + * @return true|false + */ + public function canEdit($user_guid = 0) { + return can_edit_extender($this->id,$this->type,$user_guid); } /** @@ -333,40 +333,40 @@ return true; } } -
- /**
- * Determines whether or not the specified user can edit the specified piece of extender
- *
- * @param int $extender_id The ID of the piece of extender
- * @param string $type 'metadata' or 'annotation'
- * @param int $user_guid The GUID of the user
- * @return true|false
- */
+ + /** + * Determines whether or not the specified user can edit the specified piece of extender + * + * @param int $extender_id The ID of the piece of extender + * @param string $type 'metadata' or 'annotation' + * @param int $user_guid The GUID of the user + * @return true|false + */ function can_edit_extender($extender_id, $type, $user_guid = 0) { -
- if (!isloggedin())
- return false;
+ + if (!isloggedin()) + return false; $user_guid = (int)$user_guid; $user = get_entity($user_guid); - if (!$user) $user = get_loggedin_user();
-
- $functionname = "get_{$type}";
- if (is_callable($functionname)) {
- $extender = $functionname($extender_id);
- } else return false;
-
- if (!is_a($extender,"ElggExtender")) return false;
-
- // If the owner is the specified user, great! They can edit.
- if ($extender->getOwner() == $user->getGUID()) return true;
-
- // If the user can edit the entity this is attached to, great! They can edit.
- if (can_edit_entity($extender->entity_guid,$user->getGUID())) return true;
-
- // Trigger plugin hooks
- return trigger_plugin_hook('permissions_check',$type,array('entity' => $entity, 'user' => $user),false);
-
+ if (!$user) $user = get_loggedin_user(); + + $functionname = "get_{$type}"; + if (is_callable($functionname)) { + $extender = $functionname($extender_id); + } else return false; + + if (!is_a($extender,"ElggExtender")) return false; + + // If the owner is the specified user, great! They can edit. + if ($extender->getOwner() == $user->getGUID()) return true; + + // If the user can edit the entity this is attached to, great! They can edit. + if (can_edit_entity($extender->entity_guid,$user->getGUID())) return true; + + // Trigger plugin hooks + return trigger_plugin_hook('permissions_check',$type,array('entity' => $entity, 'user' => $user),false); + } /** @@ -432,7 +432,7 @@ $url = $CONFIG->wwwroot . "export/$view/$guid/$type/$nameid/"; } return $url; - }
+ } /** Register the hook */ register_plugin_hook("import", "all", "import_extender_plugin_hook", 2); |