Merge pull request #600 from dawnbreak/master
Don't link unknown likes.
This commit is contained in:
commit
aa928d65eb
@ -440,7 +440,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
for($x = 0; $x < count($arr_blocked); $x ++)
|
for($x = 0; $x < count($arr_blocked); $x ++)
|
||||||
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -458,59 +457,53 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$profile_owner = local_user();
|
$profile_owner = local_user();
|
||||||
$page_writeable = true;
|
$page_writeable = true;
|
||||||
|
|
||||||
if(!$update) {
|
if(!$update) {
|
||||||
// The special div is needed for liveUpdate to kick in for this page.
|
// The special div is needed for liveUpdate to kick in for this page.
|
||||||
// We only launch liveUpdate if you aren't filtering in some incompatible
|
// We only launch liveUpdate if you aren't filtering in some incompatible
|
||||||
// way and also you aren't writing a comment (discovered in javascript).
|
// way and also you aren't writing a comment (discovered in javascript).
|
||||||
|
|
||||||
$live_update_div = '<div id="live-network"></div>' . "\r\n"
|
|
||||||
. "<script> var profile_uid = " . $_SESSION['uid']
|
|
||||||
. "; var netargs = '" . substr($a->cmd,8)
|
|
||||||
. '?f='
|
|
||||||
. ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
|
|
||||||
. ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '')
|
|
||||||
. ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
|
|
||||||
. ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '')
|
|
||||||
. ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
|
|
||||||
. ((x($_GET,'liked')) ? '&liked=' . $_GET['liked'] : '')
|
|
||||||
. ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
|
|
||||||
. ((x($_GET,'spam')) ? '&spam=' . $_GET['spam'] : '')
|
|
||||||
. ((x($_GET,'nets')) ? '&nets=' . $_GET['nets'] : '')
|
|
||||||
. ((x($_GET,'cmin')) ? '&cmin=' . $_GET['cmin'] : '')
|
|
||||||
. ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
|
|
||||||
. ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '')
|
|
||||||
. ((x($_GET,'uri')) ? '&uri=' . $_GET['uri'] : '')
|
|
||||||
|
|
||||||
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
$live_update_div = '<div id="live-network"></div>' . "\r\n"
|
||||||
|
. "<script> var profile_uid = " . $_SESSION['uid']
|
||||||
|
. "; var netargs = '" . substr($a->cmd,8)
|
||||||
|
. '?f='
|
||||||
|
. ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
|
||||||
|
. ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '')
|
||||||
|
. ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
|
||||||
|
. ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '')
|
||||||
|
. ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
|
||||||
|
. ((x($_GET,'liked')) ? '&liked=' . $_GET['liked'] : '')
|
||||||
|
. ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
|
||||||
|
. ((x($_GET,'spam')) ? '&spam=' . $_GET['spam'] : '')
|
||||||
|
. ((x($_GET,'nets')) ? '&nets=' . $_GET['nets'] : '')
|
||||||
|
. ((x($_GET,'cmin')) ? '&cmin=' . $_GET['cmin'] : '')
|
||||||
|
. ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
|
||||||
|
. ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '')
|
||||||
|
. ((x($_GET,'uri')) ? '&uri=' . $_GET['uri'] : '')
|
||||||
|
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($mode === 'channel') {
|
elseif($mode === 'channel') {
|
||||||
$profile_owner = $a->profile['profile_uid'];
|
$profile_owner = $a->profile['profile_uid'];
|
||||||
$page_writeable = ($profile_owner == local_user());
|
$page_writeable = ($profile_owner == local_user());
|
||||||
|
|
||||||
if(!$update) {
|
if(!$update) {
|
||||||
$tab = notags(trim($_GET['tab']));
|
$tab = notags(trim($_GET['tab']));
|
||||||
if($tab === 'posts') {
|
if($tab === 'posts') {
|
||||||
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
|
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
|
||||||
// because browser prefetching might change it on us. We have to deliver it with the page.
|
// because browser prefetching might change it on us. We have to deliver it with the page.
|
||||||
|
|
||||||
$live_update_div = '<div id="live-channel"></div>' . "\r\n"
|
|
||||||
. "<script> var profile_uid = " . $a->profile['profile_uid']
|
|
||||||
. "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$live_update_div = '<div id="live-channel"></div>' . "\r\n"
|
||||||
|
. "<script> var profile_uid = " . $a->profile['profile_uid']
|
||||||
|
. "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($mode === 'display') {
|
elseif($mode === 'display') {
|
||||||
$profile_owner = local_user();
|
$profile_owner = local_user();
|
||||||
$page_writeable = false;
|
$page_writeable = false;
|
||||||
|
$live_update_div = '<div id="live-display"></div>' . "\r\n";
|
||||||
$live_update_div = '<div id="live-display"></div>' . "\r\n";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($mode === 'page') {
|
elseif($mode === 'page') {
|
||||||
@ -519,10 +512,10 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$live_update_div = '<div id="live-page"></div>' . "\r\n";
|
$live_update_div = '<div id="live-page"></div>' . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elseif($mode === 'search') {
|
||||||
|
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
elseif($mode === 'search') {
|
|
||||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
|
||||||
}
|
|
||||||
elseif($mode === 'photos') {
|
elseif($mode === 'photos') {
|
||||||
$profile_onwer = $a->profile['profile_uid'];
|
$profile_onwer = $a->profile['profile_uid'];
|
||||||
$page_writeable = ($profile_owner == local_user());
|
$page_writeable = ($profile_owner == local_user());
|
||||||
@ -555,7 +548,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$alike = array();
|
$alike = array();
|
||||||
$dlike = array();
|
$dlike = array();
|
||||||
|
|
||||||
|
|
||||||
// array with html for each thread (parent+comments)
|
// array with html for each thread (parent+comments)
|
||||||
$threads = array();
|
$threads = array();
|
||||||
$threadsid = -1;
|
$threadsid = -1;
|
||||||
@ -609,7 +601,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$profile_name = $item['author-link'];
|
$profile_name = $item['author-link'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tags=array();
|
$tags=array();
|
||||||
$hashtags = array();
|
$hashtags = array();
|
||||||
$mentions = array();
|
$mentions = array();
|
||||||
@ -631,7 +622,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$profile_link = $item['author']['xchan_url'];
|
$profile_link = $item['author']['xchan_url'];
|
||||||
$profile_avatar = $item['author']['xchan_photo_m'];
|
$profile_avatar = $item['author']['xchan_photo_m'];
|
||||||
|
|
||||||
|
|
||||||
$location = format_location($item);
|
$location = format_location($item);
|
||||||
|
|
||||||
localize_item($item);
|
localize_item($item);
|
||||||
@ -663,7 +653,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$unverified = '';
|
$unverified = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tags=array();
|
$tags=array();
|
||||||
$terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN));
|
$terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN));
|
||||||
if(count($terms))
|
if(count($terms))
|
||||||
@ -694,12 +683,11 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
'verified' => $verified,
|
'verified' => $verified,
|
||||||
'unverified' => $unverified,
|
'unverified' => $unverified,
|
||||||
'txt_cats' => t('Categories:'),
|
'txt_cats' => t('Categories:'),
|
||||||
'txt_folders' => t('Filed under:'),
|
'txt_folders' => t('Filed under:'),
|
||||||
'has_cats' => ((count($categories)) ? 'true' : ''),
|
'has_cats' => ((count($categories)) ? 'true' : ''),
|
||||||
'has_folders' => ((count($folders)) ? 'true' : ''),
|
'has_folders' => ((count($folders)) ? 'true' : ''),
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'folders' => $folders,
|
'folders' => $folders,
|
||||||
|
|
||||||
'text' => strip_tags($body),
|
'text' => strip_tags($body),
|
||||||
'ago' => relative_date($item['created']),
|
'ago' => relative_date($item['created']),
|
||||||
'app' => $item['app'],
|
'app' => $item['app'],
|
||||||
@ -743,10 +731,10 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
// Normal View
|
// Normal View
|
||||||
// logger('conv: items: ' . print_r($items,true));
|
// logger('conv: items: ' . print_r($items,true));
|
||||||
|
|
||||||
require_once('include/ConversationObject.php');
|
require_once('include/ConversationObject.php');
|
||||||
require_once('include/ItemObject.php');
|
require_once('include/ItemObject.php');
|
||||||
|
|
||||||
$conv = new Conversation($mode, $preview, $prepared_item);
|
$conv = new Conversation($mode, $preview, $prepared_item);
|
||||||
|
|
||||||
// In the display mode we don't have a profile owner.
|
// In the display mode we don't have a profile owner.
|
||||||
|
|
||||||
@ -754,12 +742,12 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$conv->set_profile_owner($items[0]['uid']);
|
$conv->set_profile_owner($items[0]['uid']);
|
||||||
|
|
||||||
|
|
||||||
// get all the topmost parents
|
// get all the topmost parents
|
||||||
// this shouldn't be needed, as we should have only them in our array
|
// this shouldn't be needed, as we should have only them in our array
|
||||||
// But for now, this array respects the old style, just in case
|
// But for now, this array respects the old style, just in case
|
||||||
|
|
||||||
$threads = array();
|
$threads = array();
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
|
|
||||||
// Check for any blocked authors
|
// Check for any blocked authors
|
||||||
|
|
||||||
@ -786,46 +774,43 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
like_puller($a, $item, $alike, 'like');
|
||||||
|
|
||||||
|
if(feature_enabled($profile_owner, 'dislike'))
|
||||||
|
like_puller($a, $item, $dlike, 'dislike');
|
||||||
|
|
||||||
like_puller($a,$item,$alike,'like');
|
if(! visible_activity($item)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(feature_enabled($profile_owner,'dislike'))
|
$item['pagedrop'] = $page_dropping;
|
||||||
like_puller($a,$item,$dlike,'dislike');
|
|
||||||
|
|
||||||
if(! visible_activity($item)) {
|
if($item['id'] == $item['parent']) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$item['pagedrop'] = $page_dropping;
|
|
||||||
|
|
||||||
if($item['id'] == $item['parent']) {
|
|
||||||
// $tx1 = dba_timer();
|
// $tx1 = dba_timer();
|
||||||
$item_object = new Item($item);
|
$item_object = new Item($item);
|
||||||
$conv->add_thread($item_object);
|
$conv->add_thread($item_object);
|
||||||
if($page_mode === 'list')
|
if($page_mode === 'list')
|
||||||
$item_object->set_template('conv_list.tpl');
|
$item_object->set_template('conv_list.tpl');
|
||||||
|
|
||||||
// $tx2 = dba_timer();
|
// $tx2 = dba_timer();
|
||||||
// if($mode === 'network')
|
// if($mode === 'network')
|
||||||
// profiler($tx1,$tx2,'add thread ' . $item['id']);
|
// profiler($tx1,$tx2,'add thread ' . $item['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$t2 = dba_timer();
|
$t2 = dba_timer();
|
||||||
$threads = $conv->get_template_data($alike, $dlike);
|
$threads = $conv->get_template_data($alike, $dlike);
|
||||||
if(!$threads) {
|
if(!$threads) {
|
||||||
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
|
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
|
||||||
$threads = array();
|
$threads = array();
|
||||||
}
|
}
|
||||||
$t3 = dba_timer();
|
$t3 = dba_timer();
|
||||||
if($mode === 'network') {
|
if($mode === 'network') {
|
||||||
profiler($t1,$t2,'Conversation prepare');
|
profiler($t1,$t2,'Conversation prepare');
|
||||||
profiler($t2,$t3,'Conversation get_template');
|
profiler($t2,$t3,'Conversation get_template');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($page_mode === 'traditional' || $page_mode === 'preview') {
|
if($page_mode === 'traditional' || $page_mode === 'preview') {
|
||||||
$page_template = get_markup_template("threaded_conversation.tpl");
|
$page_template = get_markup_template("threaded_conversation.tpl");
|
||||||
@ -867,8 +852,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
if($page_mode === 'preview')
|
if($page_mode === 'preview')
|
||||||
logger('preview: ' . $o);
|
logger('preview: ' . $o);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,25 +965,32 @@ function item_photo_menu($item){
|
|||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function like_puller($a,$item,&$arr,$mode) {
|
* @brief Returns a like/dislike entry.
|
||||||
|
* It gives back a HTML link to the channel that liked/disliked.
|
||||||
|
*
|
||||||
|
* @param array $a (not used)
|
||||||
|
* @param array $item
|
||||||
|
* @param array &$arr
|
||||||
|
* @param string $mode like/dislike
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function like_puller($a, $item, &$arr, $mode) {
|
||||||
|
|
||||||
$url = '';
|
$url = '';
|
||||||
$sparkle = '';
|
|
||||||
$verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
|
$verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
|
||||||
|
|
||||||
if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
|
if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
|
||||||
|
|
||||||
if($item['author']['xchan_url'])
|
if($item['author']['xchan_url'])
|
||||||
$url = chanlink_url($item['author']['xchan_url']);
|
$url = chanlink_url($item['author']['xchan_url']);
|
||||||
else
|
|
||||||
$url = z_root();
|
|
||||||
|
|
||||||
if(! $item['thr_parent'])
|
if(! $item['thr_parent'])
|
||||||
$item['thr_parent'] = $item['parent_mid'];
|
$item['thr_parent'] = $item['parent_mid'];
|
||||||
|
|
||||||
if(! ((isset($arr[$item['thr_parent'] . '-l'])) && (is_array($arr[$item['thr_parent'] . '-l']))))
|
if(! ((isset($arr[$item['thr_parent'] . '-l'])) && (is_array($arr[$item['thr_parent'] . '-l']))))
|
||||||
$arr[$item['thr_parent'] . '-l'] = array();
|
$arr[$item['thr_parent'] . '-l'] = array();
|
||||||
|
|
||||||
if(! isset($arr[$item['thr_parent']]))
|
if(! isset($arr[$item['thr_parent']]))
|
||||||
$arr[$item['thr_parent']] = 1;
|
$arr[$item['thr_parent']] = 1;
|
||||||
else
|
else
|
||||||
@ -1007,7 +998,10 @@ function like_puller($a,$item,&$arr,$mode) {
|
|||||||
|
|
||||||
$name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
|
$name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
|
||||||
|
|
||||||
$arr[$item['thr_parent'] . '-l'][] = '<a href="'. $url . '">' . $name . '</a>';
|
if($url)
|
||||||
|
$arr[$item['thr_parent'] . '-l'][] = '<a href="'. $url . '">' . $name . '</a>';
|
||||||
|
else
|
||||||
|
$arr[$item['thr_parent'] . '-l'][] = '<a href="#" class="disabled">' . $name . '</a>';
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -232,3 +232,9 @@
|
|||||||
display: none;
|
display: none;
|
||||||
margin-top: 7px;
|
margin-top: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* disable link handling for unknown entries */
|
||||||
|
.dropdown-menu > li > a.disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user