From f7272be4a84df43756ec77afd9762d2d47b94e2d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Dec 2017 18:18:25 +0000 Subject: [PATCH] Reshares are now working --- include/conversation.php | 2 +- mod/display.php | 2 +- mod/share.php | 38 ++++++++++++++++++-------------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index daee67493..ee68d8f5c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -612,7 +612,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { if ($items && count($items)) { // Currently behind a config value. This allows the commenting and sharing of every public item. - if (Config::get('system', 'comment_public')) { + if (Config::get('system', 'comment_public') && local_user()) { $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA)); } else { $writable = false; diff --git a/mod/display.php b/mod/display.php index 012bc5e61..094fb30c7 100644 --- a/mod/display.php +++ b/mod/display.php @@ -348,7 +348,7 @@ function display_content(App $a, $update = false, $update_uid = 0) { if (DBM::is_result($r)) { $a->page_contact = $r; } - $is_owner = (local_user() && (local_user() == $a->profile['profile_uid']) ? true : false); + $is_owner = (local_user() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? true : false); if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) { notice(t('Access to this profile has been restricted.') . EOL); diff --git a/mod/share.php b/mod/share.php index 864199f01..e97fa82dc 100644 --- a/mod/share.php +++ b/mod/share.php @@ -4,28 +4,26 @@ use Friendica\App; use Friendica\Database\DBM; function share_init(App $a) { - $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if((! $post_id) || (! local_user())) + if (!$post_id || !local_user()) { killme(); + } $r = q("SELECT item.*, contact.network FROM `item` - inner join contact on `item`.`contact-id` = `contact`.`id` - WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", - - intval($post_id), - intval(local_user()) + INNER JOIN `contact` ON `item`.`contact-id` = `contact`.`id` + WHERE `item`.`id` = %d LIMIT 1", + intval($post_id) ); - if(! DBM::is_result($r) || ($r[0]['private'] == 1)) + if (!DBM::is_result($r) || ($r[0]['private'] == 1)) { killme(); - + } if (strpos($r[0]['body'], "[/share]") !== false) { $pos = strpos($r[0]['body'], "[share"); $o = substr($r[0]['body'], $pos); } else { $o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']); - if($r[0]['title']) + if ($r[0]['title']) $o .= '[b]'.$r[0]['title'].'[/b]'."\n"; $o .= $r[0]['body']; $o.= "[/share]"; @@ -36,17 +34,17 @@ function share_init(App $a) { } function share_header($author, $profile, $avatar, $guid, $posted, $link) { - $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author). - "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile). - "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar); + $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $author). + "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $profile). + "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $avatar); - if ($guid) - $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid); - - if ($posted) - $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted); - - $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']"; + if ($guid) { + $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $guid); + } + if ($posted) { + $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $posted); + } + $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $link)."']"; return $header; }