Reshares are now working

This commit is contained in:
Michael 2017-12-20 18:18:25 +00:00
parent cdce9b48ab
commit f7272be4a8
3 changed files with 20 additions and 22 deletions

View file

@ -612,7 +612,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
if ($items && count($items)) { if ($items && count($items)) {
// Currently behind a config value. This allows the commenting and sharing of every public item. // 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)); $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA));
} else { } else {
$writable = false; $writable = false;

View file

@ -348,7 +348,7 @@ function display_content(App $a, $update = false, $update_uid = 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() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? 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);

View file

@ -4,28 +4,26 @@ use Friendica\App;
use Friendica\Database\DBM; use Friendica\Database\DBM;
function share_init(App $a) { function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if((! $post_id) || (! local_user())) if (!$post_id || !local_user()) {
killme(); killme();
}
$r = q("SELECT item.*, contact.network FROM `item` $r = q("SELECT item.*, contact.network FROM `item`
inner join contact on `item`.`contact-id` = `contact`.`id` INNER JOIN `contact` ON `item`.`contact-id` = `contact`.`id`
WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", WHERE `item`.`id` = %d LIMIT 1",
intval($post_id)
intval($post_id),
intval(local_user())
); );
if(! DBM::is_result($r) || ($r[0]['private'] == 1)) if (!DBM::is_result($r) || ($r[0]['private'] == 1)) {
killme(); killme();
}
if (strpos($r[0]['body'], "[/share]") !== false) { if (strpos($r[0]['body'], "[/share]") !== false) {
$pos = strpos($r[0]['body'], "[share"); $pos = strpos($r[0]['body'], "[share");
$o = substr($r[0]['body'], $pos); $o = substr($r[0]['body'], $pos);
} else { } 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']); $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 .= '[b]'.$r[0]['title'].'[/b]'."\n";
$o .= $r[0]['body']; $o .= $r[0]['body'];
$o.= "[/share]"; $o.= "[/share]";
@ -36,17 +34,17 @@ function share_init(App $a) {
} }
function share_header($author, $profile, $avatar, $guid, $posted, $link) { function share_header($author, $profile, $avatar, $guid, $posted, $link) {
$header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author). $header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $author).
"' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile). "' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $profile).
"' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar); "' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $avatar);
if ($guid) if ($guid) {
$header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid); $header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $guid);
}
if ($posted) if ($posted) {
$header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted); $header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $posted);
}
$header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']"; $header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"), $link)."']";
return $header; return $header;
} }