diff --git a/Web/Models/Entities/Report.php b/Web/Models/Entities/Report.php index 1d345fd40..ae1d9a276 100644 --- a/Web/Models/Entities/Report.php +++ b/Web/Models/Entities/Report.php @@ -90,9 +90,15 @@ public function getContentObject() } } - public function getAuthor(): RowModel + public function getAuthor(?bool $realPostAuthor = false): RowModel { - return $this->getContentObject()->getOwner(); + if ($this->getContentType() == "user") + return $this->getContentObject(); + + if (!in_array($this->getContentType(), ["post", "comment", "note", "topic"])) + return $this->getContentObject()->getOwner(); + + return $this->getContentObject()->getOwner(!$realPostAuthor, $realPostAuthor); } public function getReportAuthor(): User @@ -103,7 +109,7 @@ public function getReportAuthor(): User public function banUser($initiator) { $reason = $this->getContentType() !== "user" ? ("**content-" . $this->getContentType() . "-" . $this->getContentId() . "**") : ("Подозрительная активность"); - $this->getAuthor()->ban($reason, false, time() + $this->getAuthor()->getNewBanTime(), $initiator); + $this->getAuthor()->ban($reason, false, time() + $this->getAuthor(true)->getNewBanTime(), $initiator); } public function deleteContent() diff --git a/Web/Presenters/ReportPresenter.php b/Web/Presenters/ReportPresenter.php index 19254ab08..3347374eb 100644 --- a/Web/Presenters/ReportPresenter.php +++ b/Web/Presenters/ReportPresenter.php @@ -134,6 +134,25 @@ public function renderAction(int $id): void if (!$report || $report->isDeleted()) { $this->notFound(); } + + if ($report->getContentType() === "user" && $this->postParam("excludeUserFromGlobalFeed")) { + $reportedUser = $report->getContentObject(); + $reportedUser->setHide_Global_Feed(1); + $reportedUser->save(); + } + + if ($report->getContentType() !== "user" && $this->postParam("excludeAuthorFromGlobalFeed")) { + $reportedContentAuthor = $report->getAuthor(true); + $reportedContentAuthor->setHide_Global_Feed(1); + $reportedContentAuthor->save(); + } + + if (($report->getContentType() === "group" || $report->getAuthor()->getId() != $report->getAuthor(true)->getId()) && $this->postParam("excludeGroupFromGlobalFeed")) { + $reportedGroup = $report->getContentType() === "group" ? $report->getContentObject() : $report->getAuthor(); + $reportedGroup->setHide_From_Global_Feed(1); + $reportedGroup->setEnforce_Hiding_From_Global_Feed(1); + $reportedGroup->save(); + } if ($this->postParam("ban")) { $report->deleteContent(); diff --git a/Web/Presenters/templates/Report/View.xml b/Web/Presenters/templates/Report/View.xml index 6731ee534..bcf378f34 100644 --- a/Web/Presenters/templates/Report/View.xml +++ b/Web/Presenters/templates/Report/View.xml @@ -17,8 +17,19 @@ {_comment}: {$report->getReason()}
{include "ViewContent.xml", type => $report->getContentType(), object => $report->getContentObject()} -