aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/ThreadItem.php31
-rw-r--r--Zotlabs/Lib/ThreadStream.php5
-rw-r--r--Zotlabs/Module/Photos.php11
-rw-r--r--include/conversation.php120
-rw-r--r--include/items.php11
5 files changed, 22 insertions, 156 deletions
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 1f3e4f8e0..929792916 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -34,8 +34,6 @@ class ThreadItem {
private $channel = null;
private $display_mode = 'normal';
private $reload = '';
- private $mid_uuid_map = [];
-
public function __construct($data) {
@@ -81,7 +79,7 @@ class ThreadItem {
* _ false on failure
*/
- public function get_template_data($conv_responses, $mid_uuid_map, $thread_level=1, $conv_flags = []) {
+ public function get_template_data($thread_level=1, $conv_flags = []) {
$result = [];
$item = $this->get_data();
@@ -220,14 +218,8 @@ class ThreadItem {
}
$response_verbs[] = 'comment';
- $responses = get_responses($conv_responses,$response_verbs,$this,$item);
+ $responses = get_responses($response_verbs, $item);
-/*
- $my_responses = [];
- foreach($response_verbs as $v) {
- $my_responses[$v] = ((isset($conv_responses[$v][$item['mid'] . '-m'])) ? 1 : 0);
- }
-*/
/*
* We should avoid doing this all the time, but it depends on the conversation mode
@@ -342,14 +334,7 @@ class ThreadItem {
$midb64 = $item['uuid'];
$mids = [ $item['uuid'] ];
- $response_mids = [];
- foreach($response_verbs as $v) {
- if(isset($conv_responses[$v]['mids'][$item['mid']])) {
- $response_mids = array_merge($response_mids, $conv_responses[$v]['mids'][$item['mid']]);
- }
- }
- $mids = array_merge($mids, $response_mids);
$json_mids = json_encode($mids);
// Pinned item processing
@@ -467,7 +452,7 @@ class ThreadItem {
'wait' => t('Please wait'),
'thread_level' => $thread_level,
'settings' => $settings,
- 'thr_parent_uuid' => (($item['parent_mid'] !== $item['thr_parent'] && isset($mid_uuid_map[$item['thr_parent']])) ? $mid_uuid_map[$item['thr_parent']] : ''),
+ 'thr_parent_uuid' => ((isset($item['thr_parent_uuid']) && $item['thr_parent'] !== $item['parent_mid']) ? $item['thr_parent_uuid'] : ''),
'contact_id' => (($contact) ? $contact['abook_id'] : ''),
'moderate' => ($item['item_blocked'] == ITEM_MODERATED),
'moderate_approve' => t('Approve'),
@@ -503,20 +488,14 @@ class ThreadItem {
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
- $result['children'][] = $child->get_template_data($conv_responses, $mid_uuid_map, $thread_level + 1, $conv_flags);
+ $result['children'][] = $child->get_template_data($thread_level + 1, $conv_flags);
}
// Collapse
if($thread_level === 1 && $nb_children > $visible_comments) {
$result['children'][0]['comment_firstcollapsed'] = true;
$result['children'][0]['num_comments'] = $comment_count_txt['label'];
-// $result['children'][0]['hide_text'] = t('show all');
-// if($thread_level > 1) {
-// $result['children'][$nb_children - 1]['comment_lastcollapsed'] = false;
-// }
-// else {
- $result['children'][$nb_children - ($visible_comments + 1)]['comment_lastcollapsed'] = true;
-// }
+ $result['children'][$nb_children - ($visible_comments + 1)]['comment_lastcollapsed'] = true;
}
}
diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php
index fb3b6dd9b..4e11ba252 100644
--- a/Zotlabs/Lib/ThreadStream.php
+++ b/Zotlabs/Lib/ThreadStream.php
@@ -211,16 +211,15 @@ class ThreadStream {
* _ The data requested on success
* _ false on failure
*/
- public function get_template_data($conv_responses, $mid_uuid_map) {
+ public function get_template_data() {
$result = array();
foreach($this->threads as $item) {
-
if(($item->get_data_value('id') == $item->get_data_value('parent')) && $this->prepared_item) {
$item_data = $this->prepared_item;
}
else {
- $item_data = $item->get_template_data($conv_responses, $mid_uuid_map);
+ $item_data = $item->get_template_data();
}
if(!$item_data) {
logger('Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG, LOG_ERR);
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 862298e82..5f6162ba7 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -1104,17 +1104,8 @@ class Photos extends \Zotlabs\Web\Controller {
$alike = array();
$dlike = array();
- $conv_responses = array(
- 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
- 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
- );
-
if($r) {
- foreach($r as $item) {
- builtin_activity_puller($item, $conv_responses);
- }
-
$like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : '');
$like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : '');
@@ -1224,7 +1215,7 @@ class Photos extends \Zotlabs\Web\Controller {
$response_verbs[] = 'dislike';
}
- $responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+ $responses = get_responses($response_verbs, $link_item);
}
$hookdata = [
diff --git a/include/conversation.php b/include/conversation.php
index b81c6e5d9..97a65c27d 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -465,17 +465,6 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$items = $cb['items'];
- $conv_responses = [
- 'like' => ['title' => t('Likes','title')],
- 'dislike' => ['title' => t('Dislikes','title')],
- 'attendyes' => ['title' => t('Attending','title')],
- 'attendno' => ['title' => t('Not attending','title')],
- 'attendmaybe' => ['title' => t('Might attend','title')],
- 'answer' => [],
- 'announce' => ['title' => t('Repeats','title')],
- ];
-
-
// array with html for each thread (parent+comments)
$threads = array();
$threadsid = -1;
@@ -702,14 +691,10 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$item = $x['item'];
- // builtin_activity_puller($item, $conv_responses);
-
- if(! visible_activity($item)) {
+ if (!visible_activity($item)) {
continue;
}
- $mid_uuid_map[$item['mid']] = $item['uuid'];
-
$item['pagedrop'] = $page_dropping;
if($item['id'] == $item['parent'] || $r_preview) {
@@ -718,7 +703,6 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$conv->add_thread($item_object);
if(($page_mode === 'list') || ($page_mode === 'pager_list')) {
- // $item_object->set_template('conv_list.tpl');
$item_object->set_display_mode('list');
}
if($mode === 'cards' || $mode === 'articles') {
@@ -728,7 +712,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
}
}
- $threads = $conv->get_template_data($conv_responses, $mid_uuid_map);
+ $threads = $conv->get_template_data();
if(!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
$threads = array();
@@ -950,104 +934,6 @@ function thread_author_menu($item, $mode = '') {
}
-
-
-
-/**
- * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
- *
- * Increments the count of each matching activity and adds a link to the author as needed.
- *
- * @param array $item
- * @param array &$conv_responses (already created with builtin activity structure)
- */
-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'], ['Create', ACTIVITY_POST]) && $item['obj_type'] !== 'Answer')
- return;
-
- foreach($conv_responses as $mode => $v) {
-
- $url = '';
-
- switch($mode) {
- case 'like':
- $verb = ['Like', ACTIVITY_LIKE];
- break;
- case 'dislike':
- $verb = ['Dislike', ACTIVITY_DISLIKE];
- break;
- case 'comment':
- $verb = ['Create'];
- break;
- case 'attendyes':
- $verb = ['Accept', ACTIVITY_ATTEND];
- break;
- case 'attendno':
- $verb = ['Reject', ACTIVITY_ATTENDNO];
- break;
- case 'attendmaybe':
- $verb = ['TentativeAccept', ACTIVITY_ATTENDMAYBE];
- break;
- case 'answer':
- $verb = ['Create', ACTIVITY_POST];
- break;
- case 'announce':
- $verb = 'Announce';
- break;
- default:
- return;
- break;
- }
-
- 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="bi bi-check-lg" ></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="bi bi-trash" ></i></a>' : '');
-
- $url = (($item['author_xchan'] && $item['author']['xchan_photo_s'])
- ? '<div class="dropdown-item">' . $moderate . '<a href="' . chanlink_hash($item['author_xchan']) . '" class="text-reset">' . '<img class="menu-img-1" src="' . $item['author']['xchan_photo_s'] . '" alt="' . urlencode($name) . '" loading="lazy" /> ' . $name . '</a></div>'
- : '<a class="dropdown-item" href="#" class="disabled">' . $name . '</a>'
- );
-
-
-
- if(! $item['thr_parent'])
- $item['thr_parent'] = $item['parent_mid'];
-
- $conv_responses[$mode]['mids'][$item['thr_parent']][] = $item['uuid'];
-
- if($item['obj_type'] === 'Answer')
- continue;
-
- if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l']))
- && (is_array($conv_responses[$mode][$item['thr_parent'] . '-l']))))
- $conv_responses[$mode][$item['thr_parent'] . '-l'] = array();
-
- // only list each unique author once
- if(in_array($url,$conv_responses[$mode][$item['thr_parent'] . '-l']))
- continue;
-
- if(! isset($conv_responses[$mode][$item['thr_parent']]))
- $conv_responses[$mode][$item['thr_parent']] = 1;
- else
- $conv_responses[$mode][$item['thr_parent']] ++;
-
- $conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
- if(get_observer_hash() && get_observer_hash() === $item['author_xchan']) {
- $conv_responses[$mode][$item['thr_parent'] . '-m'] = true;
- }
-
- // there can only be one activity verb per item so if we found anything, we can stop looking
- return;
- }
- }
-}
-
-
/**
* @brief Format the like/dislike text for a profile item.
*
@@ -1529,7 +1415,7 @@ function prepare_page($item) {
));
}
-function get_responses($conv_responses,$response_verbs,$ob,$item) {
+function get_responses($response_verbs, $item) {
$ret = array();
foreach($response_verbs as $v) {
diff --git a/include/items.php b/include/items.php
index 0f46b5f78..f25a564a5 100644
--- a/include/items.php
+++ b/include/items.php
@@ -5460,8 +5460,18 @@ function items_by_parent_ids(string $ids, string $thr_parents = '', bool $blog_m
$thr_parent_sql = " AND item.thr_parent IN (" . protect_sprintf($thr_parents) . ") ";
}
+ $thr_parent_uuid_sql = '';
+ $thr_parent_uuid_sql_join = '';
+
+ if (!$thread_allow) {
+ // this is required for navigation between replies if thread_allow is false
+ $thr_parent_uuid_sql = "tp.uuid AS thr_parent_uuid,";
+ $thr_parent_uuid_sql_join = "LEFT JOIN item tp ON item.thr_parent = tp.mid AND item.uid = tp.uid";
+ }
+
$ret = q(
"SELECT item.*,
+ $thr_parent_uuid_sql
$activity_sql
FROM item
LEFT JOIN item c
@@ -5469,6 +5479,7 @@ function items_by_parent_ids(string $ids, string $thr_parents = '', bool $blog_m
AND c.item_thread_top = 0
AND c.thr_parent = item.mid
$item_normal_c
+ $thr_parent_uuid_sql_join
WHERE $blog_mode_sql in (%s)
AND (
item.verb NOT IN ('Like', 'Dislike', 'Announce')