From: Alexander Ebert Date: Tue, 20 Jun 2017 12:09:02 +0000 (+0200) Subject: Added basic contact options X-Git-Tag: 3.1.0_Alpha_1~340 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c308c947a3954d76156e7138254d2bbc3a3f3972;p=GitHub%2FWoltLab%2FWCF.git Added basic contact options See #2308 --- diff --git a/wcfsetup/install/files/acp/templates/contactSettings.tpl b/wcfsetup/install/files/acp/templates/contactSettings.tpl index c6ca5f4b22..49a0d444fc 100644 --- a/wcfsetup/install/files/acp/templates/contactSettings.tpl +++ b/wcfsetup/install/files/acp/templates/contactSettings.tpl @@ -9,12 +9,14 @@ }); $(function() { + new WCF.Action.Delete('wcf\\data\\contact\\option\\ContactOptionAction', '.jsOptionRow'); + new WCF.Action.Toggle('wcf\\data\\contact\\option\\ContactOptionAction', $('.jsOptionRow')); + new WCF.Action.Delete('wcf\\data\\contact\\recipient\\ContactRecipientAction', '.jsRecipient'); new WCF.Action.Toggle('wcf\\data\\contact\\recipient\\ContactRecipientAction', '.jsRecipient'); }); -

{lang}wcf.acp.contact.settings{/lang}

@@ -32,6 +34,43 @@

{lang}wcf.acp.contact.options{/lang}

