diff options
Diffstat (limited to 'include/conversation.php')
-rw-r--r-- | include/conversation.php | 261 |
1 files changed, 203 insertions, 58 deletions
diff --git a/include/conversation.php b/include/conversation.php index c260eb4a0..0ff368e6e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -363,7 +363,7 @@ function localize_item(&$item){ if(intval($item['item_obscured']) && strlen($item['body']) && (! strpos($item['body'],'data'))) { - $item['body'] = json_encode(crypto_encapsulate($item['body'],get_config('system','pubkey'))); + $item['body'] = z_obscure($item['body']); } } @@ -473,22 +473,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ if (local_channel()) load_pconfig(local_channel(),''); - $arr_blocked = null; - - if (local_channel()) - $str_blocked = get_pconfig(local_channel(),'system','blocked'); - if (! local_channel() && ($mode == 'network')) { - $sys = get_sys_channel(); - $id = $sys['channel_id']; - $str_blocked = get_pconfig($id,'system','blocked'); - } - - if ($str_blocked) { - $arr_blocked = explode(',',$str_blocked); - for ($x = 0; $x < count($arr_blocked); $x ++) - $arr_blocked[$x] = trim($arr_blocked[$x]); - } - $profile_owner = 0; $page_writeable = false; $live_update_div = ''; @@ -615,17 +599,13 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ foreach($items as $item) { - if($arr_blocked) { - $blocked = false; - foreach($arr_blocked as $b) { - if(($b) && (($item['author_xchan'] == $b) || ($item['owner_xchan'] == $b))) { - $blocked = true; - break; - } - } - if($blocked) - continue; - } + $x = [ 'mode' => $mode, 'item' => $item ]; + call_hooks('stream_item',$x); + + if($x['item']['blocked']) + continue; + + $item = $x['item']; $threadsid++; @@ -709,7 +689,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'id' => (($preview) ? 'P0' : $item['item_id']), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url), 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), + 'thread_action_menu' => thread_action_menu($item,$mode), + 'thread_author_menu' => thread_author_menu($item,$mode), 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, @@ -787,28 +768,14 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ // Check for any blocked authors - if($arr_blocked) { - $blocked = false; - foreach($arr_blocked as $b) { - if(($b) && ($item['author_xchan'] == $b)) { - $blocked = true; - break; - } - } - if($blocked) - continue; - } - // Check all the kids too + $x = [ 'mode' => $mode, 'item' => $item ]; + call_hooks('stream_item',$x); + + if($x['item']['blocked']) + continue; - if($arr_blocked && $item['children']) { - for($d = 0; $d < count($item['children']); $d ++) { - foreach($arr_blocked as $b) { - if(($b) && ($item['children'][$d]['author_xchan'] == $b)) - $item['children'][$d]['author_blocked'] = true; - } - } - } + $item = $x['item']; builtin_activity_puller($item, $conv_responses); @@ -994,6 +961,169 @@ function item_photo_menu($item){ return $o; } + +function thread_action_menu($item,$mode = '') { + + $menu = []; + + if((local_channel()) && local_channel() == $item['uid']) { + $menu[] = [ + 'menu' => 'view_source', + 'title' => t('View Source'), + 'icon' => 'eye', + 'action' => 'viewsrc(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + + if(! in_array($mode, [ 'network-new', 'search', 'community'])) { + if($item['parent'] == $item['id'] && (get_observer_hash() != $item['author_xchan'])) { + $menu[] = [ + 'menu' => 'follow_thread', + 'title' => t('Follow Thread'), + 'icon' => 'plus', + 'action' => 'dosubthread(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + } + + $menu[] = [ + 'menu' => 'unfollow_thread', + 'title' => t('Unfollow Thread'), + 'icon' => 'minus', + 'action' => 'dounsubthread(' . $item['id'] . '); return false;', + 'href' => '#' + ]; + } + + } + + + + + $args = [ 'item' => $item, 'mode' => $mode, 'menu' => $menu ]; + call_hooks('thread_action_menu', $args); + + return $args['menu']; + +} + +function thread_author_menu($item, $mode = '') { + + $menu = []; + + $local_channel = local_channel(); + + if($local_channel) { + if(! count(App::$contacts)) + load_contact_links($local_channel); + $channel = App::get_channel(); + $channel_hash = (($channel) ? $channel['channel_hash'] : ''); + } + + $profile_link = chanlink_hash($item['author_xchan']); + if($item['uid'] > 0) + $pm_url = z_root() . '/mail/new/?f=&hash=' . $item['author_xchan']; + + if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) + $contact = App::$contacts[$item['author_xchan']]; + else + if($local_channel && $item['author']['xchan_addr']) + $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr']; + + if($contact) { + $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id']; + if (! intval($contact['abook_self'])) + $contact_url = z_root() . '/connedit/' . $contact['abook_id']; + $posts_link = z_root() . '/network/?cid=' . $contact['abook_id']; + + $clean_url = normalise_link($item['author-link']); + } + + $rating_enabled = get_config('system','rating_enabled'); + + $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : ''); + + if($profile_link) { + $menu[] = [ + 'menu' => 'view_profile', + 'title' => t('View Profile'), + 'icon' => 'fw', + 'action' => '', + 'href' => $profile_link + ]; + } + + if($posts_link) { + $menu[] = [ + 'menu' => 'view_posts', + 'title' => t('Activity/Posts'), + 'icon' => 'fw', + 'action' => '', + 'href' => $posts_link + ]; + } + + if($follow_url) { + $menu[] = [ + 'menu' => 'follow', + 'title' => t('Connect'), + 'icon' => 'fw', + 'action' => '', + 'href' => $follow_url + ]; + } + + if($contact_url) { + $menu[] = [ + 'menu' => 'connedit', + 'title' => t('Edit Connection'), + 'icon' => 'fw', + 'action' => '', + 'href' => $contact_url + ]; + } + + if($pm_url) { + $menu[] = [ + 'menu' => 'prv_message', + 'title' => t('Message'), + 'icon' => 'fw', + 'action' => '', + 'href' => $pm_url + ]; + } + + if($ratings_url) { + $menu[] = [ + 'menu' => 'ratings', + 'title' => t('Ratings'), + 'icon' => 'fw', + 'action' => '', + 'href' => $ratings_url + ]; + } + + if($poke_link) { + $menu[] = [ + 'menu' => 'poke', + 'title' => t('Poke'), + 'icon' => 'fw', + 'action' => '', + 'href' => $poke_link + ]; + } + + $args = [ 'item' => $item, 'mode' => $mode, 'menu' => $menu ]; + call_hooks('thread_author_menu', $args); + + return $args['menu']; + +} + + + + + /** * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.) * @@ -1266,11 +1396,11 @@ function status_editor($a, $x, $popup = false) { '$setloc' => $setloc, '$voting' => t('Toggle voting'), '$feature_voting' => $feature_voting, - '$consensus' => 0, + '$consensus' => ((array_key_exists('item',$x)) ? $x['item']['item_consensus'] : 0), '$nocommenttitle' => t('Disable comments'), '$nocommenttitlesub' => t('Toggle comments'), '$feature_nocomment' => $feature_nocomment, - '$nocomment' => 0, + '$nocomment' => ((array_key_exists('item',$x)) ? $x['item']['item_nocomment'] : 0), '$clearloc' => $clearloc, '$title' => ((x($x, 'title')) ? htmlspecialchars($x['title'], ENT_COMPAT,'UTF-8') : ''), '$placeholdertitle' => ((x($x, 'placeholdertitle')) ? $x['placeholdertitle'] : t('Title (optional)')), @@ -1434,7 +1564,7 @@ function format_location($item) { if(strpos($item['location'],'#') === 0) { $location = substr($item['location'],1); - $location = ((strpos($location,'[') !== false) ? bbcode($location) : $location); + $location = ((strpos($location,'[') !== false) ? zidify_links(bbcode($location)) : $location); } else { $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); @@ -1486,7 +1616,7 @@ function prepare_page($item) { '$author' => (($naked) ? '' : $item['author']['xchan_name']), '$auth_url' => (($naked) ? '' : zid($item['author']['xchan_url'])), '$date' => (($naked) ? '' : datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'Y-m-d H:i')), - '$title' => smilies(bbcode($item['title'])), + '$title' => zidify_links(smilies(bbcode($item['title']))), '$body' => $body['html'], '$preview' => $preview, '$link' => $link, @@ -1656,6 +1786,20 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ $cal_link = '/cal/' . $nickname; } + require_once('include/security.php'); + $sql_options = item_permissions_sql($uid); + + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' + and item.item_delayed = 0 and item.item_deleted = 0 + and ( iconfig.k = 'WEBPAGE' and item_type = %d ) + $sql_options limit 1", + intval($uid), + dbesc('home'), + intval(ITEM_TYPE_WEBPAGE) + ); + + $has_webpages = (($r) ? true : false); if (get_pconfig($uid, 'system', 'noprofiletabs')) return; @@ -1740,19 +1884,20 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ ); } - if ($p['write_pages'] && feature_enabled($uid,'webpages')) { + if($has_webpages && feature_enabled($uid,'webpages')) { $tabs[] = array( 'label' => t('Webpages'), - 'url' => z_root() . '/webpages/' . $nickname, + 'url' => z_root() . '/page/' . $nickname . '/home', 'sel' => ((argv(0) == 'webpages') ? 'active' : ''), - 'title' => t('Manage Webpages'), + 'title' => t('View Webpages'), 'id' => 'webpages-tab', ); - } + } + if(feature_enabled($uid,'wiki') && (get_account_techlevel($account_id) > 3)) { $tabs[] = array( - 'label' => t('Wiki'), + 'label' => t('Wikis'), 'url' => z_root() . '/wiki/' . $nickname, 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), 'title' => t('Wiki'), |