From 8774089005501a6429eb9a99a73de504598a24c3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 21:22:05 -0800 Subject: preparatory work for site ratings --- mod/ratingsearch.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'mod/ratingsearch.php') diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index ec2db570b..b95b4367e 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -32,12 +32,19 @@ function ratingsearch_init(&$a) { dbesc($hash . '%') ); + if(! $p) { + $p = q("select * from site where site_url like '%s' ", + dbesc('%' . $hash) + ); + + if(! $p) { + $ret['message'] = 'channel not found'; + json_return_and_die($ret); + } + } + if($p) $ret['target'] = $p[0]; - else { - $ret['message'] = 'channel not found'; - json_return_and_die($ret); - } $ret['success'] = true; -- cgit v1.2.3 From 1c4b9199809581504ee66212f3bb434fd9773aff Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Feb 2015 23:45:22 -0800 Subject: force site_url to be lowercase when stored. Otherwise rating hubs on postgres could get real messy. --- mod/ratingsearch.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'mod/ratingsearch.php') diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index b95b4367e..9c4f2f827 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -32,13 +32,17 @@ function ratingsearch_init(&$a) { dbesc($hash . '%') ); - if(! $p) { + if($p) + $target = $p[0]['xchan_hash']; + else { $p = q("select * from site where site_url like '%s' ", dbesc('%' . $hash) ); - - if(! $p) { - $ret['message'] = 'channel not found'; + if($p) { + $target = strtolower($hash); + } + else { + $ret['message'] = 'Rating target not found'; json_return_and_die($ret); } } @@ -50,7 +54,7 @@ function ratingsearch_init(&$a) { $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 order by xchan_name asc", - dbesc($p[0]['xchan_hash']) + dbesc($target) ); if($r) { -- cgit v1.2.3