aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-01-03 23:22:33 +0100
committercash <cash.costello@gmail.com>2012-01-04 20:22:14 -0500
commita92b300af8103e4168dc2091e2e8505f756cacf6 (patch)
tree09d924af9f5cc55a06512fe09ea3965a0c745ba2 /engine/lib
parent24a369c78df14469097dd440bba3cee087a39e7b (diff)
downloadelgg-a92b300af8103e4168dc2091e2e8505f756cacf6.tar.gz
elgg-a92b300af8103e4168dc2091e2e8505f756cacf6.tar.bz2
Refs #2051. Fixed: ElggEntity's enable does not recurse.
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index daced6740..d2c86e470 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1385,12 +1385,15 @@ function disable_entity($guid, $reason = "", $recursive = true) {
$__RECURSIVE_DELETE_TOKEN = md5(elgg_get_logged_in_user_guid());
$sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities
- WHERE container_guid=$guid
+ WHERE (
+ container_guid=$guid
or owner_guid=$guid
- or site_guid=$guid", 'entity_row_to_elggstar');
+ or site_guid=$guid
+ ) and enabled='yes'", 'entity_row_to_elggstar');
if ($sub_entities) {
foreach ($sub_entities as $e) {
+ add_entity_relationship($e->guid, 'disabled_with', $entity->guid);
$e->disable($reason);
}
}
@@ -1446,6 +1449,17 @@ function enable_entity($guid) {
$entity->deleteMetadata('disable_reason');
$entity->enableMetadata();
$entity->enableAnnotations();
+
+ $disabled_with_it = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'disabled_with',
+ 'relationship_guid' => $entity->guid,
+ 'inverse_relationship' => true,
+ ));
+
+ foreach ($disabled_with_it as $e) {
+ $e->enable();
+ remove_entity_relationship($e->guid, 'disabled_with', $entity->guid);
+ }
return $result;
}
@@ -2318,3 +2332,4 @@ elgg_register_plugin_hook_handler('volatile', 'metadata', 'volatile_data_export_
/** Register init system event **/
elgg_register_event_handler('init', 'system', 'entities_init');
+