From: Tim Düsterhus Date: Thu, 18 Feb 2021 11:23:23 +0000 (+0100) Subject: Allow disabling the admin contact in ContactForm X-Git-Tag: 5.4.0_Alpha_1~254^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e3aa54ad48f2d37eadaf4b355423bb8de06fd65f;p=GitHub%2FWoltLab%2FWCF.git Allow disabling the admin contact in ContactForm Resolves #3967 --- diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index 015bfccbfd..4e2fbb15a2 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -602,6 +602,7 @@ wcf\form\ContactForm Kontaktformular Contact Form + wcf\system\page\handler\ContactFormPageHandler module_contact_form Contact diff --git a/wcfsetup/install/files/acp/templates/contactRecipientAdd.tpl b/wcfsetup/install/files/acp/templates/contactRecipientAdd.tpl index ca2ef2a0e8..b0489d2681 100644 --- a/wcfsetup/install/files/acp/templates/contactRecipientAdd.tpl +++ b/wcfsetup/install/files/acp/templates/contactRecipientAdd.tpl @@ -70,14 +70,12 @@ - {if $action != 'edit' || !$recipient->isAdministrator} -
-
-
- -
-
- {/if} +
+
+
+ +
+
{event name='dataFields'} diff --git a/wcfsetup/install/files/acp/templates/contactSettings.tpl b/wcfsetup/install/files/acp/templates/contactSettings.tpl index 3f1c0ccf88..0bf0a32613 100644 --- a/wcfsetup/install/files/acp/templates/contactSettings.tpl +++ b/wcfsetup/install/files/acp/templates/contactSettings.tpl @@ -97,11 +97,7 @@ - {if $recipient->isAdministrator} - - {else} - - {/if} + {if $recipient->originIsSystem} diff --git a/wcfsetup/install/files/lib/acp/form/ContactRecipientEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ContactRecipientEditForm.class.php index 82e4e37a5a..102cb839ca 100644 --- a/wcfsetup/install/files/lib/acp/form/ContactRecipientEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ContactRecipientEditForm.class.php @@ -60,18 +60,6 @@ class ContactRecipientEditForm extends ContactRecipientAddForm } } - /** - * @inheritDoc - */ - public function validate() - { - parent::validate(); - - if ($this->recipient->isAdministrator) { - $this->isDisabled = 0; - } - } - /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php index 1fd016483e..5539989621 100644 --- a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php +++ b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php @@ -71,12 +71,6 @@ class ContactRecipientAction extends AbstractDatabaseObjectAction implements ISo public function validateToggle() { parent::validateUpdate(); - - foreach ($this->getObjects() as $object) { - if ($object->isAdministrator) { - throw new PermissionDeniedException(); - } - } } /** diff --git a/wcfsetup/install/files/lib/form/ContactForm.class.php b/wcfsetup/install/files/lib/form/ContactForm.class.php index ef2b97fb40..343be8b52d 100644 --- a/wcfsetup/install/files/lib/form/ContactForm.class.php +++ b/wcfsetup/install/files/lib/form/ContactForm.class.php @@ -92,7 +92,7 @@ class ContactForm extends AbstractCaptchaForm $this->recipientList->getConditionBuilder()->add("contact_recipient.isDisabled = ?", [0]); $this->recipientList->readObjects(); - if (\count($this->recipientList) < 0) { + if (!\count($this->recipientList)) { throw new IllegalLinkException(); } diff --git a/wcfsetup/install/files/lib/system/page/handler/ContactFormPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/ContactFormPageHandler.class.php new file mode 100644 index 0000000000..0f8c629547 --- /dev/null +++ b/wcfsetup/install/files/lib/system/page/handler/ContactFormPageHandler.class.php @@ -0,0 +1,33 @@ + + * @package WoltLabSuite\Core\System\Page\Handler + * @since 5.4 + */ +class ContactFormPageHandler extends AbstractMenuPageHandler +{ + /** + * @inheritDoc + */ + public function isVisible($objectID = null) + { + $sql = "SELECT EXISTS( + SELECT * + FROM wcf" . WCF_N . "_contact_recipient + WHERE isDisabled = ? + )"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([0]); + + return $statement->fetchSingleColumn(); + } +}