From e12f6f1bd93bb42bf0fe9fc9d9a1ff08cd162a0d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Feb 2014 17:20:24 -0800 Subject: small changes to a couple of lookup functions which we need to use a bit more --- boot.php | 1 + include/Contact.php | 9 ++++++--- include/widgets.php | 2 +- mod/photos.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index e7f583b44..fb029c44e 100755 --- a/boot.php +++ b/boot.php @@ -40,6 +40,7 @@ require_once('include/BaseObject.php'); require_once('include/features.php'); require_once('include/taxonomy.php'); require_once('include/identity.php'); +require_once('include/Contact.php'); define ( 'RED_PLATFORM', 'Red Matrix' ); diff --git a/include/Contact.php b/include/Contact.php index 09f7925cb..9883c598d 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -52,24 +52,27 @@ function abook_self($channel_id) { } function channelx_by_nick($nick) { - return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and not ( channel_pageflags & %d ) LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and not ( channel_pageflags & %d ) LIMIT 1", dbesc($nick), intval(PAGE_REMOVED) ); + return(($r) ? $r[0] : false); } function channelx_by_hash($hash) { - return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and not ( channel_pageflags & %d ) LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and not ( channel_pageflags & %d ) LIMIT 1", dbesc($hash), intval(PAGE_REMOVED) ); + return(($r) ? $r[0] : false); } function channelx_by_n($id) { - return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and not ( channel_pageflags & %d ) LIMIT 1", + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and not ( channel_pageflags & %d ) LIMIT 1", dbesc($id), intval(PAGE_REMOVED) ); + return(($r) ? $r[0] : false); } diff --git a/include/widgets.php b/include/widgets.php index 3c2333323..4a5ae9de7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -543,7 +543,7 @@ function widget_photo_albums($arr) { $channelx = channelx_by_n($a->profile['profile_uid']); if((! $channelx) || (! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_photos'))) return ''; - return photos_album_widget($channelx[0],$a->get_observer()); + return photos_album_widget($channelx,$a->get_observer()); } diff --git a/mod/photos.php b/mod/photos.php index 2fe2d8a74..e2279188a 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -27,7 +27,7 @@ function photos_init(&$a) { if(! $channelx) return; - $a->data['channel'] = $channelx[0]; + $a->data['channel'] = $channelx; $observer = $a->get_observer(); $a->data['observer'] = $observer; -- cgit v1.2.3