From 28e24fff93240ccaaaa9c9bc3865a6a6398d5af2 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Mon, 8 Nov 2021 18:53:37 +0200 Subject: [PATCH] Add the ability to specify the website of users and groups --- Web/Presenters/GroupPresenter.php | 5 +++++ Web/Presenters/UserPresenter.php | 5 +++++ Web/Presenters/templates/Group/Edit.xml | 8 ++++++++ Web/Presenters/templates/Group/View.xml | 8 ++++++++ Web/Presenters/templates/User/Edit.xml | 8 ++++++++ Web/Presenters/templates/User/View.xml | 8 ++++++++ install/sqls/00008-website-contact.sql | 2 ++ locales | 2 +- 8 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 install/sqls/00008-website-contact.sql diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 16ac32ea..541c95ed 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -170,6 +170,11 @@ final class GroupPresenter extends OpenVKPresenter $club->setShortcode(empty($this->postParam("shortcode")) ? NULL : $this->postParam("shortcode")); $club->setWall(empty($this->postParam("wall")) ? 0 : 1); $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display")); + if(strpos($this->postParam("website") ?? "", "https://") === 0 || strpos($this->postParam("website") ?? "", "http://") === 0) { + $club->setWebsite(empty($this->postParam("website")) ? NULL : $this->postParam("website")); + } else { + $club->setWebsite(empty($this->postParam("website")) ? NULL : "http://" . $this->postParam("website")); + } if($_FILES["ava"]["error"] === UPLOAD_ERR_OK) { $photo = new Photo; diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 1bf2ddbd..fe60b3ac 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -125,6 +125,11 @@ final class UserPresenter extends OpenVKPresenter $user->setTelegram(empty($this->postParam("telegram")) ? NULL : $this->postParam("telegram")); $user->setCity(empty($this->postParam("city")) ? NULL : $this->postParam("city")); $user->setAddress(empty($this->postParam("address")) ? NULL : $this->postParam("address")); + if(strpos($this->postParam("website") ?? "", "https://") === 0 || strpos($this->postParam("website") ?? "", "http://") === 0) { + $user->setWebsite(empty($this->postParam("website")) ? NULL : $this->postParam("website")); + } else { + $user->setWebsite(empty($this->postParam("website")) ? NULL : "http://" . $this->postParam("website")); + } } elseif($_GET['act'] === "interests") { $user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300)); $user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300)); diff --git a/Web/Presenters/templates/Group/Edit.xml b/Web/Presenters/templates/Group/Edit.xml index aaaeefee..204313f1 100644 --- a/Web/Presenters/templates/Group/Edit.xml +++ b/Web/Presenters/templates/Group/Edit.xml @@ -53,6 +53,14 @@ + + + {_website}: + + + + + {_avatar}: diff --git a/Web/Presenters/templates/Group/View.xml b/Web/Presenters/templates/Group/View.xml index af761183..9972776e 100644 --- a/Web/Presenters/templates/Group/View.xml +++ b/Web/Presenters/templates/Group/View.xml @@ -29,6 +29,14 @@ {_"description"}: {$club->getDescription()} + + {_"website"}: + + + {$club->getWebsite()} + + + diff --git a/Web/Presenters/templates/User/Edit.xml b/Web/Presenters/templates/User/Edit.xml index a61ba5f3..7ca9d209 100644 --- a/Web/Presenters/templates/User/Edit.xml +++ b/Web/Presenters/templates/User/Edit.xml @@ -173,6 +173,14 @@ + + + {_"personal_website"}: + + + + + {_"city"}: diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 0d18f59b..db68f1a2 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -424,6 +424,14 @@ + + {_"personal_website"}: + + + {$user->getWebsite()} + + + {_"city"}: diff --git a/install/sqls/00008-website-contact.sql b/install/sqls/00008-website-contact.sql new file mode 100644 index 00000000..dc15a881 --- /dev/null +++ b/install/sqls/00008-website-contact.sql @@ -0,0 +1,2 @@ +ALTER TABLE profiles ADD COLUMN website VARCHAR(128) AFTER telegram; +ALTER TABLE groups ADD COLUMN website VARCHAR(128); diff --git a/locales b/locales index ce4ede6f..6b3e5764 160000 --- a/locales +++ b/locales @@ -1 +1 @@ -Subproject commit ce4ede6f8c6cb42f2421969fab23da933c81b52b +Subproject commit 6b3e57648a5fdbfd320f0ad829849dfa76f62d68