aboutsummaryrefslogtreecommitdiffstats
path: root/include/conversation.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/conversation.php')
-rw-r--r--include/conversation.php325
1 files changed, 44 insertions, 281 deletions
diff --git a/include/conversation.php b/include/conversation.php
index faa53c639..79fe12d54 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -90,7 +90,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
function localize_item(&$item){
- if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
+ if (activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE])){
if(! $item['obj'])
return;
@@ -143,7 +143,7 @@ function localize_item(&$item){
switch($obj['type']) {
case ACTIVITY_OBJ_PHOTO:
- case 'Photo':
+ case 'Image':
$post_type = t('photo');
break;
case ACTIVITY_OBJ_EVENT:
@@ -151,6 +151,7 @@ function localize_item(&$item){
$post_type = t('event');
break;
case ACTIVITY_OBJ_PERSON:
+ case 'Person':
$post_type = t('channel');
$author_name = $obj['title'];
if($obj['link']) {
@@ -189,21 +190,19 @@ function localize_item(&$item){
$plink = '[zrl=' . zid($item_url) . ']' . $post_type . '[/zrl]';
- if(activity_match($item['verb'],ACTIVITY_LIKE)) {
+ if(activity_match($item['verb'], ['Like', ACTIVITY_LIKE])) {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
- }
- elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
- $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- }
-
- // short version, in notification strings the author will be displayed separately
-
- if(activity_match($item['verb'],ACTIVITY_LIKE)) {
+ // short version, in notification strings the author will be displayed separately
$shortbodyverb = t('likes %1$s\'s %2$s');
}
- elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
+ elseif(activity_match($item['verb'], ['Dislike', ACTIVITY_DISLIKE])) {
+ $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
$shortbodyverb = t('doesn\'t like %1$s\'s %2$s');
}
+ elseif(activity_match($item['verb'], ACTIVITY_SHARE)) {
+ $bodyverb = t('%1$s repeated %2$s\'s %3$s');
+ $shortbodyverb = t('repeated %1$s\'s %2$s');
+ }
$item['shortlocalize'] = sprintf($shortbodyverb, '[bdi]' . $author_name . '[/bdi]', $post_type);
@@ -218,191 +217,6 @@ function localize_item(&$item){
}
- if (activity_match($item['verb'],ACTIVITY_FRIEND)) {
-
- if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON)
- return;
-
- $Aname = $item['author']['xchan_name'];
- $Alink = $item['author']['xchan_url'];
-
-
- $obj= json_decode($item['obj'],true);
-
- $Blink = $Bphoto = '';
-
- if($obj['link']) {
- $Blink = get_rel_link($obj['link'],'alternate');
- $Bphoto = get_rel_link($obj['link'],'photo');
- }
- $Bname = $obj['title'];
-
-
- $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]';
- $B = '[zrl=' . chanlink_url($Blink) . '][bdi]' . $Bname . '[/bdi][/zrl]';
- if ($Bphoto!="") $Bphoto = '[zrl=' . chanlink_url($Blink) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
-
- $item['shortlocalize'] = sprintf( t('%1$s is now connected with %2$s'), '[bdi]' . $Aname . '[/bdi]', '[bdi]' . $Bname . '[/bdi]');
-
- $item['body'] = $item['localize'] = sprintf( t('%1$s is now connected with %2$s'), $A, $B);
- $item['body'] .= "\n\n\n" . $Bphoto;
- }
-
- if (stristr($item['verb'], ACTIVITY_POKE)) {
-
- /** @FIXME for obscured private posts, until then leave untranslated */
- return;
-
- $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
- if(! $verb)
- return;
-
- if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
-
- $Aname = $item['author']['xchan_name'];
- $Alink = $item['author']['xchan_url'];
-
- $obj= json_decode($item['obj'],true);
-
- $Blink = $Bphoto = '';
-
- if($obj['link']) {
- $Blink = get_rel_link($obj['link'],'alternate');
- $Bphoto = get_rel_link($obj['link'],'photo');
- }
- $Bname = $obj['title'];
-
- $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]';
- $B = '[zrl=' . chanlink_url($Blink) . '][bdi]' . $Bname . '[/bdi][/zrl]';
- if ($Bphoto!="") $Bphoto = '[zrl=' . chanlink_url($Blink) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
-
- // we can't have a translation string with three positions but no distinguishable text
- // So here is the translate string.
-
- $txt = t('%1$s poked %2$s');
-
- // now translate the verb
-
- $txt = str_replace( t('poked'), t($verb), $txt);
-
- // then do the sprintf on the translation string
-
- $item['shortlocalize'] = sprintf($txt, '[bdi]' . $Aname . '[/bdi]', '[bdi]' . $Bname . '[/bdi]');
-
- $item['body'] = $item['localize'] = sprintf($txt, $A, $B);
- $item['body'] .= "\n\n\n" . $Bphoto;
- }
- if (stristr($item['verb'],ACTIVITY_MOOD)) {
- $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
- if(! $verb)
- return;
-
- $Aname = $item['author']['xchan_name'];
- $Alink = $item['author']['xchan_url'];
-
- $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]';
-
- $txt = t('%1$s is %2$s','mood');
-
- $item['body'] = sprintf($txt, $A, t($verb));
- }
-
-
-
-/*
-// FIXME store parent item as object or target
-// (and update to json storage)
-
- if (activity_match($item['verb'],ACTIVITY_TAG)) {
- $r = q("SELECT * from item,contact WHERE
- item.contact-id=contact.id AND item.mid='%s';",
- dbesc($item['parent_mid']));
- if(count($r)==0) return;
- $obj=$r[0];
-
- $author = '[zrl=' . zid($item['author-link']) . ']' . $item['author-name'] . '[/zrl]';
- $objauthor = '[zrl=' . zid($obj['author-link']) . ']' . $obj['author-name'] . '[/zrl]';
-
- switch($obj['verb']){
- case ACTIVITY_POST:
- switch ($obj['obj_type']){
- case ACTIVITY_OBJ_EVENT:
- $post_type = t('event');
- break;
- default:
- $post_type = t('status');
- }
- break;
- default:
- if($obj['resource_id']){
- $post_type = t('photo');
- $m=array(); preg_match("/\[[zu]rl=([^]]*)\]/", $obj['body'], $m);
- $rr['plink'] = $m[1];
- } else {
- $post_type = t('status');
- }
- }
- $plink = '[zrl=' . $obj['plink'] . ']' . $post_type . '[/zrl]';
-
-// $parsedobj = parse_xml_string($xmlhead.$item['obj']);
-
- $tag = sprintf('#[zrl=%s]%s[/zrl]', $parsedobj->id, $parsedobj->content);
- $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
-
- }
-
- if (activity_match($item['verb'],ACTIVITY_FAVORITE)){
-
- if ($item['obj_type']== "")
- return;
-
- $Aname = $item['author']['xchan_name'];
- $Alink = $item['author']['xchan_url'];
-
- $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-
-// $obj = parse_xml_string($xmlhead.$item['obj']);
- if(strlen($obj->id)) {
- $r = q("select * from item where mid = '%s' and uid = %d limit 1",
- dbesc($obj->id),
- intval($item['uid'])
- );
- if(count($r) && $r[0]['plink']) {
- $target = $r[0];
- $Bname = $target['author-name'];
- $Blink = $target['author-link'];
- $A = '[zrl=' . zid($Alink) . ']' . $Aname . '[/zrl]';
- $B = '[zrl=' . zid($Blink) . ']' . $Bname . '[/zrl]';
- $P = '[zrl=' . $target['plink'] . ']' . t('post/item') . '[/zrl]';
- $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
-
- }
- }
- }
-*/
-
-/*
- $matches = null;
- if(strpos($item['body'],'[zrl') !== false) {
- if(preg_match_all('/@\[zrl=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
- foreach($matches as $mtch) {
- if(! strpos($mtch[1],'zid='))
- $item['body'] = str_replace($mtch[0],'@[zrl=' . zid($mtch[1]). ']',$item['body']);
- }
- }
- }
-
- if(strpos($item['body'],'[zmg') !== false) {
- // add zid's to public images
- if(preg_match_all('/\[zrl=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[zmg(.*?)\]h(.*?)\[\/zmg\]\[\/zrl\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
- foreach($matches as $mtch) {
- $item['body'] = str_replace($mtch[0],'[zrl=' . zid( $mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3]) . '][zmg' . $mtch[4] . ']h' . $mtch[5] . '[/zmg][/zrl]',$item['body']);
- }
- }
- }
-*/
-
-
}
/**
@@ -441,7 +255,7 @@ function count_descendants($item) {
* @return boolean
*/
function visible_activity($item) {
- $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ];
+ $hidden_activities = ['Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
if(intval($item['item_notshown']))
return false;
@@ -450,7 +264,7 @@ function visible_activity($item) {
return false;
}
- if (in_array($item['verb'], ['Add', 'Remove', ACTIVITY_TAG])) {
+ if (in_array($item['verb'], ['Add', 'Remove'])) {
return false;
}
@@ -476,27 +290,6 @@ function visible_activity($item) {
return true;
}
-/**
- * @brief Check if a given activity is an edit activity
- *
- *
- * @param array $item
- * @return boolean
- */
-
-function is_edit_activity($item) {
-
- $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)];
-
- // In order to share edits with networks which have no concept of editing, we'll create
- // separate activities to indicate the edit. Our network will not require them, since our
- // edits are automatically applied and the activity indicated.
-
- if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types)))
- return true;
-
- return false;
-}
/**
* @brief "Render" a conversation or list of items for HTML display.
@@ -670,13 +463,11 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$conv_responses = [
'like' => ['title' => t('Likes','title')],
'dislike' => ['title' => t('Dislikes','title')],
- 'agree' => ['title' => t('Agree','title')],
- 'disagree' => ['title' => t('Disagree','title')],
- 'abstain' => ['title' => t('Abstain','title')],
'attendyes' => ['title' => t('Attending','title')],
'attendno' => ['title' => t('Not attending','title')],
'attendmaybe' => ['title' => t('Might attend','title')],
- 'answer' => []
+ 'answer' => [],
+ 'announce' => ['title' => t('Repeats','title')],
];
@@ -718,9 +509,9 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$is_new = false;
if($mode === 'search' || $mode === 'community') {
- if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
- && ($item['id'] != $item['parent']))
+ if(activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]) && $item['id'] != $item['parent']) {
continue;
+ }
}
$sp = false;
@@ -785,16 +576,14 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$is_new = true;
- $conv_link_mid = (($mode == 'moderate') ? gen_link_id($item['parent_mid']) : gen_link_id($item['mid']));
-
- $conv_link = z_root() . '/display/' . $conv_link_mid;
+ $conv_link = z_root() . '/display/' . $item['uuid'];
if(local_channel()) {
- $conv_link = z_root() . '/hq/' . $conv_link_mid;
+ $conv_link = z_root() . '/hq/' . $item['uuid'];
}
if ($mode === 'pubstream-new') {
- $conv_link = z_root() . '/pubstream?mid=' . $conv_link_mid;
+ $conv_link = z_root() . '/pubstream?mid=' . $item['uuid'];
}
$contact = [];
@@ -812,8 +601,8 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
'delete' => t('Delete'),
'preview_lbl' => $preview_lbl,
'id' => (($preview) ? 'P0' : $item['item_id']),
- 'mid' => gen_link_id($item['mid']),
- 'mids' => json_encode([gen_link_id($item['mid'])]),
+ 'mid' => $item['uuid'],
+ 'mids' => json_encode([$item['uuid']]),
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_link),
'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']),
'profile_url' => $profile_link,
@@ -914,7 +703,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
continue;
}
-
+ $mid_uuid_map[$item['mid']] = $item['uuid'];
$item['pagedrop'] = $page_dropping;
@@ -934,7 +723,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
}
}
- $threads = $conv->get_template_data($conv_responses);
+ $threads = $conv->get_template_data($conv_responses, $mid_uuid_map);
if(!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
$threads = array();
@@ -1091,13 +880,10 @@ function thread_author_menu($item, $mode = '') {
}
}
-
$contact_url = '';
$posts_link = '';
- $poke_link = '';
if($contact) {
- $poke_link = ((Apps::system_app_installed($local_channel, 'Poke')) ? z_root() . '/poke/?f=&c=' . $contact['abook_id'] : '');
if (isset($contact['abook_self']) && !intval($contact['abook_self']))
$contact_url = z_root() . '/connections#' . $contact['abook_id'];
$posts_link = z_root() . '/network/?cid=' . $contact['abook_id'];
@@ -1151,18 +937,6 @@ function thread_author_menu($item, $mode = '') {
];
}
- if($poke_link) {
- $menu[] = [
- 'menu' => 'poke',
- 'title' => t('Poke'),
- 'icon' => 'fw',
- 'action' => '',
- 'href' => $poke_link,
- 'data' => '',
- 'class' => ''
- ];
- }
-
$args = [ 'item' => $item, 'mode' => $mode, 'menu' => $menu ];
call_hooks('thread_author_menu', $args);
@@ -1186,7 +960,7 @@ function builtin_activity_puller($item, &$conv_responses) {
// if this item is a post or comment there's nothing for us to do here, just return.
- if(activity_match($item['verb'],ACTIVITY_POST) && $item['obj_type'] !== 'Answer')
+ if(activity_match($item['verb'], ['Create', ACTIVITY_POST]) && $item['obj_type'] !== 'Answer')
return;
foreach($conv_responses as $mode => $v) {
@@ -1195,31 +969,25 @@ function builtin_activity_puller($item, &$conv_responses) {
switch($mode) {
case 'like':
- $verb = ACTIVITY_LIKE;
+ $verb = ['Like', ACTIVITY_LIKE];
break;
case 'dislike':
- $verb = ACTIVITY_DISLIKE;
- break;
- case 'agree':
- $verb = ACTIVITY_AGREE;
- break;
- case 'disagree':
- $verb = ACTIVITY_DISAGREE;
- break;
- case 'abstain':
- $verb = ACTIVITY_ABSTAIN;
+ $verb = ['Dislike', ACTIVITY_DISLIKE];
break;
case 'attendyes':
- $verb = ACTIVITY_ATTEND;
+ $verb = ['Accept', ACTIVITY_ATTEND];
break;
case 'attendno':
- $verb = ACTIVITY_ATTENDNO;
+ $verb = ['Reject', ACTIVITY_ATTENDNO];
break;
case 'attendmaybe':
- $verb = ACTIVITY_ATTENDMAYBE;
+ $verb = ['TentativeAccept', ACTIVITY_ATTENDMAYBE];
break;
case 'answer':
- $verb = ACTIVITY_POST;
+ $verb = ['Create', ACTIVITY_POST];
+ break;
+ case 'announce':
+ $verb = 'Announce';
break;
default:
return;
@@ -1227,6 +995,7 @@ 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'));
$moderate = ((intval($item['item_blocked']) === ITEM_MODERATED) ? '<a href="moderate/' . $item['id'] . '/approve" onclick="moderate_approve(' . $item['id'] . '); return false;" class="text-success pe-2" title="' . t('Approve this item') . '"><i class="fa fa-check" ></i></a><a href="moderate/' . $item['id'] . '/drop" onclick="moderate_drop(' . $item['id'] . '); return false;" class="text-danger pe-2" title="' . t('Delete this item') . '"><i class="fa fa-trash-o" ></i></a>' : '');
@@ -1241,7 +1010,7 @@ function builtin_activity_puller($item, &$conv_responses) {
if(! $item['thr_parent'])
$item['thr_parent'] = $item['parent_mid'];
- $conv_responses[$mode]['mids'][$item['thr_parent']][] = gen_link_id($item['mid']);
+ $conv_responses[$mode]['mids'][$item['thr_parent']][] = $item['uuid'];
if($item['obj_type'] === 'Answer')
continue;
@@ -1778,28 +1547,22 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
function get_response_button_text($v,$count) {
switch($v) {
case 'like':
- return tt('Like','Likes',$count,'noun');
+ return ['label' => tt('Like','Likes',$count,'noun'), 'icon' => 'thumbs-o-up', 'class' => 'like'];
+ break;
+ case 'announce':
+ return ['label' => tt('Repeat','Repeats',$count,'noun'), 'icon' => 'retweet', 'class' => 'announce'];
break;
case 'dislike':
- return tt('Dislike','Dislikes',$count,'noun');
+ return ['label' => tt('Dislike','Dislikes',$count,'noun'), 'icon' => 'thumbs-o-down', 'class' => 'dislike'];
break;
case 'attendyes':
- return tt('Attending','Attending',$count,'noun');
+ return ['label' => tt('Attending','Attending',$count,'noun'), 'icon' => 'calendar-check-o', 'class' => 'attendyes'];
break;
case 'attendno':
- return tt('Not Attending','Not Attending',$count,'noun');
+ return ['label' => tt('Not Attending','Not Attending',$count,'noun'), 'icon' => 'calendar-times-o', 'class' => 'attendno'];
break;
case 'attendmaybe':
- return tt('Undecided','Undecided',$count,'noun');
- break;
- case 'agree':
- return tt('Agree','Agrees',$count,'noun');
- break;
- case 'disagree':
- return tt('Disagree','Disagrees',$count,'noun');
- break;
- case 'abstain':
- return tt('Abstain','Abstains',$count,'noun');
+ return ['label' => tt('Undecided','Undecided',$count,'noun'), 'icon' => 'calendar-o', 'class' => 'attendmaybe'];
break;
default:
return '';