From 4a65096e6473a0bc42469e223f270f343c990e94 Mon Sep 17 00:00:00 2001 From: n1rwana Date: Wed, 9 Aug 2023 15:50:04 +0300 Subject: [PATCH] Clubs&Albums: Fix of empty names of albums and clubs (#936) --- Web/Presenters/GroupPresenter.php | 4 ++-- Web/Presenters/PhotosPresenter.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 4f671df3..3e0d8c6e 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -39,7 +39,7 @@ final class GroupPresenter extends OpenVKPresenter $this->willExecuteWriteAction(); if($_SERVER["REQUEST_METHOD"] === "POST") { - if(!empty($this->postParam("name"))) + if(!empty($this->postParam("name")) && mb_strlen(trim($this->postParam("name"))) > 0) { $club = new Club; $club->setName($this->postParam("name")); @@ -201,7 +201,7 @@ final class GroupPresenter extends OpenVKPresenter if(!$club->setShortcode( empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode") )) $this->flashFail("err", tr("error"), tr("error_shorturl_incorrect")); - $club->setName(empty($this->postParam("name")) ? $club->getName() : $this->postParam("name")); + $club->setName((empty($this->postParam("name")) || mb_strlen(trim($this->postParam("name"))) === 0) ? $club->getName() : $this->postParam("name")); $club->setAbout(empty($this->postParam("about")) ? NULL : $this->postParam("about")); $club->setWall(empty($this->postParam("wall")) ? 0 : 1); $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display")); diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php index 02d6ae46..345b2c60 100644 --- a/Web/Presenters/PhotosPresenter.php +++ b/Web/Presenters/PhotosPresenter.php @@ -66,7 +66,7 @@ final class PhotosPresenter extends OpenVKPresenter } if($_SERVER["REQUEST_METHOD"] === "POST") { - if(empty($this->postParam("name"))) + if(empty($this->postParam("name")) || mb_strlen(trim($this->postParam("name"))) === 0) $this->flashFail("err", tr("error"), tr("error_segmentation")); else if(strlen($this->postParam("name")) > 36) $this->flashFail("err", tr("error"), tr("error_data_too_big", "name", 36, "bytes")); @@ -101,7 +101,7 @@ final class PhotosPresenter extends OpenVKPresenter if(strlen($this->postParam("name")) > 36) $this->flashFail("err", tr("error"), tr("error_data_too_big", "name", 36, "bytes")); - $album->setName(empty($this->postParam("name")) ? $album->getName() : $this->postParam("name")); + $album->setName((empty($this->postParam("name")) || mb_strlen(trim($this->postParam("name"))) === 0) ? $album->getName() : $this->postParam("name")); $album->setDescription(empty($this->postParam("desc")) ? NULL : $this->postParam("desc")); $album->setEdited(time()); $album->save();