aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-10 12:09:19 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-10 12:09:19 +0000
commitdab73343aa7e5b6a46d9094bf5b39522e769392f (patch)
treed7ad3d6a76966d9c4ab87a0a830599a749f971f7 /engine
parent2e54eedc16240ddab2efec91e38de73f97e59710 (diff)
downloadelgg-dab73343aa7e5b6a46d9094bf5b39522e769392f.tar.gz
elgg-dab73343aa7e5b6a46d9094bf5b39522e769392f.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Site objects git-svn-id: https://code.elgg.org/elgg/trunk@131 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/sites.php40
1 files changed, 33 insertions, 7 deletions
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index db234c151..e8c17b34c 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -271,7 +271,9 @@
*/
function get_sites($user_id = 0, $type = "", $metadata_name = "", $metadata_value = "", $order_by = "created desc", $limit = 10, $offset = 0)
{
- return get_objects_from_metadatas(0, 'site', $metadata_name, $metadata_value, $user_id, $order_by, $limit, $offset);
+ // I'm not sure what this is meant to do, or how its useful.
+
+ //return get_objects_from_metadatas(0, 'site', $metadata_name, $metadata_value, $user_id, $order_by, $limit, $offset);
}
/**
@@ -333,8 +335,21 @@
*/
function get_site_objects($site_id, $type = "", $limit = 10, $offset = 0)
{
- // TODO : Writeme
- throw new NotImplementedException("Writeme!");
+ global $CONFIG;
+
+ $site_id = (int)$site_id;
+ $type = sanitise_string($type);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ $owner_id = (int)$owner_id; if ($owner_id==0) $owner_id = $_SESSION['id'];
+
+ $access = get_access_list();
+ $type = get_data_row("SELECT * from {$CONFIG->dbprefix}object_types where name='$type'");
+
+ if (!$type)
+ return false;
+
+ return get_data("SELECT * from {$CONFIG->dbprefix}objects where site_id=$site_id and type_id={$type->id} and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))","row_to_elggobject");
}
/**
@@ -359,8 +374,15 @@
*/
function add_site_user($site_id, $user_id)
{
- // TODO : Writeme
- throw new NotImplementedException("Writeme!");
+ global $CONFIG;
+
+ $site = get_site($site_id);
+ $user = get_user($user_id);
+
+ if (($site) && ($user))
+ return insert_data("INSERT into {$CONFIG->dbprefix}users_sites (site_id, user_id) VALUES ({$site->id},{$user->id})");
+
+ return false;
}
/**
@@ -371,8 +393,12 @@
*/
function remove_site_user($site_id, $user_id)
{
- // TODO : Writeme
- throw new NotImplementedException("Writeme!");
+ global $CONFIG;
+
+ $site_id = (int)$site_id;
+ $user_id = (int)$user_id;
+
+ return delete_data("DELETE from {$CONFIG->dbprefix}users_sites where site_id=$site_id and user_id=$user_id");
}
/**