From 561bab4ece9fa5844a0cb00f3cbd75e0855b2796 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:32:29 -0800 Subject: remote rating and addition of rate-me to channel profile sidebar --- include/identity.php | 6 ++---- include/widgets.php | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index aef6471e5..415e85f2f 100644 --- a/include/identity.php +++ b/include/identity.php @@ -943,10 +943,8 @@ logger('online: ' . $profile['online']); $tpl = get_markup_template('profile_vcard.tpl'); -// This isn't ideal here because it requires local_channel(). -// We need the rating widget to recognise and take you home if you're remote. -// require_once('include/widgets.php'); -// $z = widget_rating(array('target' => $profile['channel_hash'])); + require_once('include/widgets.php'); + $z = widget_rating(array('target' => $profile['channel_hash'])); $o .= replace_macros($tpl, array( '$profile' => $profile, diff --git a/include/widgets.php b/include/widgets.php index 71407ad3d..7d2aaeb99 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -907,10 +907,6 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); - if(! local_channel()) - return; - - $channel = $a->get_channel(); if($arr['target']) $hash = $arr['target']; @@ -920,13 +916,39 @@ function widget_rating($arr) { if(! $hash) return; - if($hash == $channel['channel_hash']) - return; + $url = ''; + $remote = false; + + if(remote_channel() && ! local_channel()) { + $ob = $a->get_observer(); + if($ob && $ob['xchan_url']) { + $p = parse_url($ob['xchan_url']); + if($p) { + $url = $p['scheme'] . '://' . $p['host'] . (($p['port']) ? ':' . $p['port'] : ''); + $url .= '/rate?f=&target=' . urlencode($hash); + } + $remote = true; + } + } - head_add_js('ratings.js'); + if(local_channel()) { + $channel = $a->get_channel(); + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + } + + if((! $remote) && (! local_channel())) + return; $o = '
'; - $o .= '
'; + if($remote) + $o .= ' ' . t('Rate Me') . ''; + else + $o .= ''; return $o; } \ No newline at end of file -- cgit v1.2.3