<controller>wcf\form\ContactForm</controller>
<name language="de">Kontaktformular</name>
<name language="en">Contact Form</name>
+ <handler>wcf\system\page\handler\ContactFormPageHandler</handler>
<options>module_contact_form</options>
<content language="en">
<title>Contact</title>
</dd>
</dl>
- {if $action != 'edit' || !$recipient->isAdministrator}
- <dl>
- <dt></dt>
- <dd>
- <label><input type="checkbox" name="isDisabled" value="1"{if $isDisabled} checked{/if}> {lang}wcf.acp.contact.recipient.isDisabled{/lang}</label>
- </dd>
- </dl>
- {/if}
+ <dl>
+ <dt></dt>
+ <dd>
+ <label><input type="checkbox" name="isDisabled" value="1"{if $isDisabled} checked{/if}> {lang}wcf.acp.contact.recipient.isDisabled{/lang}</label>
+ </dd>
+ </dl>
{event name='dataFields'}
</div>
<span class="statusDisplay sortableButtonContainer">
<span class="icon icon16 fa-arrows sortableNodeHandle"></span>
- {if $recipient->isAdministrator}
- <span class="icon icon16 fa-check-square-o disabled"></span>
- {else}
- <span class="icon icon16 fa-{if !$recipient->isDisabled}check-square-o{else}square-o{/if} jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $recipient->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$recipient->recipientID}"></span>
- {/if}
+ <span class="icon icon16 fa-{if !$recipient->isDisabled}check-square-o{else}square-o{/if} jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $recipient->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$recipient->recipientID}"></span>
<a href="{link controller='ContactRecipientEdit' id=$recipient->recipientID}{/link}"><span title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip icon icon16 fa-pencil"></a>
{if $recipient->originIsSystem}
<span class="icon icon16 fa-times disabled"></span>
}
}
- /**
- * @inheritDoc
- */
- public function validate()
- {
- parent::validate();
-
- if ($this->recipient->isAdministrator) {
- $this->isDisabled = 0;
- }
- }
-
/**
* @inheritDoc
*/
public function validateToggle()
{
parent::validateUpdate();
-
- foreach ($this->getObjects() as $object) {
- if ($object->isAdministrator) {
- throw new PermissionDeniedException();
- }
- }
}
/**
$this->recipientList->getConditionBuilder()->add("contact_recipient.isDisabled = ?", [0]);
$this->recipientList->readObjects();
- if (\count($this->recipientList) < 0) {
+ if (!\count($this->recipientList)) {
throw new IllegalLinkException();
}
--- /dev/null
+<?php
+
+namespace wcf\system\page\handler;
+
+use wcf\system\WCF;
+
+/**
+ * Hides the contact form if no recipients are enabled.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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();
+ }
+}