From 37fc460b25e7e0f22dc547702bddf4fd7fe03a97 Mon Sep 17 00:00:00 2001 From: n1rwana Date: Mon, 21 Aug 2023 12:45:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=D0=BA=D0=B8=20posts-edit=20(#958)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Редактирование постов * Log posts changes * Fixes * Features * Совместимость с логами --- Web/Presenters/WallPresenter.php | 35 ++++++++++++------- Web/Presenters/templates/Wall/Post.xml | 8 +++++ .../components/post/microblogpost.xml | 19 +++++++--- .../templates/components/post/oldpost.xml | 21 +++++++++-- .../templates/components/textArea.xml | 2 +- Web/routes.yml | 2 ++ Web/static/js/openvk.cls.js | 4 +-- 7 files changed, 69 insertions(+), 22 deletions(-) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 3e115ec7..9d01d42e 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -17,7 +17,7 @@ final class WallPresenter extends OpenVKPresenter function __construct(Posts $posts) { $this->posts = $posts; - + parent::__construct(); } @@ -207,7 +207,7 @@ final class WallPresenter extends OpenVKPresenter ]; } - function renderMakePost(int $wall): void + function renderMakePost(int $wall, ?int $editTarget = 0): void { $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); @@ -298,17 +298,28 @@ final class WallPresenter extends OpenVKPresenter if(empty($this->postParam("text")) && !$photo && !$video && !$poll && !$note) $this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big")); - + try { - $post = new Post; - $post->setOwner($this->user->id); - $post->setWall($wall); - $post->setCreated(time()); - $post->setContent($this->postParam("text")); - $post->setAnonymous($anon); - $post->setFlags($flags); - $post->setNsfw($this->postParam("nsfw") === "on"); - $post->save(); + if ($editTarget) { + $post = $this->posts->getPostById($this->user->id, $editTarget); + + $post->setEdited(time()); + $post->setContent($this->postParam("text")); + $post->setFlags($flags); + $post->setNsfw($this->postParam("nsfw") === "on"); + $post->save(); + } else { + $post = new Post; + $post->setOwner($this->user->id); + $post->setWall($wall); + $post->setCreated(time()); + $post->setContent($this->postParam("text")); + $post->setAnonymous($anon); + $post->setFlags($flags); + $post->setNsfw($this->postParam("nsfw") === "on"); + $post->save(); + } + } catch (\LengthException $ex) { $this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big")); } diff --git a/Web/Presenters/templates/Wall/Post.xml b/Web/Presenters/templates/Wall/Post.xml index 575c7bba..c6566709 100644 --- a/Web/Presenters/templates/Wall/Post.xml +++ b/Web/Presenters/templates/Wall/Post.xml @@ -34,6 +34,14 @@ {/if} {_delete} + + История изменений + {_report}