From d428bf5721dbf25df415a0775117d3e791d1c05c Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 9 Feb 2009 17:07:39 +0000 Subject: Refs #640: Entity disable now recursive git-svn-id: https://code.elgg.org/elgg/trunk@2696 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index d4c01857b..8eee20857 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1639,7 +1639,7 @@ * @param int $guid The guid * @param string $reason Optional reason */ - function disable_entity($guid, $reason = "") + function disable_entity($guid, $reason = "", $recursive = true) { global $CONFIG; @@ -1652,8 +1652,20 @@ if ($reason) create_metadata($guid, 'disable_reason', $reason,'', 0, ACCESS_PUBLIC); - //$entity->disable_reason = $reason; - + + if ($recursive) + { + // Temporary token overriding access controls TODO: Do this better. + static $__RECURSIVE_DELETE_TOKEN; + $__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid()); // Make it slightly harder to guess + + $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid=$guid or owner_guid=$guid or site_guid=$guid", 'entity_row_to_elggstar'); + foreach ($sub_entities as $e) + $e->disable($reason); + + $__RECURSIVE_DELETE_TOKEN = null; + } + $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}"); return $res; -- cgit v1.2.3