diff options
author | Mario <mario@mariovavti.com> | 2025-04-30 14:42:09 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2025-04-30 14:42:09 +0000 |
commit | e5cd6330b37cb322842a7bc558b62a3497eb7f08 (patch) | |
tree | 930a2f9cbc009dff8bda057b0740edfbe32f030f /Zotlabs/Module | |
parent | e91021f648fee8039d073c6607f438737db8d703 (diff) | |
download | volse-hubzilla-e5cd6330b37cb322842a7bc558b62a3497eb7f08.tar.gz volse-hubzilla-e5cd6330b37cb322842a7bc558b62a3497eb7f08.tar.bz2 volse-hubzilla-e5cd6330b37cb322842a7bc558b62a3497eb7f08.zip |
default to threaded
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Channel.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 26 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 31 | ||||
-rw-r--r-- | Zotlabs/Module/Network.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Pubstream.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Viewsrc.php | 32 |
6 files changed, 72 insertions, 23 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index d8b503b37..079694247 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -410,7 +410,7 @@ class Channel extends Controller { if ($r) { $parents_str = ids_to_querystr($r, 'item_id'); - $r = items_by_parent_ids($parents_str, $sql_extra); + $r = items_by_parent_ids($parents_str); xchan_query($r); $items = fetch_post_tags($r, true); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 227e47e64..20fb96983 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -291,7 +291,31 @@ class Display extends Controller { $parents_str = ids_to_querystr($r,'item_id'); if($parents_str) { - $items = items_by_parent_ids($parents_str, $sql_extra); + $thr_parents[] = $target_item['thr_parent']; + + if (Config::Get('system', 'thread_allow', true)) { + $_mid = $target_item['thr_parent']; + $_parent_mid = $target_item['parent_mid']; + $_uid = $target_item['uid']; + $_i = 0; + + // Find the thr_parents we need to show when we need to show a nested comment + // TODO: can this be improved or maybe implemented differently in the UI? + while ($_mid !== $target_item['parent_mid'] && $_i < 100) { + $x = q("SELECT thr_parent, mid FROM item WHERE uid = %d AND mid = '%s'", + intval($_uid), + dbesc($_mid) + ); + + $_mid = $x[0]['thr_parent']; + $thr_parents[] = $x[0]['thr_parent']; + $_i++; + } + } + + $thr_parents_str = stringify_array($thr_parents, true); + + $items = items_by_parent_ids($parents_str, $thr_parents_str); xchan_query($items); $items = fetch_post_tags($items,true); diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 235ff28d7..062a6f0e7 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -3,6 +3,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Widget\Messages; +use Zotlabs\Lib\Config; class Hq extends \Zotlabs\Web\Controller { @@ -50,12 +51,13 @@ class Hq extends \Zotlabs\Web\Controller { // select the target item with a bias to our own item $sql_order = ((local_channel() > $sys['channel_id']) ? 'DESC' : 'ASC'); - $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where uid in (%d, %d) and $identifier = '%s' order by uid $sql_order limit 2", + $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where uid in (%d, %d) and $identifier = '%s' order by uid $sql_order limit 2", intval(local_channel()), intval($sys['channel_id']), dbesc($item_hash) ); + if($r) { $target_item = $r[0]; if (intval($target_item['uid']) === intval($sys['channel_id'])) { @@ -145,7 +147,6 @@ class Hq extends \Zotlabs\Web\Controller { } if($load && $target_item) { - if (!$sys_item) { $r = q("SELECT item.id AS item_id FROM item WHERE uid = %d @@ -199,7 +200,31 @@ class Hq extends \Zotlabs\Web\Controller { } if($r) { - $items = items_by_parent_ids($r[0]['item_id'], $sql_extra); + $thr_parents[] = $target_item['thr_parent']; + + if (Config::Get('system', 'thread_allow', true)) { + $_mid = $target_item['thr_parent']; + $_parent_mid = $target_item['parent_mid']; + $_uid = $target_item['uid']; + $_i = 0; + + // Find the thr_parents we need to show when we need to show a nested comment + // TODO: can this be improved or maybe implemented differently in the UI? + while ($_mid !== $target_item['parent_mid'] && $_i < 100) { + $x = q("SELECT thr_parent, mid FROM item WHERE uid = %d AND mid = '%s'", + intval($_uid), + dbesc($_mid) + ); + + $_mid = $x[0]['thr_parent']; + $thr_parents[] = $x[0]['thr_parent']; + $_i++; + } + } + + $thr_parents_str = stringify_array($thr_parents, true); + + $items = items_by_parent_ids($r[0]['item_id'], $thr_parents_str); xchan_query($items,true,(($sys_item) ? local_channel() : 0)); $items = fetch_post_tags($items,true); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index f32a85068..43ddac50e 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -511,7 +511,7 @@ class Network extends \Zotlabs\Web\Controller { if($r) { $parents_str = ids_to_querystr($r, 'item_id'); - $items = items_by_parent_ids($parents_str, $sql_extra); + $items = items_by_parent_ids($parents_str); xchan_query($items, true); $items = fetch_post_tags($items, true); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 1f349ae1c..dfc8a4c4f 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -254,7 +254,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $parents_str = ids_to_querystr($r,'item_id'); - $items = items_by_parent_ids($parents_str, $sql_extra); + $items = items_by_parent_ids($parents_str); // use effective_uid param of xchan_query to help sort out comment permission // for sys_channel owned items. diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php index 3e49b9db4..cfc184a9d 100644 --- a/Zotlabs/Module/Viewsrc.php +++ b/Zotlabs/Module/Viewsrc.php @@ -6,34 +6,34 @@ namespace Zotlabs\Module; class Viewsrc extends \Zotlabs\Web\Controller { function get() { - + $o = ''; - + $sys = get_sys_channel(); - + $item_id = ((argc() > 1) ? intval(argv(1)) : 0); $json = ((argc() > 2 && argv(2) === 'json') ? true : false); $dload = ((argc() > 2 && argv(2) === 'download') ? true : false); - + if(! local_channel()) { notice( t('Permission denied.') . EOL); } - - + + if(! $item_id) { \App::$error = 404; notice( t('Item not found.') . EOL); } - + $item_normal = item_normal_search(); - + if(local_channel() && $item_id) { - $r = q("select id, mid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1", + $r = q("select id, mid, uuid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id) ); - + if($r) { if(intval($r[0]['item_obscured'])) $dload = true; @@ -50,18 +50,18 @@ class Viewsrc extends \Zotlabs\Web\Controller { $o = (($json) ? json_encode($content) : $content); } } - + if(is_ajax()) { echo '<div class="p-1">'; - echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a><br>mid: ' . $r[0]['mid'] . '</div>'; + echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a><br>mid: ' . $r[0]['mid'] . '<br>uuid: ' . $r[0]['uuid'] . '</div>'; echo '<hr>'; echo '<pre class="p-1">' . $o . '</pre>'; echo '</div>'; killme(); - } - + } + return $o; } - - + + } |