+ + + + + + + + + + {event name='columnHeads'} + + + + + {foreach from=$optionList item=option} + + + + + + + + {event name='columns'} + + {/foreach} + +
{lang}wcf.global.objectID{/lang}{lang}wcf.global.name{/lang}{lang}wcf.acp.customOption.optionType{/lang}{lang}wcf.acp.customOption.showOrder{/lang}
+ + + {if $option->canDelete()} + + {else} + + {/if} + + {event name='rowButtons'} + {@$option->optionID}{$option->optionTitle|language}{lang}wcf.acp.customOption.optionType.{$option->optionType}{/lang}{#$option->showOrder}
diff --git a/wcfsetup/install/files/lib/acp/form/AbstractAcpForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractAcpForm.class.php index 0d2387b3b9..109aa1e53b 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractAcpForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractAcpForm.class.php @@ -101,8 +101,6 @@ abstract class AbstractAcpForm extends AbstractForm { */ public function readDataI18n(DatabaseObject $databaseObject) { if (empty($_POST) && !empty($this->i18nValues)) { - I18nHandler::getInstance()->readValues(); - foreach ($this->i18nValues as $fieldName => $value) { I18nHandler::getInstance()->setOptions( $fieldName, @@ -133,7 +131,7 @@ abstract class AbstractAcpForm extends AbstractForm { $value->getPackageID() ); - $value[$fieldName] = I18nHandler::getInstance()->getValues($fieldName)[WCF::getLanguage()->languageID]; + $values[$fieldName] = I18nHandler::getInstance()->getValues($fieldName)[WCF::getLanguage()->languageID]; } } diff --git a/wcfsetup/install/files/lib/acp/form/AbstractCustomOptionForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractCustomOptionForm.class.php index aa6455739f..dcf1a0425e 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractCustomOptionForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractCustomOptionForm.class.php @@ -1,6 +1,6 @@ action === 'edit') { - if (isset($_REQUEST['id'])) $this->objectID = intval($_REQUEST['id']); - $this->object = new $this->baseClass($this->objectID); - if (!$this->object->getObjectID()) { + if (isset($_REQUEST['id'])) $this->optionID = intval($_REQUEST['id']); + $this->option = new $this->baseClass($this->optionID); + if (!$this->option->getObjectID()) { throw new IllegalLinkException(); } } @@ -186,6 +186,24 @@ abstract class AbstractCustomOptionForm extends AbstractAcpForm { } } + /** + * @inheritDoc + */ + public function readData() { + if ($this->action === 'edit' && empty($_POST)) { + $this->readDataI18n($this->option); + + $this->optionType = $this->option->optionType; + $this->defaultValue = $this->option->defaultValue; + $this->validationPattern = $this->option->validationPattern; + $this->selectOptions = $this->option->selectOptions; + $this->required = $this->option->required; + $this->showOrder = $this->option->showOrder; + } + + parent::readData(); + } + /** * Returns the list of database values including additional fields. * @@ -218,6 +236,11 @@ abstract class AbstractCustomOptionForm extends AbstractAcpForm { $this->reset(); } else { + $this->beforeSaveI18n($this->option); + + $this->objectAction = new $this->actionClass([$this->option], 'update', ['data' => $this->getDatabaseValues()]); + $this->objectAction->executeAction(); + $this->saved(); // show success message @@ -243,7 +266,7 @@ abstract class AbstractCustomOptionForm extends AbstractAcpForm { public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign([ + $variables = [ 'defaultValue' => $this->defaultValue, 'validationPattern' => $this->validationPattern, 'optionType' => $this->optionType, @@ -253,6 +276,13 @@ abstract class AbstractCustomOptionForm extends AbstractAcpForm { 'action' => $this->action, 'availableOptionTypes' => self::$availableOptionTypes, 'optionTypesUsingSelectOptions' => self::$optionTypesUsingSelectOptions - ]); + ]; + + if ($this->action === 'edit') { + $variables['option'] = $this->option; + $variables['optionID'] = $this->optionID; + } + + WCF::getTPL()->assign($variables); } } diff --git a/wcfsetup/install/files/lib/acp/form/ContactOptionAddForm.class.php b/wcfsetup/install/files/lib/acp/form/ContactOptionAddForm.class.php index c04a0de07a..a105291482 100644 --- a/wcfsetup/install/files/lib/acp/form/ContactOptionAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ContactOptionAddForm.class.php @@ -58,7 +58,7 @@ class ContactOptionAddForm extends AbstractCustomOptionForm { public function readParameters() { parent::readParameters(); - $this->getI18nValue('optionTitle')->setLanguageItem('wcf.contact.field', 'wcf.contact', 'com.woltlab.wcf'); - $this->getI18nValue('optionDescription')->setLanguageItem('wcf.contact.fieldDescription', 'wcf.contact', 'com.woltlab.wcf'); + $this->getI18nValue('optionTitle')->setLanguageItem('wcf.contact.option', 'wcf.contact', 'com.woltlab.wcf'); + $this->getI18nValue('optionDescription')->setLanguageItem('wcf.contact.optionDescription', 'wcf.contact', 'com.woltlab.wcf'); } } diff --git a/wcfsetup/install/files/lib/acp/form/ContactOptionEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ContactOptionEditForm.class.php new file mode 100644 index 0000000000..9c2d3acf96 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/ContactOptionEditForm.class.php @@ -0,0 +1,18 @@ + + * @package WoltLabSuite\Core\Acp\Form + * @since 3.1 + */ +class ContactOptionEditForm extends ContactOptionAddForm { + /** + * @inheritDoc + */ + public $action = 'edit'; +} diff --git a/wcfsetup/install/files/lib/acp/page/ContactSettingsPage.class.php b/wcfsetup/install/files/lib/acp/page/ContactSettingsPage.class.php index 4b5b2762f8..8c9a9829c4 100644 --- a/wcfsetup/install/files/lib/acp/page/ContactSettingsPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/ContactSettingsPage.class.php @@ -1,5 +1,6 @@ optionList = new ContactOptionList(); + $this->optionList->readObjects(); + $this->recipientList = new ContactRecipientList(); $this->recipientList->readObjects(); } @@ -51,6 +60,7 @@ class ContactSettingsPage extends AbstractPage { parent::assignVariables(); WCF::getTPL()->assign([ + 'optionList' => $this->optionList, 'recipientList' => $this->recipientList ]); } diff --git a/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php b/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php index 246c53ee01..efeb6646fb 100644 --- a/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php +++ b/wcfsetup/install/files/lib/data/custom/option/CustomOption.class.php @@ -28,6 +28,7 @@ use wcf\util\StringUtil; * @property-read integer $required is `1` if the option has to be filled out, otherwise `0` * @property-read integer $showOrder position of the option relation tp the other options * @property-read integer $isDisabled is `1` if the option is disabled, otherwise `0` + * @property-read integer $originIsSystem is `1` if the option has been delivered by a package, otherwise `0` (i.e. the option has been created in the ACP) */ abstract class CustomOption extends Option { /** @@ -126,4 +127,14 @@ abstract class CustomOption extends Option { return StringUtil::encodeHTML($this->optionValue); } } + + /** + * Returns true if this option can be deleted, defaults to false for + * options created through the package system. + * + * @return boolean + */ + public function canDelete() { + return !$this->originIsSystem; + } } diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index 4373daac1c..cd56301544 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -179,7 +179,12 @@ class LinkHandler extends SingletonFactory { $pageURL = RouteHandler::getHost() . str_replace('//', '/', RouteHandler::getPath(['acp'])); } else { - $pageURL = ApplicationHandler::getInstance()->getApplication($abbreviation)->getPageURL(); + $application = ApplicationHandler::getInstance()->getApplication($abbreviation); + if ($application === null) { + throw new \InvalidArgumentException("Unknown application identifier '{$abbreviation}'."); + } + + $pageURL = $application->getPageURL(); } $url = $pageURL . ($isACP ? 'acp/' : '') . $url; diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index a704b40d76..f89c0e8515 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -269,6 +269,7 @@ + @@ -2340,6 +2341,9 @@ Fehler sind beispielsweise: + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 702c380782..1ee961f75e 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2273,12 +2273,16 @@ Errors are: + + + + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index d1885d0900..591626f689 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -413,6 +413,21 @@ CREATE TABLE wcf1_condition ( conditionData MEDIUMTEXT ); +DROP TABLE IF EXISTS wcf1_contact_option; +CREATE TABLE wcf1_contact_option ( + optionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, + optionTitle VARCHAR(255) NOT NULL DEFAULT '', + optionDescription TEXT, + optionType VARCHAR(255) NOT NULL DEFAULT '', + defaultValue MEDIUMTEXT, + validationPattern TEXT, + selectOptions MEDIUMTEXT, + required TINYINT(1) NOT NULL DEFAULT 0, + showOrder INT(10) NOT NULL DEFAULT 0, + isDisabled TINYINT(1) NOT NULL DEFAULT 0, + originIsSystem TINYINT(1) NOT NULL DEFAULT 0 +); + DROP TABLE IF EXISTS wcf1_contact_recipient; CREATE TABLE wcf1_contact_recipient ( recipientID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, @@ -2225,5 +2240,9 @@ INSERT INTO wcf1_user_rank (groupID, requiredPoints, rankTitle, cssClassName) VA (3, 9000, 'wcf.user.rank.user4', ''), (3, 15000, 'wcf.user.rank.user5', ''); +-- default options: subject and message +INSERT INTO wcf1_contact_option (optionID, optionTitle, optionDescription, optionType, required, showOrder, originIsSystem) VALUES (1, 'wcf.contact.option1', 'wcf.contact.optionDescription1', 'text', 1, 1, 1); +INSERT INTO wcf1_contact_option (optionID, optionTitle, optionDescription, optionType, required, showOrder, originIsSystem) VALUES (2, 'wcf.contact.option2', '', 'textarea', 1, 1, 1); + -- default recipient: site administrator INSERT INTO wcf1_contact_recipient (recipientID, name, email, isAdministrator, originIsSystem) VALUES (1, 'wcf.contact.recipient.name1', '', 1, 1);