aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2017-11-25 10:44:47 +0100
committerMario <mario@mariovavti.com>2017-11-25 10:44:47 +0100
commit4b2bd871b765e0287f329ad398a15f20cb6a6425 (patch)
treece5d3bbf1c23b8c4f2274788121d6f3e82c02258 /Zotlabs/Module
parent2108173e74c12ce590c87e673d3455f7a9b18de8 (diff)
downloadvolse-hubzilla-4b2bd871b765e0287f329ad398a15f20cb6a6425.tar.gz
volse-hubzilla-4b2bd871b765e0287f329ad398a15f20cb6a6425.tar.bz2
volse-hubzilla-4b2bd871b765e0287f329ad398a15f20cb6a6425.zip
implement pubstream items in mod hq
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Hq.php47
1 files changed, 36 insertions, 11 deletions
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 08f4ddda5..c5b3ced3e 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -125,11 +125,12 @@ class Hq extends \Zotlabs\Web\Controller {
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
- if($load)
- $simple_update = '';
if($static && $simple_update)
$simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
+
+ $sys = get_sys_channel();
+ $sql_extra = item_permissions_sql($sys['channel_id']);
if(! $update && ! $load) {
@@ -183,34 +184,58 @@ class Hq extends \Zotlabs\Web\Controller {
if($load) {
$r = null;
- $r = q("SELECT item.id as item_id from item
+ $r = q("SELECT item.id AS item_id FROM item
WHERE uid = %d
- and mid = '%s'
+ AND mid = '%s'
$item_normal
- limit 1",
+ LIMIT 1",
intval(local_channel()),
dbesc($target_item['parent_mid'])
);
+
if($r) {
$updateable = true;
}
+
+ if(!$r) {
+ $r = q("SELECT item.id AS item_id FROM item
+ LEFT JOIN abook ON item.author_xchan = abook.abook_xchan
+ WHERE mid = '%s' AND item.uid = %d $item_normal
+ AND (abook.abook_blocked = 0 or abook.abook_flags is null)
+ $sql_extra LIMIT 1",
+ dbesc($target_item['parent_mid']),
+ intval($sys['channel_id'])
+ );
+ }
}
elseif($update) {
$r = null;
- $r = q("SELECT item.parent AS item_id from item
+ $r = q("SELECT item.parent AS item_id FROM item
WHERE uid = %d
- and parent_mid = '%s'
+ AND parent_mid = '%s'
$item_normal_update
$simple_update
- limit 1",
+ LIMIT 1",
intval(local_channel()),
dbesc($target_item['parent_mid'])
);
+
if($r) {
$updateable = true;
}
+ if(!$r) {
+ $r = q("SELECT item.parent AS item_id FROM item
+ LEFT JOIN abook ON item.author_xchan = abook.abook_xchan
+ WHERE mid = '%s' AND item.uid = %d $item_normal_update $simple_update
+ AND (abook.abook_blocked = 0 or abook.abook_flags is null)
+ $sql_extra LIMIT 1",
+ dbesc($target_item['parent_mid']),
+ intval($sys['channel_id'])
+ );
+ }
+
$_SESSION['loadtime'] = datetime_convert();
}
else {
@@ -222,11 +247,11 @@ class Hq extends \Zotlabs\Web\Controller {
if($parents_str) {
$items = q("SELECT item.*, item.id AS item_id
FROM item
- WHERE parent in ( %s ) $item_normal ",
+ WHERE parent IN ( %s ) $item_normal ",
dbesc($parents_str)
);
- xchan_query($items);
+ xchan_query($items,true,local_channel());
$items = fetch_post_tags($items,true);
$items = conv_sort($items,'created');
}
@@ -238,7 +263,7 @@ class Hq extends \Zotlabs\Web\Controller {
$o .= conversation($items, 'hq', $update, 'client');
if($updateable) {
- $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ",
+ $x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d AND parent = %d ",
intval(local_channel()),
intval($r[0]['item_id'])
);