X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fwall_attach.php;h=0324a5581ca9a674d48ac08381edd6289e392964;hb=27eaffd7fb4713491dbb72410b0adc55d4c9a6aa;hp=c4ee33bd18f97468b614bc5c598db8fad5091688;hpb=854cc3e47296d4a1b01b893376064cf254d84f79;p=friendica.git diff --git a/mod/wall_attach.php b/mod/wall_attach.php index c4ee33bd18..0324a5581c 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\Model\Attach; use Friendica\Model\User; @@ -43,35 +44,21 @@ function wall_attach_post(App $a) { $page_owner_cid = $r[0]['id']; $community_page = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); - if ((local_user()) && (local_user() == $page_owner_uid)) { + if (local_user() && (local_user() == $page_owner_uid)) { $can_post = true; - } else { - if ($community_page && remote_user()) { - $contact_id = 0; - - if (is_array($_SESSION['remote'])) { - foreach ($_SESSION['remote'] as $v) { - if ($v['uid'] == $page_owner_uid) { - $contact_id = $v['cid']; - break; - } - } - } - - if ($contact_id > 0) { - $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval($page_owner_uid) - ); + } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) { + $contact_id = Session::getRemoteContactID($page_owner_uid); + $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($page_owner_uid) + ); - if (DBA::isResult($r)) { - $can_post = true; - } - } + if (DBA::isResult($r)) { + $can_post = true; } } - if (! $can_post) { + if (!$can_post) { if ($r_json) { echo json_encode(['error' => L10n::t('Permission denied.')]); exit();