diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acl.php | 7 | ||||
-rwxr-xr-x | mod/events.php | 31 | ||||
-rw-r--r-- | mod/home.php | 14 | ||||
-rw-r--r-- | mod/item.php | 2 | ||||
-rw-r--r-- | mod/photos.php | 8 | ||||
-rw-r--r-- | mod/post.php | 2 | ||||
-rw-r--r-- | mod/pubsites.php | 7 | ||||
-rw-r--r-- | mod/rate.php | 24 | ||||
-rw-r--r-- | mod/ratings.php | 19 | ||||
-rw-r--r-- | mod/ratingsearch.php | 19 |
10 files changed, 105 insertions, 28 deletions
diff --git a/mod/acl.php b/mod/acl.php index 6ae803596..e919bb912 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -99,6 +99,7 @@ function acl_init(&$a){ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED), intval(XCHAN_FLAGS_DELETED) ); + } else { // Visitors $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags @@ -148,12 +149,14 @@ function acl_init(&$a){ } } if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_channel(),'system','taganyone'))) { - if((! $r) && $type == 'c') { - $r = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags + if((count($r) < 100) && $type == 'c') { + $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags FROM xchan WHERE not (xchan_flags & %d )>0 $sql_extra2 order by $order_extra2 xchan_name asc" , intval(XCHAN_FLAGS_DELETED) ); + if($r2) + $r = array_merge($r,$r2); } } } diff --git a/mod/events.php b/mod/events.php index f209dab1d..010f1f7c4 100755 --- a/mod/events.php +++ b/mod/events.php @@ -273,6 +273,10 @@ function events_content(&$a) { $mode = 'add'; $item_id = intval(argv(2)); } + if(argc() > 2 && argv(1) === 'drop') { + $mode = 'drop'; + $event_id = argv(2); + } if(argv(1) === 'new') { $mode = 'new'; $event_id = ''; @@ -412,6 +416,8 @@ function events_content(&$a) { $last_date = $d; // FIXME $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null); + $drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); + $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); if(! $title) { list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); @@ -425,6 +431,7 @@ function events_content(&$a) { 'hash' => $rr['event_hash'], 'start'=> $start, 'end' => $end, + 'drop' => $drop, 'allDay' => false, 'title' => $title, @@ -479,6 +486,30 @@ function events_content(&$a) { } + if($mode === 'drop' && $event_id) { + $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", + dbesc($event_id), + intval(local_channel()) + ); + if($r) { + $r = q("delete from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event_id), + intval(local_channel()) + ); + if($r) { + $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d", + dbesc($event_id), + intval(local_channel()) + ); + info( t('Event removed') . EOL); + } + else { + notice( t('Failed to remove event' ) . EOL); + } + goaway(z_root() . '/events'); + } + } + if($mode === 'edit' && $event_id) { $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), diff --git a/mod/home.php b/mod/home.php index db4ae9c42..6d5c7db25 100644 --- a/mod/home.php +++ b/mod/home.php @@ -164,9 +164,16 @@ function home_content(&$a, $update = 0, $load = false) { } require_once('include/identity.php'); - $sys = get_sys_channel(); - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; - $a->data['firehose'] = intval($sys['channel_id']); + + if(get_config('system','site_firehose')) { + require_once('include/security.php'); + $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 "; + } + else { + $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $a->data['firehose'] = intval($sys['channel_id']); + } $page_mode = 'list'; @@ -199,6 +206,7 @@ function home_content(&$a, $update = 0, $load = false) { intval(ABOOK_FLAG_BLOCKED) ); + } // Then fetch all the children of the parents that are on this page diff --git a/mod/item.php b/mod/item.php index eb823b4b0..dbee2df3b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -644,7 +644,7 @@ function item_post(&$a) { } } - $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); + $item_unseen = 1; if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; diff --git a/mod/photos.php b/mod/photos.php index 33854dd76..8ac6ed3d7 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -977,10 +977,10 @@ function photos_content(&$a) { if($r) { - foreach($r as $item) { - like_puller($a,$item,$alike,'like'); - like_puller($a,$item,$dlike,'dislike'); - } +// foreach($r as $item) { +// like_puller($a,$item,$alike,'like'); +// like_puller($a,$item,$dlike,'dislike'); +// } $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : ''); $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : ''); diff --git a/mod/post.php b/mod/post.php index c90997335..6e35632da 100644 --- a/mod/post.php +++ b/mod/post.php @@ -467,7 +467,7 @@ function post_post(&$a) { * tells us we need to unencapsulate the AES-256-CBC content using the site private key */ - if(array_key_exists('iv',$data)) { + if($data && array_key_exists('iv',$data)) { $encrypted_packet = true; $data = crypto_unencapsulate($data,get_config('system','prvkey')); logger('mod_zot: decrypt1: ' . $data, LOGGER_DATA); diff --git a/mod/pubsites.php b/mod/pubsites.php index c31bbcf97..ff3854492 100644 --- a/mod/pubsites.php +++ b/mod/pubsites.php @@ -22,10 +22,13 @@ function pubsites_content(&$a) { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= '<table border="1"><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Location') . '</td></tr>'; + $rate_meta = ((local_channel()) ? '<td>' . t('Rate this hub') . '</td>' : ''); + $o .= '<table border="1"><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Location') . '</td><td>' . t('View hub ratings') . '</td>' . $rate_meta . '</tr>'; if($j['sites']) { foreach($j['sites'] as $jj) { - $o .= '<tr><td>' . '<a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" >' . $jj['url'] . '</a>' . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . $jj['location'] . '</td></tr>'; + $host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3)); + $rate_links = ((local_channel()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="icon-check"></i> ' . t('Rate') . '</a></td>' : ''); + $o .= '<tr><td>' . '<a href="'. (($jj['sellpage']) ? $jj['sellpage'] : $jj['url'] . '/register' ) . '" >' . $jj['url'] . '</a>' . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . $jj['location'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="icon-eye-open"></i> ' . t('View ratings') . '</a></td>' . $rate_links . '</tr>'; } } diff --git a/mod/rate.php b/mod/rate.php index 694b88ddd..a3a36b4a9 100644 --- a/mod/rate.php +++ b/mod/rate.php @@ -21,6 +21,15 @@ function rate_init(&$a) { if($r) { $a->poi = $r[0]; } + else { + $r = q("select * from site where site_url like '%s' ", + dbesc('%' . $target) + ); + if($r) { + $a->data['site'] = $r[0]; + $a->data['site']['site_url'] = strtolower($r[0]['site_url']); + } + } } @@ -119,12 +128,15 @@ function rate_content(&$a) { dbesc($channel['channel_hash']), dbesc($a->data['target']) ); - if($r) + if($r) { $a->data['xlink'] = $r[0]; - - $rating_val = $r[0]['xlink_rating']; - $rating_text = $r[0]['xlink_rating_text']; - + $rating_val = $r[0]['xlink_rating']; + $rating_text = $r[0]['xlink_rating_text']; + } + else { + $rating_val = 0; + $rating_text = ''; + } // if unset default to enabled if($poco_rating === false) @@ -142,6 +154,8 @@ function rate_content(&$a) { $o = replace_macros(get_markup_template('rating_form.tpl'),array( '$header' => t('Rating'), + '$website' => t('Website:'), + '$site' => (($a->data['site']) ? '<a href="' . $a->data['site']['site_url'] . '" >' . $a->data['site']['site_url'] . '</a>' : ''), 'target' => $a->data['target'], '$tgt_name' => (($a->poi && $a->poi['xchan_name']) ? $a->poi['xchan_name'] : sprintf( t('Remote Channel [%s] (not yet known on this site)'), substr($a->data['target'],0,16))), '$lbl_rating' => t('Rating (this information is public)'), diff --git a/mod/ratings.php b/mod/ratings.php index fe7865778..dc98eb238 100644 --- a/mod/ratings.php +++ b/mod/ratings.php @@ -35,7 +35,7 @@ function ratings_init(&$a) { $results = false; - $x = z_fetch_url($url . '/ratingsearch/' . $hash); + $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash)); if($x['success']) @@ -48,8 +48,9 @@ function ratings_init(&$a) { return; } - $a->poi = $results['target']; - + if(array_key_exists('xchan_hash',$results['target'])) + $a->poi = $results['target']; + $friends = array(); $others = array(); @@ -62,9 +63,9 @@ function ratings_init(&$a) { } } - $a->data = array_merge($friends,$others); + $a->data = array('target' => $results['target'], 'results' => array_merge($friends,$others)); - if(! $a->data) { + if(! $a->data['results']) { notice( t('No ratings') . EOL); } @@ -90,11 +91,17 @@ function ratings_content(&$a) { if(! $poco_rating) return; + $site_target = ((array_key_exists('target',$a->data) && array_key_exists('site_url',$a->data['target'])) ? + '<a href="' . $a->data['target']['site_url'] . '" >' . $a->data['target']['site_url'] . '</a>' : ''); + + $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' => $a->data + '$raters' => $a->data['results'] )); return $o; diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index ec2db570b..9c4f2f827 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -33,17 +33,28 @@ function ratingsearch_init(&$a) { ); if($p) - $ret['target'] = $p[0]; + $target = $p[0]['xchan_hash']; else { - $ret['message'] = 'channel not found'; - json_return_and_die($ret); + $p = q("select * from site where site_url like '%s' ", + dbesc('%' . $hash) + ); + if($p) { + $target = strtolower($hash); + } + else { + $ret['message'] = 'Rating target not found'; + json_return_and_die($ret); + } } + if($p) + $ret['target'] = $p[0]; + $ret['success'] = true; $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 order by xchan_name asc", - dbesc($p[0]['xchan_hash']) + dbesc($target) ); if($r) { |