aboutsummaryrefslogtreecommitdiffstats
path: root/mod/ratings.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-02-03 15:06:16 -0800
committerfriendica <info@friendica.com>2015-02-03 15:06:16 -0800
commitdf632c423252a19b41d3502412135309063b85fa (patch)
tree29bab49ddb2cdb26af128e97922d7b86c30c0826 /mod/ratings.php
parent448af7458f096be07fc5173e234c7e6d2d20a50a (diff)
downloadvolse-hubzilla-df632c423252a19b41d3502412135309063b85fa.tar.gz
volse-hubzilla-df632c423252a19b41d3502412135309063b85fa.tar.bz2
volse-hubzilla-df632c423252a19b41d3502412135309063b85fa.zip
run ratingsearch on the server
Diffstat (limited to 'mod/ratings.php')
-rw-r--r--mod/ratings.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/mod/ratings.php b/mod/ratings.php
new file mode 100644
index 000000000..fe7cca6e1
--- /dev/null
+++ b/mod/ratings.php
@@ -0,0 +1,78 @@
+<?php
+
+require_once('include/dir_fns.php');
+
+function ratings_init(&$a) {
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ $x = find_upstream_directory($dirmode);
+ if($x)
+ $url = $x['url'];
+
+ $poco_rating = get_config('system','poco_rating_enable');
+ // if unset default to enabled
+ if($poco_rating === false)
+ $poco_rating = true;
+
+ if(! $poco_rating)
+ return;
+
+ if(argc() > 1)
+ $hash = argv(1);
+
+ if(! $hash) {
+ notice('Must supply a channel identififier.');
+ return;
+ }
+
+ $results = false;
+
+ $x = z_fetch_url($url . '/ratingsearch/' . $hash);
+
+
+ if($x['success'])
+ $results = json_decode($x['body'],true);
+
+
+ if((! $results) || (! $results['success'])) {
+
+ notice('No results.');
+ return;
+ }
+
+ $a->poi = $results['target'];
+ $a->data = $results['ratings'];
+
+ if(! $a->data) {
+ notice( t('No ratings') . EOL);
+ }
+
+ return;
+}
+
+
+
+
+
+function ratings_content(&$a) {
+
+ $poco_rating = get_config('system','poco_rating_enable');
+ // if unset default to enabled
+ if($poco_rating === false)
+ $poco_rating = true;
+
+ if(! $poco_rating)
+ return;
+
+ $o = replace_macros(get_markup_template('prep.tpl'),array(
+ '$header' => t('Ratings'),
+ '$rating_lbl' => t('Rating: ' ),
+ '$rating_text_lbl' => t('Description: '),
+ '$raters' => $a->data
+ ));
+
+ return $o;
+}
+
+ \ No newline at end of file