aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-09 17:07:39 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-09 17:07:39 +0000
commitd428bf5721dbf25df415a0775117d3e791d1c05c (patch)
tree619c0fd2856e9c7e18c5af9f9d77d6b82bb40cb7 /engine/lib/entities.php
parentfbd79f863a8cad8ba17c80be011ecfda914d37c5 (diff)
downloadelgg-d428bf5721dbf25df415a0775117d3e791d1c05c.tar.gz
elgg-d428bf5721dbf25df415a0775117d3e791d1c05c.tar.bz2
Refs #640: Entity disable now recursive
git-svn-id: https://code.elgg.org/elgg/trunk@2696 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php18
1 files changed, 15 insertions, 3 deletions
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;