implement pubstream items in mod hq
This commit is contained in:
parent
2108173e74
commit
4b2bd871b7
@ -125,12 +125,13 @@ class Hq extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
if($update && $_SESSION['loadtime'])
|
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']) . "' ) ";
|
$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)
|
if($static && $simple_update)
|
||||||
$simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
|
$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) {
|
if(! $update && ! $load) {
|
||||||
|
|
||||||
nav_set_selected('HQ');
|
nav_set_selected('HQ');
|
||||||
@ -183,34 +184,58 @@ class Hq extends \Zotlabs\Web\Controller {
|
|||||||
if($load) {
|
if($load) {
|
||||||
$r = null;
|
$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
|
WHERE uid = %d
|
||||||
and mid = '%s'
|
AND mid = '%s'
|
||||||
$item_normal
|
$item_normal
|
||||||
limit 1",
|
LIMIT 1",
|
||||||
intval(local_channel()),
|
intval(local_channel()),
|
||||||
dbesc($target_item['parent_mid'])
|
dbesc($target_item['parent_mid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
$updateable = true;
|
$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) {
|
elseif($update) {
|
||||||
$r = null;
|
$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
|
WHERE uid = %d
|
||||||
and parent_mid = '%s'
|
AND parent_mid = '%s'
|
||||||
$item_normal_update
|
$item_normal_update
|
||||||
$simple_update
|
$simple_update
|
||||||
limit 1",
|
LIMIT 1",
|
||||||
intval(local_channel()),
|
intval(local_channel()),
|
||||||
dbesc($target_item['parent_mid'])
|
dbesc($target_item['parent_mid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
$updateable = true;
|
$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();
|
$_SESSION['loadtime'] = datetime_convert();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -222,11 +247,11 @@ class Hq extends \Zotlabs\Web\Controller {
|
|||||||
if($parents_str) {
|
if($parents_str) {
|
||||||
$items = q("SELECT item.*, item.id AS item_id
|
$items = q("SELECT item.*, item.id AS item_id
|
||||||
FROM item
|
FROM item
|
||||||
WHERE parent in ( %s ) $item_normal ",
|
WHERE parent IN ( %s ) $item_normal ",
|
||||||
dbesc($parents_str)
|
dbesc($parents_str)
|
||||||
);
|
);
|
||||||
|
|
||||||
xchan_query($items);
|
xchan_query($items,true,local_channel());
|
||||||
$items = fetch_post_tags($items,true);
|
$items = fetch_post_tags($items,true);
|
||||||
$items = conv_sort($items,'created');
|
$items = conv_sort($items,'created');
|
||||||
}
|
}
|
||||||
@ -238,7 +263,7 @@ class Hq extends \Zotlabs\Web\Controller {
|
|||||||
$o .= conversation($items, 'hq', $update, 'client');
|
$o .= conversation($items, 'hq', $update, 'client');
|
||||||
|
|
||||||
if($updateable) {
|
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(local_channel()),
|
||||||
intval($r[0]['item_id'])
|
intval($r[0]['item_id'])
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $module == 'hq'}}
|
{{if $module == 'hq'}}
|
||||||
if(b64mid !== 'undefined' && path !== 'pubstre') {
|
if(b64mid !== 'undefined') {
|
||||||
{{else}}
|
{{else}}
|
||||||
if(path === 'display' && b64mid) {
|
if(path === 'display' && b64mid) {
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Reference in New Issue
Block a user