diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index f0a80fe7..f7416472 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -507,11 +507,10 @@ final class WallPresenter extends OpenVKPresenter if($_SERVER["REQUEST_METHOD"] !== "POST") $this->redirect("/id0"); - if($this->postParam("type") == "post") { + if($this->postParam("type") == "post") $post = $this->posts->get((int)$this->postParam("postid")); - } else { + else $post = (new Comments)->get((int)$this->postParam("postid")); - } if(!$post || $post->isDeleted()) $this->returnJson(["error" => "Invalid post"]); @@ -519,8 +518,18 @@ final class WallPresenter extends OpenVKPresenter if(!$post->canBeEditedBy($this->user->identity)) $this->returnJson(["error" => "Access denied"]); + $attachmentsCount = sizeof(iterator_to_array($post->getChildren())); + + if(empty($this->postParam("newContent")) && $attachmentsCount < 1) + $this->returnJson(["error" => "Empty post"]); + $post->setEdited(time()); - $post->setContent($this->postParam("newContent")); + + try { + $post->setContent($this->postParam("newContent")); + } catch(\LengthException $e) { + $this->returnJson(["error" => $e->getMessage()]); + } if($this->postParam("type") === "post") { $post->setNsfw($this->postParam("nsfw") == "true"); diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 93e209b0..9b54adce 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -358,6 +358,11 @@ $(document).on("click", "#editPost", (e) => { "&fromgroup="+(content.querySelector("#fromgroup") != null ? content.querySelector("#fromgroup").checked : 0)) }) + u(".editMenu").on("keydown", (e) => { + if(e.ctrlKey && e.keyCode === 13) + content.querySelector("#endEditing").click() + }); + text.style.display = "none" setupWallPostInputHandlers(999) } else {