aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/annotations.php21
-rw-r--r--engine/lib/entities.php3
-rw-r--r--engine/lib/metadata.php21
-rw-r--r--engine/lib/users.php15
4 files changed, 59 insertions, 1 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 8ad918180..dd647444a 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -820,6 +820,27 @@
}
}
+ }
+
+ /**
+ * Clear all annotations belonging to a given owner_guid
+ *
+ * @param int $owner_guid The owner
+ */
+ function clear_annotations_by_owner($owner_guid)
+ {
+ $owner_guid = (int)$owner_guid;
+
+ $annotations = get_data("SELECT id from {$CONFIG->dbprefix}annotations WHERE owner_guid=$owner_guid");
+ $deleted = 0;
+
+ foreach ($annotations as $id)
+ {
+ if (delete_annotation($id)) // Is this the best way?
+ $deleted++;
+ }
+
+ return $deleted;
}
/**
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index ff4487570..fc572e29a 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1843,7 +1843,7 @@
$entity->clearAnnotations();
$entity->clearRelationships();
remove_from_river_by_subject($guid);
- remove_from_river_by_object($guid);
+ remove_from_river_by_object($guid);
$res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
if ($res)
{
@@ -2777,6 +2777,7 @@
// Allow a permission override for recursive entity deletion
// TODO: Can this be done better?
register_plugin_hook('permissions_check','all','recursive_delete_permissions_check');
+ register_plugin_hook('permissions_check:metadata','all','recursive_delete_permissions_check');
register_plugin_hook('gc','system','entities_gc');
}
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 3decc1461..57987107c 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -730,6 +730,27 @@
return delete_data("DELETE from {$CONFIG->dbprefix}metadata where entity_guid={$entity_guid}");
}
return false;
+ }
+
+ /**
+ * Clear all annotations belonging to a given owner_guid
+ *
+ * @param int $owner_guid The owner
+ */
+ function clear_metadata_by_owner($owner_guid)
+ {
+ $owner_guid = (int)$owner_guid;
+
+ $metas = get_data("SELECT id from {$CONFIG->dbprefix}metadata WHERE owner_guid=$owner_guid");
+ $deleted = 0;
+
+ foreach ($metas as $id)
+ {
+ if (delete_metadata($id)) // Is this the best way?
+ $deleted++;
+ }
+
+ return $deleted;
}
/**
diff --git a/engine/lib/users.php b/engine/lib/users.php
index e45223e54..5a9234dc6 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -143,6 +143,21 @@
// Now save specific stuff
return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'), $this->get('code'));
+ }
+
+ /**
+ * User specific override of the entity delete method.
+ *
+ * @return bool
+ */
+ public function delete()
+ {
+ // Delete owned data
+ clear_annotations_by_owner($this->owner_guid);
+ clear_metadata_by_owner($this->owner_guid);
+
+ // Delete entity
+ return parent::delete();
}
/**