From cb902b77684192c6efce99c7959ccd06b9467567 Mon Sep 17 00:00:00 2001
From: celestora <kitsuruko@gmail.com>
Date: Wed, 3 Aug 2022 21:01:36 +0300
Subject: [PATCH] Throw error if user attempts to set incorrect s-code for club

Resolves #621
---
 Web/Presenters/GroupPresenter.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php
index 101e71b3..7b551859 100644
--- a/Web/Presenters/GroupPresenter.php
+++ b/Web/Presenters/GroupPresenter.php
@@ -199,10 +199,12 @@ final class GroupPresenter extends OpenVKPresenter
             $this->template->club = $club;
             
         if($_SERVER["REQUEST_METHOD"] === "POST") {
+	    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->setAbout(empty($this->postParam("about")) ? NULL : $this->postParam("about"));
-            $club->setShortcode(empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode"));
-	        $club->setWall(empty($this->postParam("wall")) ? 0 : 1);
+	    $club->setWall(empty($this->postParam("wall")) ? 0 : 1);
             $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display"));
 	    $club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1);
             $club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1);