From c2cdd41e8139068426175c9e6c5fe2f771ea7caf Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 9 Mar 2016 10:04:33 +0100 Subject: Issue #316 make /display updates work. Basically copy and paste what we do on load and add $simple_update to the query. --- mod/display.php | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index b2d9ba34b..ac1de17ca 100644 --- a/mod/display.php +++ b/mod/display.php @@ -116,7 +116,7 @@ function display_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update .= " and 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 = ''; @@ -217,9 +217,54 @@ function display_content(&$a, $update = 0, $load = false) { } } - else { - $r = array(); + } + + elseif($update && !$load) { + $r = null; + + require_once('include/identity.php'); + $sys = get_sys_channel(); + $sysid = $sys['channel_id']; + + if(local_channel()) { + $r = q("SELECT * from item + WHERE uid = %d + and mid = '%s' + $item_normal + $simple_update + limit 1", + intval(local_channel()), + dbesc($target_item['parent_mid']) + ); + if($r) { + $updateable = true; + } } + if($r === null) { + // in case somebody turned off public access to sys channel content using permissions + // make that content unsearchable by ensuring the owner_xchan can't match + if(! perm_is_allowed($sysid,$observer_hash,'view_stream')) + $sysid = 0; + + $r = q("SELECT * from item + WHERE mid = '%s' + AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' + AND `item`.`deny_gid` = '' AND item_private = 0 ) + and owner_xchan in ( " . stream_perms_xchans(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) + OR uid = %d ) + $sql_extra ) + $item_normal + $simple_update + limit 1", + dbesc($target_item['parent_mid']), + intval($sysid) + ); + } + $_SESSION['loadtime'] = datetime_convert(); + } + + else { + $r = array(); } if($r) { -- cgit v1.2.3 From 4e9440396cbff64e1ffbe3025a2e02baeb41f9c0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 11 Mar 2016 10:54:04 +0100 Subject: remove superfluous return --- mod/display.php | 1 - 1 file changed, 1 deletion(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index ac1de17ca..40427846b 100644 --- a/mod/display.php +++ b/mod/display.php @@ -329,6 +329,5 @@ function display_content(&$a, $update = 0, $load = false) { } */ - return $o; } -- cgit v1.2.3 From 9abd95fad3784a10fc48bc40f9b8a75d7d74edda Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 31 Mar 2016 16:06:03 -0700 Subject: static App --- mod/display.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index 40427846b..e4a6a0e66 100644 --- a/mod/display.php +++ b/mod/display.php @@ -21,7 +21,7 @@ function display_content(&$a, $update = 0, $load = false) { require_once('include/items.php'); - $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array()); + App::$page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array()); if(argc() > 1 && argv(1) !== 'load') $item_hash = argv(1); @@ -32,7 +32,7 @@ function display_content(&$a, $update = 0, $load = false) { if(! $item_hash) { - $a->error = 404; + App::$error = 404; notice( t('Item not found.') . EOL); return; } @@ -42,7 +42,7 @@ function display_content(&$a, $update = 0, $load = false) { if(local_channel() && (! $update)) { - $channel = $a->get_channel(); + $channel = App::get_channel(); $channel_acl = array( @@ -127,9 +127,9 @@ function display_content(&$a, $update = 0, $load = false) { $o .= '
' . "\r\n"; $o .= "\r\n"; + . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; \r\n"; - $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( + App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), '$pgtype' => 'display', '$uid' => '0', @@ -144,7 +144,7 @@ function display_content(&$a, $update = 0, $load = false) { '$fh' => '0', '$nouveau' => '0', '$wall' => '0', - '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1), + '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1), '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), '$search' => '', '$order' => '', @@ -169,7 +169,7 @@ function display_content(&$a, $update = 0, $load = false) { $updateable = false; - $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']),intval($a->pager['start'])); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start'])); if($load || ($_COOKIE['jsAvailable'] != 1)) { $r = null; @@ -292,7 +292,7 @@ function display_content(&$a, $update = 0, $load = false) { } else { $o .= conversation($a, $items, 'display', $update, 'traditional'); if ($items[0]['title']) - $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; + App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; } -- cgit v1.2.3 From 46ed79c87a23f442eadc4244b62a6f85f3d431e8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 9 Apr 2016 12:27:36 +0200 Subject: fix autocomplete for /channel and /display --- mod/display.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index e4a6a0e66..ef140d454 100644 --- a/mod/display.php +++ b/mod/display.php @@ -65,7 +65,10 @@ function display_content(&$a, $update = 0, $load = false) { 'visitor' => true, 'profile_uid' => local_channel(), 'return_path' => 'channel/' . $channel['channel_address'], - 'expanded' => true + 'expanded' => true, + 'editor_autocomplete' => true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true ); $o = '
'; -- cgit v1.2.3 From 91cc36514306e827c126ceed6c17486c85f5544c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 12 Apr 2016 22:55:26 -0700 Subject: reverse the logic of the jsenabled setting so that sessions without js are performance penalised instead of regular sessions. --- mod/display.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index ef140d454..9c50eb9c0 100644 --- a/mod/display.php +++ b/mod/display.php @@ -168,13 +168,13 @@ function display_content(&$a, $update = 0, $load = false) { $sql_extra = public_permissions_sql($observer_hash); - if(($update && $load) || ($_COOKIE['jsAvailable'] != 1)) { + if(($update && $load) || ($_COOKIE['jsdisabled'] == 1)) { $updateable = false; $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start'])); - if($load || ($_COOKIE['jsAvailable'] != 1)) { + if($load || ($_COOKIE['jsdisabled'] == 1)) { $r = null; require_once('include/identity.php'); @@ -290,13 +290,13 @@ function display_content(&$a, $update = 0, $load = false) { } - if ($_COOKIE['jsAvailable'] == 1) { - $o .= conversation($a, $items, 'display', $update, 'client'); - } else { + if ($_COOKIE['jsdisabled'] == 1) { $o .= conversation($a, $items, 'display', $update, 'traditional'); if ($items[0]['title']) App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; - + } + else { + $o .= conversation($a, $items, 'display', $update, 'client'); } if($updateable) { -- cgit v1.2.3 From 9a0b61e4afed94727679eee966afb76e1add2beb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 13 Apr 2016 16:31:06 -0700 Subject: refactor the js detection into a checkjs class which is only enabled on demand (currently only the channel and display pages). Will probably require a bit more work to hide/disable the cover photo when js is disabled. Have not actually tested without js to discover any other potential page issues. Have only confirmed that the detection class works and redirects to set a jsdisabled cookie and reload the page with that cookie+variable set if called from the channel page. --- mod/display.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'mod/display.php') diff --git a/mod/display.php b/mod/display.php index 9c50eb9c0..2844a1205 100644 --- a/mod/display.php +++ b/mod/display.php @@ -5,6 +5,10 @@ function display_content(&$a, $update = 0, $load = false) { // logger("mod-display: update = $update load = $load"); + + $checkjs = new Zotlabs\Web\CheckJS(); + + if($load) $_SESSION['loadtime'] = datetime_convert(); @@ -168,13 +172,13 @@ function display_content(&$a, $update = 0, $load = false) { $sql_extra = public_permissions_sql($observer_hash); - if(($update && $load) || ($_COOKIE['jsdisabled'] == 1)) { + if(($update && $load) || ($checkjs->disabled())) { $updateable = false; $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start'])); - if($load || ($_COOKIE['jsdisabled'] == 1)) { + if($load || ($checkjs->disabled())) { $r = null; require_once('include/identity.php'); @@ -290,7 +294,7 @@ function display_content(&$a, $update = 0, $load = false) { } - if ($_COOKIE['jsdisabled'] == 1) { + if ($checkjs->disabled()) { $o .= conversation($a, $items, 'display', $update, 'traditional'); if ($items[0]['title']) App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; -- cgit v1.2.3