aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-17 17:48:01 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-17 17:48:01 +0000
commit4b50ab5ef56c657f41a7039c1967bd2777293c92 (patch)
tree4eace68ea01f16eccca55f23e7d6285025cce85a /engine
parent2530e3b908028473878d4b681e04a31509116eff (diff)
downloadelgg-4b50ab5ef56c657f41a7039c1967bd2777293c92.tar.gz
elgg-4b50ab5ef56c657f41a7039c1967bd2777293c92.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* limit/offset the wrong way round git-svn-id: https://code.elgg.org/elgg/trunk@238 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/entities.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index d42dbfd5f..9c1de36f0 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -327,6 +327,25 @@
}
/**
+ * This function will register a new subtype, returning its ID as required.
+ *
+ * @param string $subtype
+ */
+ function add_subtype($subtype)
+ {
+ global $CONFIG;
+
+ $subtype = sanitise_string($subtype);
+
+ $id = get_subtype_id($subtype);
+
+ if (!$id)
+ return insert_data("insert into {$CONFIG->dbprefix}entity_subtypes (subtype) values ('$subtype')");
+
+ return $id;
+ }
+
+ /**
* Update an existing entity.
*
* @param int $guid
@@ -360,9 +379,9 @@
function create_entity($type, $subtype, $owner_guid, $access_id)
{
global $CONFIG;
-
+
$type = sanitise_string($type);
- $subtype = get_subtype_id($subtype);
+ $subtype = add_subtype($subtype);
$owner_guid = (int)$owner_guid;
$access_id = (int)$access_id;
$time = time();
@@ -397,7 +416,7 @@
{
if (!($row instanceof stdClass))
return $row;
-
+
switch ($row->type)
{
case 'object' : return new ElggObject($row);
@@ -456,7 +475,7 @@
foreach ($where as $w)
$query .= " $w and ";
$query .= " (access_id in {$access} or (access_id = 0 and owner_guid = {$_SESSION['id']}))"; // Add access controls
- $query .= " order by $order_by limit $offset,$limit"; // Add order and limit
+ $query .= " order by $order_by limit $limit, $offset"; // Add order and limit
return get_data($query, "entity_row_to_elggstar");
}
@@ -512,7 +531,7 @@
foreach ($where as $w)
$query .= " $w and ";
$query .= " (e.access_id in {$access} or (e.access_id = 0 and e.owner_guid = {$_SESSION['id']}))"; // Add access controls
- $query .= " order by $order_by limit $offset,$limit"; // Add order and limit
+ $query .= " order by $order_by limit $limit, $offset"; // Add order and limit
return get_data($query, "entity_row_to_elggstar");
}