aboutsummaryrefslogtreecommitdiffstats
path: root/mod/display.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/display.php')
-rw-r--r--mod/display.php68
1 files changed, 50 insertions, 18 deletions
diff --git a/mod/display.php b/mod/display.php
index 3c2172c7d..110dd1807 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -3,6 +3,8 @@
function display_content(&$a, $update = 0, $load = false) {
+ logger("mod-display: update = $update load = $load");
+
if(intval(get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
@@ -20,8 +22,10 @@ function display_content(&$a, $update = 0, $load = false) {
if(argc() > 1 && argv(1) !== 'load')
$item_hash = argv(1);
- if($_REQUEST['uri'])
- $item_hash = $_REQUEST['uri'];
+
+
+ if($_REQUEST['mid'])
+ $item_hash = $_REQUEST['mid'];
if(! $item_hash) {
@@ -43,7 +47,7 @@ function display_content(&$a, $update = 0, $load = false) {
$target_item = null;
- $r = q("select uri, parent_uri from item where uri = '%s' limit 1",
+ $r = q("select mid, parent_mid from item where mid = '%s' limit 1",
dbesc($item_hash)
);
@@ -55,7 +59,7 @@ function display_content(&$a, $update = 0, $load = false) {
$o .= '<div id="live-display"></div>' . "\r\n";
- $o .= "<script> var profile_uid = " . intval(local_user())
+ $o .= "<script> var profile_uid = " . ((intval(local_user())) ? local_user() : (-1))
. "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
@@ -79,7 +83,7 @@ function display_content(&$a, $update = 0, $load = false) {
'$cats' => '',
'$dend' => '',
'$dbegin' => '',
- '$uri' => $item_hash
+ '$mid' => $item_hash
));
@@ -90,20 +94,36 @@ function display_content(&$a, $update = 0, $load = false) {
if($update && $load) {
+ $updateable = false;
+
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
if($load) {
-
- $r = q("SELECT * from item
- WHERE item_restrict = 0
- and uri = '%s'
- AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
- AND `item`.`deny_gid` = '' AND item_private = 0 )
- and uid in ( " . stream_perms_api_uids() . " ))
- $sql_extra )
- group by uri limit 1",
- dbesc($target_item['parent_uri'])
- );
+ $r = null;
+ if(local_user()) {
+ $r = q("SELECT * from item
+ WHERE item_restrict = 0
+ and uid = %d
+ and mid = '%s'
+ limit 1",
+ intval(local_user()),
+ dbesc($target_item['parent_mid'])
+ );
+ if($r)
+ $updateable = true;
+ }
+ if($r === null) {
+ $r = q("SELECT * from item
+ WHERE item_restrict = 0
+ and mid = '%s'
+ AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
+ AND `item`.`deny_gid` = '' AND item_private = 0 )
+ and uid in ( " . stream_perms_api_uids() . " ))
+ $sql_extra )
+ group by mid limit 1",
+ dbesc($target_item['parent_mid'])
+ );
+ }
}
else {
@@ -131,14 +151,26 @@ function display_content(&$a, $update = 0, $load = false) {
}
- $o .= conversation($a,$items,'display', $update, 'client');
+
+ $o .= conversation($a, $items, 'display', $update, 'client');
+
+ if($updateable) {
+ $x = q("UPDATE item SET item_flags = ( item_flags ^ %d )
+ WHERE (item_flags & %d) AND uid = %d and parent = %d ",
+ intval(ITEM_UNSEEN),
+ intval(ITEM_UNSEEN),
+ intval(local_user()),
+ intval($r[0]['parent'])
+ );
+ }
+
return $o;
/*
elseif((! $update) && (! {
- $r = q("SELECT `id`, item_flags FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
+ $r = q("SELECT `id`, item_flags FROM `item` WHERE `id` = '%s' OR `mid` = '%s' LIMIT 1",
dbesc($item_hash),
dbesc($item_hash)
);