X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Fitem.php;h=1faef960163c7845bad16b15a814d58a747dd667;hb=54d598ce7c66308dbcf5d5aa0b14b3aec73885a8;hp=c35a48b7e71173ddb6ab56b0df04974294052955;hpb=5ba6c7717a06842c27fec15508ff8cabb3d9a31b;p=friendica.git diff --git a/mod/item.php b/mod/item.php index c35a48b7e7..1faef96016 100644 --- a/mod/item.php +++ b/mod/item.php @@ -29,7 +29,6 @@ use Friendica\Protocol\Diaspora; use Friendica\Protocol\Email; use Friendica\Util\Emailer; -require_once 'include/crypto.php'; require_once 'include/enotify.php'; require_once 'include/tags.php'; require_once 'include/files.php'; @@ -39,7 +38,7 @@ require_once 'include/items.php'; function item_post(App $a) { - if ((! local_user()) && (! remote_user()) && (! x($_REQUEST, 'commenter'))) { + if (!local_user() && !remote_user() && !x($_REQUEST, 'commenter')) { return; } @@ -81,8 +80,8 @@ function item_post(App $a) { } // Is this a reply to something? - $parent = ((x($_REQUEST, 'parent')) ? intval($_REQUEST['parent']) : 0); - $parent_uri = ((x($_REQUEST, 'parent_uri')) ? trim($_REQUEST['parent_uri']) : ''); + $parent = (x($_REQUEST, 'parent') ? intval($_REQUEST['parent']) : 0); + $parent_uri = (x($_REQUEST, 'parent_uri') ? trim($_REQUEST['parent_uri']) : ''); $parent_item = null; $parent_contact = null; @@ -122,7 +121,7 @@ function item_post(App $a) { } } - if (! DBM::is_result($r)) { + if (!DBM::is_result($r)) { notice( t('Unable to locate original post.') . EOL); if (x($_REQUEST, 'return')) { goaway($return_path); @@ -201,7 +200,7 @@ function item_post(App $a) { // First check that the parent exists and it is a wall item. - if ((x($_REQUEST, 'commenter')) && ((! $parent) || (! $parent_item['wall']))) { + if (x($_REQUEST, 'commenter') && (!$parent || !$parent_item['wall'])) { notice(t('Permission denied.') . EOL) ; if (x($_REQUEST, 'return')) { goaway($return_path); @@ -209,11 +208,14 @@ function item_post(App $a) { killme(); } + // Allow commenting if it is an answer to a public post + $allow_comment = ($profile_uid == 0) && $parent && in_array($parent_item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA]); + /* * Now check that it is a page_type of PAGE_BLOG, and that valid personal details * have been provided, and run any anti-spam plugins */ - if ((! can_write_wall($a, $profile_uid)) && (! $allow_moderated)) { + if (!(can_write_wall($a, $profile_uid) || $allow_comment) && !$allow_moderated) { notice(t('Permission denied.') . EOL) ; if (x($_REQUEST, 'return')) { goaway($return_path); @@ -377,11 +379,11 @@ function item_post(App $a) { $self = false; $contact_id = 0; - if ((local_user()) && (local_user() == $profile_uid)) { + if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) { $self = true; - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($_SESSION['uid'])); - } elseif(remote_user()) { + } elseif (remote_user()) { if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $v) { if ($v['uid'] == $profile_uid) { @@ -404,10 +406,10 @@ function item_post(App $a) { // get contact info for owner - if ($profile_uid == local_user()) { + if ($profile_uid == local_user() || $allow_comment) { $contact_record = $author; } else { - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($profile_uid) ); if (DBM::is_result($r)) {