aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-11 16:25:17 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-11 16:25:17 +0000
commite17011295c2b28cafa70269ba4b885f0529bbd1a (patch)
tree539b39bb067f8e0aed809d63dca51360b3c82dab /engine/lib
parent5577149cb5af76af8af5a844d22c6ceb6241eec1 (diff)
downloadelgg-e17011295c2b28cafa70269ba4b885f0529bbd1a.tar.gz
elgg-e17011295c2b28cafa70269ba4b885f0529bbd1a.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Added orderby and limits git-svn-id: https://code.elgg.org/elgg/trunk@166 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/annotations.php6
-rw-r--r--engine/lib/metadata.php13
2 files changed, 13 insertions, 6 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 3ff8c0e69..21f62f715 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -143,7 +143,7 @@
* @param int $limit
* @param int $offset
*/
- function get_annotations($object_id = 0, $object_type = "", $name = "", $value = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0)
+ function get_annotations($object_id = 0, $object_type = "", $name = "", $value = "", $owner_id = 0, $object_subtype = "", $order_by = "created desc", $limit = 10, $offset = 0)
{
global $CONFIG;
@@ -187,7 +187,9 @@
if ($n > 0) $query .= " and ";
$query .= $where[$n];
}
- error_log($query);
+
+ $query .= " order by $order_by limit $offset,$limit";
+
return get_data($query, "row_to_elggannotation");
}
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 3659a7075..0a82ec4dd 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -248,7 +248,7 @@
* @param int $offset
* @return array of ElggMetadata
*/
- function get_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0)
+ function get_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $object_subtype = "", $order_by = "created desc", $limit = 10, $offset = 0)
{
global $CONFIG;
@@ -257,8 +257,9 @@
$name = sanitise_string(trim($name));
$value = sanitise_string(trim($value));
$value_type = sanitise_string(trim($value_type));
-
+ $object_subtype = get_object_type_id($object_subtype);
$owner_id = (int)$owner_id;
+ $order_by = sanitise_string($order_by);
$limit = (int)$limit;
$offset = (int)$offset;
@@ -287,6 +288,9 @@
// add access controls
$access = get_access_list();
$where[] = "(access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))";
+
+ if ($object_subtype!="")
+ $where[] = "";
// construct query.
$query = "SELECT * from {$CONFIG->dbprefix}metadata where ";
@@ -295,6 +299,7 @@
if ($n > 0) $query .= " and ";
$query .= $where[$n];
}
+ $query .= " order by $order_by limit $offset,$limit";
return get_data($query, "row_to_elggmetadata");
}
@@ -310,9 +315,9 @@
* @param int $offset
* @return mixed Array of objects or false.
*/
- function get_objects_from_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0)
+ function get_objects_from_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $object_subtype = "", $order_by = "created desc", $limit = 10, $offset = 0)
{
- $results = get_metadatas($object_id, $object_type, $name, $value, $value_type, $owner_id, $order_by, $limit, $offset);
+ $results = get_metadatas($object_id, $object_type, $name, $value, $value_type, $owner_id, $object_subtype, $order_by, $limit, $offset);
$objects = false;
if ($results)