diff options
author | friendica <info@friendica.com> | 2015-02-05 19:38:43 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-02-05 19:38:43 -0800 |
commit | 4b348d248975ba07ba9cea62f51eb52d6afb5645 (patch) | |
tree | fc60c2d05958c2a458ac72b03e1e7ddffce0c41b /mod/ratings.php | |
parent | aafed50a0ea8a8d7091572473dcb8e4fb8cd4602 (diff) | |
parent | b948fbaeda84f4358722222b4a2d5555ef10b82e (diff) | |
download | volse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.tar.gz volse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.tar.bz2 volse-hubzilla-4b348d248975ba07ba9cea62f51eb52d6afb5645.zip |
Merge branch 'master' into tres
Conflicts:
view/css/mod_events.css
view/theme/redbasic/css/style.css
Diffstat (limited to 'mod/ratings.php')
-rw-r--r-- | mod/ratings.php | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/mod/ratings.php b/mod/ratings.php new file mode 100644 index 000000000..fe7865778 --- /dev/null +++ b/mod/ratings.php @@ -0,0 +1,103 @@ +<?php + +require_once('include/dir_fns.php'); + +function ratings_init(&$a) { + + if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + return; + } + + if(local_channel()) + load_contact_links(local_channel()); + + $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']; + + $friends = array(); + $others = array(); + + if($results['ratings']) { + foreach($results['ratings'] as $n) { + if(is_array($a->contacts) && array_key_exists($n['xchan_hash'],$a->contacts)) + $friends[] = $n; + else + $others[] = $n; + } + } + + $a->data = array_merge($friends,$others); + + if(! $a->data) { + notice( t('No ratings') . EOL); + } + + return; +} + + + + + +function ratings_content(&$a) { + + if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { + notice( t('Public access denied.') . EOL); + return; + } + + $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 |