aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-25 17:53:05 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-25 17:53:05 +0000
commita84c649d391a13218343bb5a934f26cbb6568f0a (patch)
treef80cf17e4a0af3e2d71792ad3a5ddeb5807d1537 /engine/lib
parent5ad141202c18ebb8591227b8a8239d28b8cc3936 (diff)
downloadelgg-a84c649d391a13218343bb5a934f26cbb6568f0a.tar.gz
elgg-a84c649d391a13218343bb5a934f26cbb6568f0a.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Crude deleteall method added git-svn-id: https://code.elgg.org/elgg/trunk@539 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 21ef3d595..b83b9f4b5 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -807,7 +807,7 @@
$query .= " (access_id in {$access} or (access_id = 0 and owner_guid = {$_SESSION['id']}))"; // Add access controls
if (!$count) {
$query .= " order by $order_by";
- $query .= " limit $offset, $limit"; // Add order and limit
+ if ($limit) $query .= " limit $offset, $limit"; // Add order and limit
$dt = get_data($query, "entity_row_to_elggstar");
return $dt;
} else {
@@ -841,6 +841,25 @@
return false;
}
+
+ /**
+ * Delete multiple entities that match a given query.
+ * This function itterates through and calls delete_entity on each one, this is somewhat inefficient but lets
+ * the 'delete' even be called for each entity.
+ *
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ */
+ function delete_entities($type = "", $subtype = "", $owner_guid = 0)
+ {
+ $entities = get_entities($type, $subtype, $owner_guid, "time_created desc", 0);
+
+ foreach ($entities as $entity)
+ delete_entity($entity->guid);
+
+ return true;
+ }
/**
* Handler called by trigger_plugin_hook on the "export" event.