implement pubstream items in mod hq

This commit is contained in:
Mario 2017-11-25 10:44:47 +01:00
parent 2108173e74
commit 4b2bd871b7
2 changed files with 37 additions and 12 deletions

View File

@ -125,12 +125,13 @@ 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) {
nav_set_selected('HQ');
@ -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'])
);

View File

@ -36,7 +36,7 @@
{{/if}}
{{if $module == 'hq'}}
if(b64mid !== 'undefined' && path !== 'pubstre') {
if(b64mid !== 'undefined') {
{{else}}
if(path === 'display' && b64mid) {
{{/if}}