});
$(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');
});
</script>
-
<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.contact.settings{/lang}</h1>
<section class="section">
<h2 class="sectionTitle">{lang}wcf.acp.contact.options{/lang}</h2>
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th class="columnID columnOptionID" colspan="2">{lang}wcf.global.objectID{/lang}</th>
+ <th class="columnTitle columnOptionTitle">{lang}wcf.global.name{/lang}</th>
+ <th class="columnText columnOptionType">{lang}wcf.acp.customOption.optionType{/lang}</th>
+ <th class="columnDigits columnShowOrder">{lang}wcf.acp.customOption.showOrder{/lang}</th>
+
+ {event name='columnHeads'}
+ </tr>
+ </thead>
+
+ <tbody>
+ {foreach from=$optionList item=option}
+ <tr class="jsOptionRow">
+ <td class="columnIcon">
+ <span class="icon icon16 fa-{if !$option->isDisabled}check-{/if}square-o jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $option->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$option->optionID}"></span>
+ <a href="{link controller='ContactOptionEdit' id=$option->optionID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
+ {if $option->canDelete()}
+ <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$option->optionID}" data-confirm-message-html="{lang __encode=true}wcf.acp.customOption.delete.confirmMessage{/lang}"></span>
+ {else}
+ <span class="icon icon16 fa-times disabled"></span>
+ {/if}
+
+ {event name='rowButtons'}
+ </td>
+ <td class="columnID">{@$option->optionID}</td>
+ <td class="columnTitle columnOptionTitle"><a href="{link controller='ContactOptionEdit' id=$option->optionID}{/link}">{$option->optionTitle|language}</a></td>
+ <td class="columnText columnOptionType">{lang}wcf.acp.customOption.optionType.{$option->optionType}{/lang}</td>
+ <td class="columnDigits columnShowOrder">{#$option->showOrder}</td>
+
+ {event name='columns'}
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
</section>
<section class="section">
*/
public function readDataI18n(DatabaseObject $databaseObject) {
if (empty($_POST) && !empty($this->i18nValues)) {
- I18nHandler::getInstance()->readValues();
-
foreach ($this->i18nValues as $fieldName => $value) {
I18nHandler::getInstance()->setOptions(
$fieldName,
$value->getPackageID()
);
- $value[$fieldName] = I18nHandler::getInstance()->getValues($fieldName)[WCF::getLanguage()->languageID];
+ $values[$fieldName] = I18nHandler::getInstance()->getValues($fieldName)[WCF::getLanguage()->languageID];
}
}
<?php
namespace wcf\acp\form;
-use wcf\data\option\Option;
+use wcf\data\custom\option\CustomOption;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
use wcf\system\language\I18nValue;
/**
* object instance
- * @var Option
+ * @var CustomOption
*/
- public $object;
+ public $option;
/**
* object id
* @var integer
*/
- public $objectID;
+ public $optionID;
/**
* available option types
}
if ($this->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();
}
}
}
}
+ /**
+ * @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.
*
$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
public function assignVariables() {
parent::assignVariables();
- WCF::getTPL()->assign([
+ $variables = [
'defaultValue' => $this->defaultValue,
'validationPattern' => $this->validationPattern,
'optionType' => $this->optionType,
'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);
}
}
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');
}
}
--- /dev/null
+<?php
+namespace wcf\acp\form;
+
+/**
+ * Shows the contact option edit form.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Acp\Form
+ * @since 3.1
+ */
+class ContactOptionEditForm extends ContactOptionAddForm {
+ /**
+ * @inheritDoc
+ */
+ public $action = 'edit';
+}
<?php
namespace wcf\acp\page;
+use wcf\data\contact\option\ContactOptionList;
use wcf\data\contact\recipient\ContactRecipientList;
use wcf\page\AbstractPage;
use wcf\system\WCF;
*/
public $neededPermissions = ['admin.contact.canManageContactForm'];
+ /**
+ * @var ContactOptionList
+ */
+ public $optionList;
+
/**
* @var ContactRecipientList
*/
public function readData() {
parent::readData();
+ $this->optionList = new ContactOptionList();
+ $this->optionList->readObjects();
+
$this->recipientList = new ContactRecipientList();
$this->recipientList->readObjects();
}
parent::assignVariables();
WCF::getTPL()->assign([
+ 'optionList' => $this->optionList,
'recipientList' => $this->recipientList
]);
}
* @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 {
/**
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;
+ }
}
$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;
<category name="wcf.acp.contact">
<item name="wcf.acp.contact.options"><![CDATA[Eingabefelder]]></item>
<item name="wcf.acp.contact.option.add"><![CDATA[Eingabefeld hinzufügen]]></item>
+ <item name="wcf.acp.contact.option.edit"><![CDATA[Eingabefeld bearbeiten]]></item>
<item name="wcf.acp.contact.recipients"><![CDATA[Empfänger]]></item>
<item name="wcf.acp.contact.recipient.add"><![CDATA[Empfänger hinzufügen]]></item>
<item name="wcf.acp.contact.recipient.edit"><![CDATA[Empfänger bearbeiten]]></item>
</category>
<category name="wcf.contact">
+ <item name="wcf.contact.option1"><![CDATA[Betreff]]></item>
+ <item name="wcf.contact.optionDescription1"><![CDATA[Kurze, prägnante Beschreibung der Anfrage.]]></item>
+ <item name="wcf.contact.option2"><![CDATA[Nachricht]]></item>
<item name="wcf.contact.recipient.name1"><![CDATA[Administrator]]></item>
</category>
</category>
<category name="wcf.contact">
+ <item name="wcf.contact.option1"><![CDATA[Subject]]></item>
+ <item name="wcf.contact.optionDescription1"><![CDATA[Short and precise description of your inquiry.]]></item>
+ <item name="wcf.contact.option2"><![CDATA[Message]]></item>
<item name="wcf.contact.recipient.name1"><![CDATA[Administrator]]></item>
</category>
<category name="wcf.acp.contact">
<item name="wcf.acp.contact.options"><![CDATA[Input Fields]]></item>
<item name="wcf.acp.contact.option.add"><![CDATA[Add Input Field]]></item>
+ <item name="wcf.acp.contact.option.edit"><![CDATA[Edit Input Field]]></item>
<item name="wcf.acp.contact.recipients"><![CDATA[Recipients]]></item>
<item name="wcf.acp.contact.recipient.add"><![CDATA[Add Recipient]]></item>
<item name="wcf.acp.contact.recipient.edit"><![CDATA[Edit Recipient]]></item>
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,
(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);