]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2051. Fixed: ElggEntity's enable does not recurse.
authorSem <sembrestels@riseup.net>
Tue, 3 Jan 2012 22:22:33 +0000 (23:22 +0100)
committercash <cash.costello@gmail.com>
Thu, 5 Jan 2012 01:22:14 +0000 (20:22 -0500)
engine/lib/entities.php

index daced6740e3f0276c1ca111cedb5f4fb6a4976c9..d2c86e470da19213983ba8999d54295b9a402dd0 100644 (file)
@@ -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');
+