From 48c29f1d2217fed8db865ed32d2e7c226da85d06 Mon Sep 17 00:00:00 2001 From: icewing Date: Tue, 10 Jun 2008 11:01:49 +0000 Subject: Marcus Povey * Bugfixed canEdit and isFullyLoaded git-svn-id: https://code.elgg.org/elgg/trunk@844 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/engine/lib/entities.php b/engine/lib/entities.php index f95993dcb..7dcfc5f85 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -409,7 +409,7 @@ * * @return bool */ - public function isFullyLoaded() { return $this->attributes['tables_split'] == $this->attributes['tables_loaded']; } + public function isFullyLoaded() { return ! ($this->attributes['tables_loaded'] < $this->attributes['tables_split']); } /** * Save generic attributes to the entities table. @@ -709,7 +709,7 @@ { global $ENTITY_CACHE; - $ENTITY_CACHE[$entity->guid] = &$entity; + $ENTITY_CACHE[$entity->guid] = $entity; } /** @@ -871,17 +871,16 @@ */ function update_entity($guid, $owner_guid, $access_id) { - global $CONFIG; + global $CONFIG, $ENTITY_CACHE; $guid = (int)$guid; $owner_guid = (int)$owner_guid; $access_id = (int)$access_id; $time = time(); - + $entity = get_entity($guid); if ($entity->canEdit()) { - if (trigger_event('update',$entity->type,$entity)) { $ret = update_data("UPDATE {$CONFIG->dbprefix}entities set owner_guid='$owner_guid', access_id='$access_id', time_updated='$time' WHERE guid=$guid"); @@ -1226,26 +1225,25 @@ * @return true|false Whether the specified user can edit the specified entity. */ function can_edit_entity($entity_guid, $user_guid = 0) { - + echo "e_guid:$entity_guid, u_guid:$user_guid"; if ($user_guid == 0) { - if (isset($_SESSION['user'])) { + + if (isset($_SESSION['user'])) { $user = $_SESSION['user']; - } else { + } else { $user = null; } - } else { + } else { $user = get_entity($user_guid); } if (($entity = get_entity($entity_guid)) && (!is_null($user))) { - if ($entity->getOwner() == $user->getGUID()) return true; if ($entity->type == "user" && $entity->getGUID() == $user->getGUID()) return true; return trigger_plugin_hook('permissions_check',$entity->type,array('entity' => $entity, 'user' => $user),false); - } else { - + } else { return false; } -- cgit v1.2.3