From 398894851628ccb99090e9d70b92a9a909ef7015 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 15:48:39 -0800 Subject: first cut at rating widget. The flaw is that it is limited because it requires local_channel() (formerly local_user()). We need to extend this to take you home like rpost does if you're logged in as remote_channel() - and/or we need zot to send the rating message to the source channel and target in addition to the directories. --- include/widgets.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 523318850..71407ad3d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -903,3 +903,30 @@ function widget_random_block($arr) { return $o; } + + +function widget_rating($arr) { + $a = get_app(); + if(! local_channel()) + return; + + $channel = $a->get_channel(); + + if($arr['target']) + $hash = $arr['target']; + else + $hash = $a->poi['xchan_hash']; + + if(! $hash) + return; + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + $o = '
'; + $o .= '
'; + return $o; + +} \ No newline at end of file -- cgit v1.2.3 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/widgets.php | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'include/widgets.php') 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 From 24b198a50c54736ad137a342c30814033b27eff7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:34:53 -0800 Subject: honour the rating enable setting (which we really do need to rename since it isn't poco any more) --- include/widgets.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 7d2aaeb99..5eda9008b 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -908,6 +908,11 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); + $poco_rating = get_config('system','poco_rating_enable'); + if((! $poco_rating) && ($poco_rating !== false)) { + return; + } + if($arr['target']) $hash = $arr['target']; else -- cgit v1.2.3 From 6e84dbe493a660b391c519c331aaa79878adf933 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:18:04 -0800 Subject: add 'view ratings' to the widget. It's actually two stacked widgets rather than a widget with two entries. That's the only way we can keep the theming consistent with the rconnect button. --- include/widgets.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index 5eda9008b..a94bf03dc 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -951,9 +951,13 @@ function widget_rating($arr) { $o = '
'; if($remote) - $o .= ' ' . t('Rate Me') . '
'; + $o .= ' ' . t('Rate Me') . ''; else - $o .= ''; + $o .= ''; + + $o .= ''; + return $o; } \ No newline at end of file -- cgit v1.2.3 From 24355430a8ca8420aa0c1d42e9c38932d1cd54f7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:26:59 -0800 Subject: allow anybody to view ratings - including oneself. Only allow authenticated folks to edit them. --- include/widgets.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index a94bf03dc..e995b213f 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -946,16 +946,16 @@ function widget_rating($arr) { } - if((! $remote) && (! local_channel())) - return; - - $o = '
'; - if($remote) - $o .= ' ' . t('Rate Me') . ''; - else - $o .= ''; + if(($remote) || (local_channel())) { + $o = '
'; + if($remote) + $o .= ' ' . t('Rate Me') . ''; + else + $o .= ''; + $o .= '
'; + } - $o .= '
' . t('View Ratings') . ''; + $o .= ''; return $o; -- cgit v1.2.3 From 5a0ccbfcf375acad49a0f7e818fe5611c2f858cc Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:31:12 -0800 Subject: forgot to add the self exclusion --- include/widgets.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/widgets.php') diff --git a/include/widgets.php b/include/widgets.php index e995b213f..d457db07d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -936,17 +936,19 @@ function widget_rating($arr) { } } + $self = false; + if(local_channel()) { $channel = $a->get_channel(); if($hash == $channel['channel_hash']) - return; + $self = true; head_add_js('ratings.js'); } - if(($remote) || (local_channel())) { + if((($remote) || (local_channel())) && (! $self)) { $o = '
'; if($remote) $o .= ' ' . t('Rate Me') . ''; -- cgit v1.2.3