diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
commit | 47d55694a4c84b6c12c0db61a69bcac8b671b20e (patch) | |
tree | b15e96f4ea67e2214a66a9d28dafaf53d25b98ec /include/conversation.php | |
parent | 087f9784e3c5a860ed2b86e7f9e8e9f312038546 (diff) | |
parent | f0e615dee529e031663576286345141ad2996974 (diff) | |
download | volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.tar.gz volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.tar.bz2 volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.zip |
Merge branch '2.4RC'2.4
Diffstat (limited to 'include/conversation.php')
-rw-r--r-- | include/conversation.php | 209 |
1 files changed, 82 insertions, 127 deletions
diff --git a/include/conversation.php b/include/conversation.php index a1acc456a..0f940b1a3 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -2,10 +2,6 @@ require_once('include/items.php'); -// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images' -// is identical to the code in mod/message.php for 'item_extract_images' and -// 'item_redir_and_replace_images' - function item_extract_images($body) { @@ -375,13 +371,14 @@ function localize_item(&$item){ * * \e array \b children * @return number */ + function count_descendants($item) { $total = count($item['children']); - if ($total > 0) { - foreach ($item['children'] as $child) { - if (! visible_activity($child)) + if($total > 0) { + foreach($item['children'] as $child) { + if(! visible_activity($child)) $total --; $total += count_descendants($child); @@ -408,8 +405,8 @@ function visible_activity($item) { if(intval($item['item_notshown'])) return false; - foreach ($hidden_activities as $act) { - if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { + foreach($hidden_activities as $act) { + if((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { return false; } } @@ -614,6 +611,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $owner_photo = ''; $owner_name = ''; $sparkle = ''; + $is_new = false; if($mode === 'search' || $mode === 'community') { if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) @@ -682,6 +680,9 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false); + if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + $is_new = true; + $tmp_item = array( 'template' => $tpl, 'toplevel' => 'toplevel_item', @@ -738,6 +739,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'wait' => t('Please wait'), 'thread_level' => 1, 'has_tags' => $has_tags, + 'is_new' => $is_new ); $arr = array('item' => $item, 'output' => $tmp_item); @@ -870,98 +872,6 @@ function best_link_url($item) { -function item_photo_menu($item){ - - $contact = null; - - $ssl_state = false; - - $sub_link=""; - $poke_link=""; - $contact_url=""; - $pm_url=""; - $vsrc_link = ""; - $follow_url = ""; - - $local_channel = local_channel(); - - if($local_channel) { - $ssl_state = true; - if(! count(App::$contacts)) - load_contact_links($local_channel); - $channel = App::get_channel(); - $channel_hash = (($channel) ? $channel['channel_hash'] : ''); - } - - if(($local_channel) && $local_channel == $item['uid']) { - $vsrc_link = 'javascript:viewsrc(' . $item['id'] . '); return false;'; - if($item['parent'] == $item['id'] && $channel && ($channel_hash != $item['author_xchan'])) { - $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; - } - if($channel) { - $unsub_link = 'javascript:dounsubthread(' . $item['id'] . '); return false;'; - } - } - - $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']) : ''); - - $post_menu = Array( - t("View Source") => $vsrc_link, - t("Follow Thread") => $sub_link, - t("Unfollow Thread") => $unsub_link, - ); - - $author_menu = array( - t("View Profile") => $profile_link, - t("Activity/Posts") => $posts_link, - t("Connect") => $follow_url, - t("Edit Connection") => $contact_url, - t("Message") => $pm_url, - t('Ratings') => $ratings_url, - t("Poke") => $poke_link - ); - - - $args = array('item' => $item, 'post_menu' => $post_menu, 'author_menu' => $author_menu); - - call_hooks('item_photo_menu', $args); - - $menu = array_merge($args['post_menu'],$args['author_menu']); - - $o = ""; - foreach($menu as $k=>$v){ - if(strpos($v,'javascript:') === 0) { - $v = substr($v,11); - $o .= "<li><a href=\"#\" onclick=\"$v\">$k</a></li>\n"; - } - elseif ($v!="") $o .= "<li><a href=\"$v\">$k</a></li>\n"; - } - - return $o; -} - - function thread_action_menu($item,$mode = '') { $menu = []; @@ -1007,6 +917,24 @@ function thread_action_menu($item,$mode = '') { } +function author_is_pmable($xchan) { + + $x = [ 'xchan' => $xchan, 'result' => 'unset' ]; + call_hooks('author_is_pmable',$x); + if($x['result'] !== 'unset') + return $x['result']; + + if($xchan['xchan_network'] === 'zot') + return true; + return false; + +} + + + + + + function thread_author_menu($item, $mode = '') { $menu = []; @@ -1021,14 +949,19 @@ function thread_author_menu($item, $mode = '') { } $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']; + $follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']); + + + if($item['uid'] > 0 && author_is_pmable($item['author'])) + $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']); + + if($contact) { $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id']; @@ -1176,8 +1109,8 @@ function builtin_activity_puller($item, &$conv_responses) { if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) { $name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown')); $url = (($item['author_xchan'] && $item['author']['xchan_photo_s']) - ? '<a href="' . chanlink_hash($item['author_xchan']) . '">' . '<img class="dropdown-menu-img-xs" src="' . zid($item['author']['xchan_photo_s']) . '" alt="' . urlencode($name) . '" />' . $name . '</a>' - : '<a href="#" class="disabled">' . $name . '</a>' + ? '<a class="dropdown-item" href="' . chanlink_hash($item['author_xchan']) . '">' . '<img class="menu-img-1" src="' . zid($item['author']['xchan_photo_s']) . '" alt="' . urlencode($name) . '" />' . $name . '</a>' + : '<a class="dropdown-item" href="#" class="disabled">' . $name . '</a>' ); if(! $item['thr_parent']) @@ -1608,6 +1541,15 @@ function prepare_page($item) { // the template will get passed an unobscured title. $body = prepare_body($item, true); + if(App::$page['template'] == 'none') { + $tpl = 'page_display_empty.tpl'; + + return replace_macros(get_markup_template($tpl), array( + '$body' => $body['html'] + )); + + } + $tpl = get_pconfig($item['uid'], 'system', 'pagetemplate'); if (! $tpl) $tpl = 'page_display.tpl'; @@ -1770,6 +1712,9 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if (App::$is_sys) return; + if (get_pconfig($uid, 'system', 'noprofiletabs')) + return; + $channel = App::get_channel(); if (is_null($nickname)) @@ -1779,6 +1724,9 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ $uid = ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : local_channel()); $account_id = ((App::$profile['profile_uid']) ? App::$profile['channel_account_id'] : App::$channel['channel_account_id']); + if ($uid == local_channel()) + return; + if($uid == local_channel()) { $cal_link = ''; } @@ -1801,9 +1749,6 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ $has_webpages = (($r) ? true : false); - if (get_pconfig($uid, 'system', 'noprofiletabs')) - return; - if (x($_GET, 'tab')) $tab = notags(trim($_GET['tab'])); @@ -1817,6 +1762,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'channel') ? 'active' : ''), 'title' => t('Status Messages and Posts'), 'id' => 'status-tab', + 'icon' => 'home' ), ); @@ -1829,6 +1775,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'profile') ? 'active' : ''), 'title' => t('Profile Details'), 'id' => 'profile-tab', + 'icon' => 'user' ); } if ($p['view_storage']) { @@ -1838,6 +1785,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'photos') ? 'active' : ''), 'title' => t('Photo Albums'), 'id' => 'photo-tab', + 'icon' => 'photo' ); $tabs[] = array( 'label' => t('Files'), @@ -1845,6 +1793,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''), 'title' => t('Files and Storage'), 'id' => 'files-tab', + 'icon' => 'folder-open' ); } @@ -1855,6 +1804,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'cal' || argv(0) == 'events') ? 'active' : ''), 'title' => t('Events'), 'id' => 'event-tab', + 'icon' => 'calendar' ); } @@ -1868,6 +1818,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'chat') ? 'active' : '' ), 'title' => t('Chatrooms'), 'id' => 'chat-tab', + 'icon' => 'comments-o' ); } } @@ -1881,6 +1832,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'bookmarks') ? 'active' : ''), 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab', + 'icon' => 'bookmark' ); } @@ -1891,27 +1843,34 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ 'sel' => ((argv(0) == 'webpages') ? 'active' : ''), 'title' => t('View Webpages'), 'id' => 'webpages-tab', + 'icon' => 'newspaper-o' ); } - if(feature_enabled($uid,'wiki') && (get_account_techlevel($account_id) > 3)) { - $tabs[] = array( - 'label' => t('Wikis'), - 'url' => z_root() . '/wiki/' . $nickname, - 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), - 'title' => t('Wiki'), - 'id' => 'wiki-tab', - ); + if ($p['view_wiki']) { + if(feature_enabled($uid,'wiki') && (get_account_techlevel($account_id) > 3)) { + $tabs[] = array( + 'label' => t('Wikis'), + 'url' => z_root() . '/wiki/' . $nickname, + 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), + 'title' => t('Wiki'), + 'id' => 'wiki-tab', + 'icon' => 'pencil-square-o' + ); + } } - $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs); call_hooks('profile_tabs', $arr); - $tpl = get_markup_template('common_tabs.tpl'); + $tpl = get_markup_template('profile_tabs.tpl'); - return replace_macros($tpl,array('$tabs' => $arr['tabs'])); + return replace_macros($tpl, array( + '$tabs' => $arr['tabs'], + '$name' => App::$profile['channel_name'], + '$thumb' => App::$profile['thumb'] + )); } @@ -1922,15 +1881,11 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { $ret[$v] = array(); $ret[$v]['count'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid']] : ''); $ret[$v]['list'] = ((x($conv_responses[$v],$item['mid'])) ? $conv_responses[$v][$item['mid'] . '-l'] : ''); - if(count($ret[$v]['list']) > MAX_LIKERS) { - $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS); - array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-' - . (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>'); - } else { - $ret[$v]['list_part'] = ''; - } $ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']); $ret[$v]['title'] = $conv_responses[$v]['title']; + if($ret[$v]['count'] > MAX_LIKERS) { + $ret[$v]['modal'] = true; + } } $count = 0; |