From 2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 18 Apr 2016 20:38:38 -0700 Subject: module updates --- Zotlabs/Module/Ratings.php | 115 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Zotlabs/Module/Ratings.php (limited to 'Zotlabs/Module/Ratings.php') diff --git a/Zotlabs/Module/Ratings.php b/Zotlabs/Module/Ratings.php new file mode 100644 index 000000000..802bbfec2 --- /dev/null +++ b/Zotlabs/Module/Ratings.php @@ -0,0 +1,115 @@ + 1) + $hash = argv(1); + + if(! $hash) { + notice('Must supply a channel identififier.'); + return; + } + + $results = false; + + $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash)); + + + if($x['success']) + $results = json_decode($x['body'],true); + + + if((! $results) || (! $results['success'])) { + + notice('No results.'); + return; + } + + if(array_key_exists('xchan_hash',$results['target'])) + \App::$poi = $results['target']; + + $friends = array(); + $others = array(); + + if($results['ratings']) { + foreach($results['ratings'] as $n) { + if(is_array(\App::$contacts) && array_key_exists($n['xchan_hash'],\App::$contacts)) + $friends[] = $n; + else + $others[] = $n; + } + } + + \App::$data = array('target' => $results['target'], 'results' => array_merge($friends,$others)); + + if(! \App::$data['results']) { + notice( t('No ratings') . EOL); + } + + return; + } + + + + + + function get() { + + 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; + + $site_target = ((array_key_exists('target',\App::$data) && array_key_exists('site_url',\App::$data['target'])) ? + '' . \App::$data['target']['site_url'] . '' : ''); + + + $o = replace_macros(get_markup_template('prep.tpl'),array( + '$header' => t('Ratings'), + '$rating_lbl' => t('Rating: ' ), + '$website' => t('Website: '), + '$site' => $site_target, + '$rating_text_lbl' => t('Description: '), + '$raters' => \App::$data['results'] + )); + + return $o; + } + + +} -- cgit v1.2.3