<li><a href="{@$__wcf->getAnchor('general')}">{lang}wcf.global.form.data{/lang}</a></li>
<li><a href="{@$__wcf->getAnchor('contents')}">{lang}wcf.acp.box.contents{/lang}</a></li>
<li><a href="{@$__wcf->getAnchor('pages')}">{lang}wcf.acp.page.list{/lang}</a></li>
+ <li><a href="{@$__wcf->getAnchor('conditions')}">{lang}wcf.acp.box.conditions{/lang}</a></li>
<li><a href="{@$__wcf->getAnchor('acl')}">{lang}wcf.acl.access{/lang}</a></li>
{event name='tabMenuTabs'}
{include file='aclSimple' __supportsInvertedPermissions=true}
</div>
+ <div id="conditions" class="tabMenuContent">
+ <section class="section">
+ <header class="sectionHeader">
+ <h2 class="sectionTitle">{lang}wcf.acp.box.conditions.page{/lang}</h2>
+ </header>
+
+ {foreach from=$groupedConditionObjectTypes['com.woltlab.wcf.page'] item='pageConditionObjectType'}
+ {@$pageConditionObjectType->getProcessor()->getHtml()}
+ {/foreach}
+ </section>
+
+ {if $groupedConditionObjectTypes['com.woltlab.wcf.pointInTime']|isset}
+ <section class="section">
+ <header class="sectionHeader">
+ <h2 class="sectionTitle">{lang}wcf.acp.box.conditions.pointInTime{/lang}</h2>
+ </header>
+
+ {foreach from=$groupedConditionObjectTypes['com.woltlab.wcf.pointInTime'] item='pointInTimeConditionObjectType'}
+ {@$pointInTimeConditionObjectType->getProcessor()->getHtml()}
+ {/foreach}
+ </section>
+ {/if}
+
+ {if $groupedConditionObjectTypes['com.woltlab.wcf.user']|isset}
+ <section class="section">
+ <header class="sectionHeader">
+ <h2 class="sectionTitle">{lang}wcf.acp.box.conditions.user{/lang}</h2>
+ </header>
+
+ {include file='userConditions' groupedObjectTypes=$groupedConditionObjectTypes['com.woltlab.wcf.user']}
+ </section>
+ {/if}
+
+ {event name='conditionContainers'}
+ </div>
+
{event name='tabMenuContents'}
</div>
use wcf\system\acl\simple\SimpleAclHandler;
use wcf\system\box\IBoxController;
use wcf\system\box\IConditionBoxController;
+use wcf\system\condition\ConditionHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
*/
public $invertPermissions;
+ /**
+ * grouped boxes condition object types
+ * @var ObjectType[][]
+ */
+ public $groupedConditionObjectTypes = [];
+
/**
* @inheritDoc
*/
if ($this->boxType === 'system') {
$this->boxController = ObjectTypeCache::getInstance()->getObjectType($this->boxControllerID);
}
+
+ foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
+ foreach ($groupedObjectTypes as $objectTypes) {
+ if (\is_array($objectTypes)) {
+ foreach ($objectTypes as $objectType) {
+ $objectType->getProcessor()->readFormParameters();
+ }
+ } else {
+ $objectTypes->getProcessor()->readFormParameters();
+ }
+ }
+ }
}
/**
$statement->execute($conditionBuilder->getParameters());
$this->pageIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
}
+
+ foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
+ foreach ($groupedObjectTypes as $objectTypes) {
+ if (\is_array($objectTypes)) {
+ foreach ($objectTypes as $objectType) {
+ $objectType->getProcessor()->validate();
+ }
+ } else {
+ $objectTypes->getProcessor()->validate();
+ }
+ }
+ }
}
/**
// save acl
SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $box->boxID, $this->aclValues);
+ // transform conditions array into one-dimensional array
+ $conditions = [];
+ foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
+ foreach ($groupedObjectTypes as $objectTypes) {
+ if (\is_array($objectTypes)) {
+ $conditions = \array_merge($conditions, $objectTypes);
+ } else {
+ $conditions[] = $objectTypes;
+ }
+ }
+ }
+ ConditionHandler::getInstance()->createConditions($box->boxID, $conditions);
+
// call saved event
$this->saved();
$this->linkType = 'none';
$this->linkPageID = 0;
$this->linkPageObjectID = 0;
+
+ foreach ($conditions as $condition) {
+ $condition->getProcessor()->reset();
+ }
}
/**
*/
public function readData()
{
+ $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.condition.box');
+ foreach ($objectTypes as $objectType) {
+ if (!$objectType->conditionobject) {
+ continue;
+ }
+
+ if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject])) {
+ $this->groupedConditionObjectTypes[$objectType->conditionobject] = [];
+ }
+
+ if ($objectType->conditiongroup) {
+ if (!isset($this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup])) {
+ $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup] = [];
+ }
+
+ $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
+ } else {
+ $this->groupedConditionObjectTypes[$objectType->conditionobject][$objectType->objectTypeID] = $objectType;
+ }
+ }
+
parent::readData();
if (empty($_POST) && $this->presetBox) {
'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues),
'availableBoxPositions' => $this->availableBoxPositions,
'invertPermissions' => $this->invertPermissions,
+ 'groupedConditionObjectTypes' => $this->groupedConditionObjectTypes,
]);
}
}
SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.box', $this->box->boxID, $this->aclValues);
+ // transform conditions array into one-dimensional array
+ $conditions = [];
+ foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
+ foreach ($groupedObjectTypes as $objectTypes) {
+ if (\is_array($objectTypes)) {
+ $conditions = \array_merge($conditions, $objectTypes);
+ } else {
+ $conditions[] = $objectTypes;
+ }
+ }
+ }
+
+ ConditionHandler::getInstance()->updateConditions(
+ $this->box->boxID,
+ $this->box->getConditions2(),
+ $conditions
+ );
+
// call saved event
$this->saved();
$this->invertPermissions = $this->box->invertPermissions;
$this->readBoxImages();
+
+ $conditions = $this->box->getConditions2();
+ $conditionsByObjectTypeID = [];
+ foreach ($conditions as $condition) {
+ $conditionsByObjectTypeID[$condition->objectTypeID] = $condition;
+ }
+
+ foreach ($this->groupedConditionObjectTypes as $objectTypes1) {
+ foreach ($objectTypes1 as $objectTypes2) {
+ if (\is_array($objectTypes2)) {
+ foreach ($objectTypes2 as $objectType) {
+ if (isset($conditionsByObjectTypeID[$objectType->objectTypeID])) {
+ $conditionsByObjectTypeID[$objectType->objectTypeID]->getObjectType()->getProcessor()->setData($conditionsByObjectTypeID[$objectType->objectTypeID]);
+ }
+ }
+ } elseif (isset($conditionsByObjectTypeID[$objectTypes2->objectTypeID])) {
+ $conditionsByObjectTypeID[$objectTypes2->objectTypeID]->getObjectType()->getProcessor()->setData($conditionsByObjectTypeID[$objectTypes2->objectTypeID]);
+ }
+ }
+ }
}
}
return [];
}
+ /**
+ * @TODO
+ *
+ * @return Condition[]
+ * @since 5.5
+ */
+ public function getConditions2(): array // @TODO name
+ {
+ return ConditionHandler::getInstance()->getConditions(
+ 'com.woltlab.wcf.condition.box', // @TODO make const
+ $this->boxID
+ );
+ }
+
+ public function isVisible(): bool
+ {
+ $conditions = $this->getConditions2();
+ foreach ($conditions as $condition) {
+ if (!$condition->getObjectType()->getProcessor()->showContent($condition)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/**
* Returns true if this box is accessible by current user.
*
$boxes = [];
foreach ($boxList as $box) {
- if (!$forDisplay || $box->isAccessible()) {
+ if (!$forDisplay || ($box->isAccessible() && $box->isVisible())) {
$virtualShowOrder = (isset($showOrders[$box->boxID])) ? $showOrders[$box->boxID] : ($box->showOrder + 1000);
$box->setVirtualShowOrder($virtualShowOrder);
<item name="wcf.acp.box.controller.limit"><![CDATA[Maximale Anzahl an Einträgen]]></item>
<item name="wcf.acp.box.controller.sortField"><![CDATA[Sortierung nach]]></item>
<item name="wcf.acp.box.controller.sortField.description"><![CDATA[Die ausgewählte Objekteigenschaft wird für die Sortierung der Einträge verwendet.]]></item>
+ <item name="wcf.acp.box.conditions"><![CDATA[Bedingungen]]></item>
+ <item name="wcf.acp.box.conditions.page"><![CDATA[Seite]]></item>
+ <item name="wcf.acp.box.conditions.pointInTime"><![CDATA[Zeitpunkt]]></item>
+ <item name="wcf.acp.box.conditions.user"><![CDATA[Aktiver Benutzer]]></item>
</category>
<category name="wcf.acp.cache">
<item name="wcf.acp.cache.button.clear"><![CDATA[Cache leeren]]></item>
<item name="wcf.acp.box.controller.sortField"><![CDATA[Sort By]]></item>
<item name="wcf.acp.box.controller.sortField.description"><![CDATA[The selected object property is used for sorting.]]></item>
<item name="wcf.acp.box.controller.limit"><![CDATA[Maximum Number of Items]]></item>
+ <item name="wcf.acp.box.conditions"><![CDATA[Conditions]]></item>
+ <item name="wcf.acp.box.conditions.page"><![CDATA[Page]]></item>
+ <item name="wcf.acp.box.conditions.pointInTime"><![CDATA[Time]]></item>
+ <item name="wcf.acp.box.conditions.user"><![CDATA[Active user]]></item>
</category>
<category name="wcf.acp.cache">
<item name="wcf.acp.cache.button.clear"><![CDATA[Clear Cache]]></item>