Updating after post does now work

This commit is contained in:
Michael 2017-12-20 10:16:25 +00:00
parent fa8a09d977
commit 343f22e02f
3 changed files with 16 additions and 13 deletions

View file

@ -611,9 +611,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$page_template = get_markup_template("conversation.tpl"); $page_template = get_markup_template("conversation.tpl");
if ($items && count($items)) { if ($items && count($items)) {
// Currently disabled. This is a preparation for the ability to comment and share every public item. // Currently behind a config value. This allows the commenting and sharing of every public item.
// $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA)); if (Config::get('system', 'comment_public')) {
$writable = false; $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA));
} else {
$writable = false;
}
if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {

View file

@ -205,9 +205,9 @@ function display_fetchauthor($a, $item) {
return($profiledata); return($profiledata);
} }
function display_content(App $a, $update = 0) { function display_content(App $a, $update = false, $update_uid = 0) {
if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) { if (Config::get('system','block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL); notice(t('Public access denied.') . EOL);
return; return;
} }
@ -227,7 +227,8 @@ function display_content(App $a, $update = 0) {
if ($update) { if ($update) {
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$a->profile = array('uid' => intval($update), 'profile_uid' => intval($update)); $item = dba::select('item', ['uid'], ['id' => $item_id], ['limit' => 1]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
} else { } else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0); $item_id = (($a->argc > 2) ? $a->argv[2] : 0);
@ -347,9 +348,9 @@ function display_content(App $a, $update = 0) {
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$a->page_contact = $r; $a->page_contact = $r;
} }
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); $is_owner = (local_user() && (local_user() == $a->profile['profile_uid']) ? true : false);
if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) { if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
notice(t('Access to this profile has been restricted.') . EOL); notice(t('Access to this profile has been restricted.') . EOL);
return; return;
} }
@ -375,10 +376,9 @@ function display_content(App $a, $update = 0) {
$sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups); $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
if ($update) { if ($update) {
$r = dba::p("SELECT `id` FROM `item` WHERE `item`.`uid` = ? $r = dba::p("SELECT `id` FROM `item` WHERE
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = ?) `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = ?)
$sql_extra AND `unseen`", $sql_extra AND `unseen`",
$a->profile['uid'],
$item_id $item_id
); );
@ -429,7 +429,7 @@ function display_content(App $a, $update = 0) {
if (!$update) { if (!$update) {
$o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>"; $o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
} }
$o .= conversation($a, $items, 'display', $update); $o .= conversation($a, $items, 'display', $update_uid);
// Preparing the meta header // Preparing the meta header
require_once('include/bbcode.php'); require_once('include/bbcode.php');

View file

@ -15,7 +15,7 @@ function update_display_content(App $a)
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>"; echo "<section>";
$text = display_content($a, $profile_uid); $text = display_content($a, true, $profile_uid);
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);