aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 10:47:54 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 10:47:54 +0000
commit4e08ff9149c717f18ee7285b0508e8a1fc50503b (patch)
treefa269e3172c4acdb19b16352e98f0ff4d77a83d1
parentb84f744cfdbeb1f7bc42ed254747318d892beddc (diff)
downloadelgg-4e08ff9149c717f18ee7285b0508e8a1fc50503b.tar.gz
elgg-4e08ff9149c717f18ee7285b0508e8a1fc50503b.tar.bz2
The friends pages now use listing functions; also fixed a minor bug in the get_entities_from_relationship function.
git-svn-id: https://code.elgg.org/elgg/trunk@990 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/relationships.php11
-rw-r--r--friends/index.php18
-rw-r--r--friends/of.php18
3 files changed, 12 insertions, 35 deletions
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index f715f4a58..b71f075e5 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -427,7 +427,7 @@
* @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
* @return array|int|false An array of entities, or the number of entities, or false on failure
*/
- function get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false, $site_guid = 0)
+ function get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0)
{
global $CONFIG;
@@ -436,7 +436,8 @@
$inverse_relationship = (bool)$inverse_relationship;
$type = sanitise_string($type);
$subtype = get_subtype_id($type, $subtype);
- $owner_guid = (int)$owner_guid;
+ $owner_guid = (int)$owner_guid;
+ if ($order_by == "") $order_by = "time_created desc";
$order_by = sanitise_string($order_by);
$limit = (int)$limit;
$offset = (int)$offset;
@@ -501,13 +502,13 @@
* @param int $limit The number of entities to display on a page
* @return string The viewable list of entities
*/
- function list_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $limit = 0) {
+ function list_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $limit = 10) {
$limit = (int) $limit;
$offset = (int) get_input('offset');
$count = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, 0, true);
- $entities = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, 0, true);
-
+ $entities = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, 0);
+
return elgg_view_entity_list($entities, $count, $offset, $Limit);
}
diff --git a/friends/index.php b/friends/index.php
index 6629a2fc6..8b5e17ef0 100644
--- a/friends/index.php
+++ b/friends/index.php
@@ -13,24 +13,12 @@
if (!$owner = page_owner_entity()) {
gatekeeper();
+ set_page_owner($_SESSION['user']->getGUID());
$owner = $_SESSION['user'];
}
- $offset = (int) get_input('offset');
-
- if ($friends = $owner->getFriends("",50,$offset)) {
-
- $body = elgg_view("friends/list",array('friends' => $friends));
-
- } else {
-
- if (page_owner() != $_SESSION['guid']) {
- $body = elgg_echo("friends:none");
- } else {
- $body = elgg_echo("friends:none:you");
- }
-
- }
+ $area1 = list_entities_from_relationship('friend',$owner->getGUID(),false,'user','');
+ $body = elgg_view_layout('one_column',$area1);
echo page_draw(sprintf(elgg_echo("friends:owned"),$owner->name),$body);
diff --git a/friends/of.php b/friends/of.php
index 7886c6c14..68aa47778 100644
--- a/friends/of.php
+++ b/friends/of.php
@@ -13,24 +13,12 @@
if (!$owner = page_owner_entity()) {
gatekeeper();
+ set_page_owner($_SESSION['user']->getGUID());
$owner = $_SESSION['user'];
}
- $offset = (int) get_input('offset');
-
- if ($friends = $owner->getFriendsOf("",50,$offset)) {
-
- $body = elgg_view("friends/list",array('friends' => $friends));
-
- } else {
-
- if (page_owner() != $_SESSION['guid']) {
- $body = elgg_echo("friends:of:none");
- } else {
- $body = elgg_echo("friends:of:none:you");
- }
-
- }
+ $area1 = list_entities_from_relationship('friend',$owner->getGUID(),true,'user','');
+ $body = elgg_view_layout('one_column',$area1);
echo page_draw(sprintf(elgg_echo("friends:of:owned"),$owner->name),$body);