From 73e416d088772065a8a4ed2b73a6ac5547274f27 Mon Sep 17 00:00:00 2001 From: Christian Hartmann Date: Sat, 5 Oct 2024 20:14:44 +0200 Subject: [PATCH] chore: remove legacy link support Signed-off-by: Christian Hartmann --- lib/Constants.php | 5 +-- lib/Controller/ApiController.php | 5 --- lib/Controller/PageController.php | 25 ----------- lib/Db/Form.php | 10 +---- .../Version050000Date20241005173955.php | 40 +++++++++++++++++ lib/Service/FormsService.php | 6 +-- .../SidebarTabs/SettingsSidebarTab.vue | 6 +-- .../SidebarTabs/SharingSidebarTab.vue | 44 ------------------- src/views/Create.vue | 13 ------ src/views/Submit.vue | 13 ------ 10 files changed, 44 insertions(+), 123 deletions(-) create mode 100644 lib/Migration/Version050000Date20241005173955.php diff --git a/lib/Constants.php b/lib/Constants.php index 44ce72a1d..df7b49ffe 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -68,16 +68,13 @@ class Constants { public const FORM_ACCESS_NOPUBLICSHARE = 0; public const FORM_ACCESS_PERMITALLUSERS = 1; public const FORM_ACCESS_SHOWTOALLUSERS = 2; + // still needed for Migrations public const FORM_ACCESS_LEGACYLINK = 3; - public const FORM_ACCESS_LEGACYLINK_PERMITALLUSERS = 4; - public const FORM_ACCESS_LEGACYLINK_SHOWTOALLUSERS = 5; public const FORM_ACCESS_ARRAY_PERMIT = [ self::FORM_ACCESS_PERMITALLUSERS, - self::FORM_ACCESS_LEGACYLINK_PERMITALLUSERS ]; public const FORM_ACCESS_ARRAY_SHOWN = [ self::FORM_ACCESS_SHOWTOALLUSERS, - self::FORM_ACCESS_LEGACYLINK_SHOWTOALLUSERS ]; /** diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index f3b0584a6..d695213d4 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -2765,11 +2765,6 @@ private function loadFormForSubmission(int $formId, string $shareHash): Form { // If hash given, find the corresponding share & check if hash corresponds to given formId. if ($shareHash !== '') { - // public by legacy Link - if (isset($form->getAccess()['legacyLink']) && $shareHash === $form->getHash()) { - $isPublicShare = true; - } - // Public link share $share = $this->shareMapper->findPublicShareByHash($shareHash); if ($share->getFormId() === $formId) { diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 75e431b15..e3b72fc12 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -117,31 +117,6 @@ public function internalLinkView(string $hash): Response { return new RedirectResponse($internalView); } - // For legacy-support, show public template - try { - $form = $this->formMapper->findByHash($hash); - } catch (DoesNotExistException $e) { - return $this->provideEmptyContent(Constants::EMPTY_NOTFOUND); - } - if (isset($form->getAccess()['legacyLink'])) { - // Inject style on all templates - Util::addStyle($this->appName, 'forms'); - - // Has form expired - if ($this->formsService->hasFormExpired($form)) { - return $this->provideEmptyContent(Constants::EMPTY_EXPIRED, $form); - } - - // Public Template to fill the form - Util::addScript($this->appName, 'forms-submit'); - $this->insertHeaderOnIos(); - $this->initialState->provideInitialState('form', $this->formsService->getPublicForm($form)); - $this->initialState->provideInitialState('isLoggedIn', $this->userSession->isLoggedIn()); - $this->initialState->provideInitialState('shareHash', $hash); - $this->initialState->provideInitialState('maxStringLengths', Constants::MAX_STRING_LENGTHS); - return $this->provideTemplate(self::TEMPLATE_MAIN, $form); - } - // Otherwise Redirect to login (& then internal view) return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', ['redirect_url' => $internalView])); } diff --git a/lib/Db/Form.php b/lib/Db/Form.php index c2c4144de..d08665b98 100644 --- a/lib/Db/Form.php +++ b/lib/Db/Form.php @@ -98,10 +98,7 @@ public function getAccess(): array { $accessEnum = $this->getAccessEnum(); $access = []; - if ($accessEnum >= Constants::FORM_ACCESS_LEGACYLINK) { - $access['legacyLink'] = true; - } - switch ($accessEnum % Constants::FORM_ACCESS_LEGACYLINK) { + switch ($accessEnum) { case Constants::FORM_ACCESS_NOPUBLICSHARE: $access['permitAllUsers'] = false; $access['showToAllUsers'] = false; @@ -135,11 +132,6 @@ public function setAccess(array $access) { $value = Constants::FORM_ACCESS_PERMITALLUSERS; } - // If legacyLink add 3 - if (isset($access['legacyLink']) && $access['legacyLink']) { - $value += Constants::FORM_ACCESS_LEGACYLINK; - } - $this->setAccessEnum($value); } diff --git a/lib/Migration/Version050000Date20241005173955.php b/lib/Migration/Version050000Date20241005173955.php new file mode 100644 index 000000000..ab55520e8 --- /dev/null +++ b/lib/Migration/Version050000Date20241005173955.php @@ -0,0 +1,40 @@ +db->getQueryBuilder(); + + $qbUpdate->update('forms_v2_forms') + ->set('access_enum', 'access_enum - 3') + ->where($qbUpdate->expr()->gte('access_enum', '3')); + } +} diff --git a/lib/Service/FormsService.php b/lib/Service/FormsService.php index 386a4f727..540d545da 100644 --- a/lib/Service/FormsService.php +++ b/lib/Service/FormsService.php @@ -357,7 +357,7 @@ public function canDeleteResults(Form $form): bool { * @return boolean */ public function canSubmit(Form $form): bool { - // We cannot control how many time users can submit if public link / legacyLink available + // We cannot control how many time users can submit if public link available if ($this->hasPublicLink($form)) { return true; } @@ -387,10 +387,6 @@ public function canSubmit(Form $form): bool { private function hasPublicLink(Form $form): bool { $access = $form->getAccess(); - if (isset($access['legacyLink'])) { - return true; - } - $shareEntities = $this->shareMapper->findByForm($form->getId()); foreach ($shareEntities as $shareEntity) { if ($shareEntity->getShareType() === IShare::TYPE_LINK) { diff --git a/src/components/SidebarTabs/SettingsSidebarTab.vue b/src/components/SidebarTabs/SettingsSidebarTab.vue index eb5d657fc..16bfd891c 100644 --- a/src/components/SidebarTabs/SettingsSidebarTab.vue +++ b/src/components/SidebarTabs/SettingsSidebarTab.vue @@ -208,11 +208,7 @@ export default { * Submit Multiple is disabled, if it cannot be controlled. */ disableSubmitMultiple() { - return ( - this.hasPublicLink || - this.form.access.legacyLink || - this.form.isAnonymous - ) + return this.hasPublicLink || this.form.isAnonymous }, disableSubmitMultipleExplanation() { if (this.disableSubmitMultiple) { diff --git a/src/components/SidebarTabs/SharingSidebarTab.vue b/src/components/SidebarTabs/SharingSidebarTab.vue index 308c41b84..fc8138805 100644 --- a/src/components/SidebarTabs/SharingSidebarTab.vue +++ b/src/components/SidebarTabs/SharingSidebarTab.vue @@ -115,37 +115,6 @@ :text="qrDialogText" @closed="qrDialogText = ''" /> - - -