aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 12:34:24 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 12:34:24 +0000
commit9e1593a5bf6604a4e22023f3c465f8f571b7feb2 (patch)
treeb5a4b4b9027e57f6b661c77389c065dcfe0c3052 /engine/lib
parent26bf6e77aa959edce641ff1bc32475f0e76a950d (diff)
downloadelgg-9e1593a5bf6604a4e22023f3c465f8f571b7feb2.tar.gz
elgg-9e1593a5bf6604a4e22023f3c465f8f571b7feb2.tar.bz2
Objects are now cast to ElggObjects on get
git-svn-id: https://code.elgg.org/elgg/trunk@94 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/objects.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 1541c8dd5..62039ff38 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -13,6 +13,21 @@
*/
/**
+ * Converts a standard database row result to an ElggObject
+ *
+ * @param object $row The database row object
+ * @return ElggObject The formatted ElggObject
+ */
+ function row_to_elggobject($row) {
+ if (empty($row))
+ return $row;
+ $object = new ElggObject();
+ foreach(get_object_vars($row) as $property => $value)
+ $object->$property = $value;
+ return $object;
+ }
+
+ /**
* Get object reverse ordered by publish time, optionally filtered by user and/or type
*
* @param int $user_id The ID of the publishing user; set to 0 for all users
@@ -56,7 +71,7 @@
$query .= " order by o.time_created desc ";
if ($limit > 0 || $offset > 0) $query .= " limit {$offset}, {$limit}";
- return get_data($query);
+ return get_data($query,"row_to_elggobject");
}
@@ -73,7 +88,8 @@
$object_id = (int) $object_id;
$access = get_access_list();
- return get_data_row("select o.*, ot.name as typename from {$CONFIG->dbprefix}objects left join {$CONFIG->dbprefix}object_types ot on ot.id = o.type_id where (o.access_id in {$access} or (o.access_id = 0 and o.owner_id = {$_SESSION['id']}))");
+ $row = get_data_row("select o.*, ot.name as typename from {$CONFIG->dbprefix}objects left join {$CONFIG->dbprefix}object_types ot on ot.id = o.type_id where (o.access_id in {$access} or (o.access_id = 0 and o.owner_id = {$_SESSION['id']}))");
+ return row_to_elggobject($row);
}
@@ -150,7 +166,7 @@
* @param int $site_id The site the object belongs to
* @return int|false Either 1 or 0 (the number of objects updated) or false on failure
*/
-
+
function update_object($id, $title = null, $description = null, $type = null, $owner_id = null, $access_id = null, $site_id = null) {
global $CONFIG;