<ul>
<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>
{/if}
</div>
- <div id="pages" class="tabMenuContent">
- <div class="section">
- <dl>
- <dt></dt>
- <dd>
- <label><input type="checkbox" id="visibleEverywhere" name="visibleEverywhere" value="1"{if $visibleEverywhere} checked{/if}> {lang}wcf.acp.box.visibleEverywhere{/lang}</label>
- <script data-relocate="true">
- require([], function() {
- // visibility toggle
- var visibilityExceptionHidden = elById('visibilityExceptionHidden');
- var visibilityExceptionVisible = elById('visibilityExceptionVisible');
-
- elById('visibleEverywhere').addEventListener('change', function() {
- window[this.checked ? 'elShow' : 'elHide'](visibilityExceptionHidden);
- window[this.checked ? 'elHide' : 'elShow'](visibilityExceptionVisible);
- });
- });
- </script>
- </dd>
- </dl>
-
- <dl>
- <dt>
- <span id="visibilityExceptionVisible"{if $visibleEverywhere} style="display: none"{/if}>{lang}wcf.acp.box.visibilityException.visible{/lang}</span>
- <span id="visibilityExceptionHidden"{if !$visibleEverywhere} style="display: none"{/if}>{lang}wcf.acp.box.visibilityException.hidden{/lang}</span>
- </dt>
- <dd>
- {include file='scrollablePageCheckboxList' pageCheckboxListContainerID='boxVisibilitySettings' pageCheckboxID='pageIDs'}
- </dd>
- </dl>
-
- {event name='pagesTabMenuContent'}
- </div>
- </div>
-
<div id="acl" class="tabMenuContent">
{include file='aclSimple' __supportsInvertedPermissions=true}
</div>
use wcf\system\box\IBoxController;
use wcf\system\box\IConditionBoxController;
use wcf\system\condition\ConditionHandler;
+use wcf\system\condition\page\MultiPageCondition;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
if (isset($_POST['showOrder'])) {
$this->showOrder = \intval($_POST['showOrder']);
}
- if (isset($_POST['visibleEverywhere'])) {
- $this->visibleEverywhere = \intval($_POST['visibleEverywhere']);
- }
if (isset($_POST['cssClassName'])) {
$this->cssClassName = StringUtil::trim($_POST['cssClassName']);
}
if (isset($_POST['isDisabled'])) {
$this->isDisabled = 1;
}
- if (isset($_POST['pageIDs']) && \is_array($_POST['pageIDs'])) {
- $this->pageIDs = ArrayUtil::toIntegerArray($_POST['pageIDs']);
- }
-
if (isset($_POST['linkType'])) {
$this->linkType = $_POST['linkType'];
}
if (isset($_POST['externalURL'])) {
$this->externalURL = StringUtil::trim($_POST['externalURL']);
}
-
if (isset($_POST['title']) && \is_array($_POST['title'])) {
$this->title = ArrayUtil::trim($_POST['title']);
}
$this->boxController = ObjectTypeCache::getInstance()->getObjectType($this->boxControllerID);
}
+ $this->readConditions();
+ }
+
+ private function readConditions(): void
+ {
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (\is_array($objectTypes)) {
foreach ($objectTypes as $objectType) {
$objectType->getProcessor()->readFormParameters();
+ if ($objectType->getProcessor() instanceof MultiPageCondition) {
+ $data = $objectType->getProcessor()->getData();
+ if ($data !== null) {
+ $this->pageIDs = $data['pageIDs'];
+ $this->visibleEverywhere = !$data['pageIDs_reverseLogic'];
+ }
+ }
}
} else {
$objectTypes->getProcessor()->readFormParameters();
+ if ($objectTypes->getProcessor() instanceof MultiPageCondition) {
+ $data = $objectTypes->getProcessor()->getData();
+ if ($data !== null) {
+ $this->pageIDs = $data['pageIDs'];
+ $this->visibleEverywhere = !$data['pageIDs_reverseLogic'];
+ }
+ }
}
}
}
use wcf\data\box\Box;
use wcf\data\box\BoxList;
+use wcf\data\condition\Condition;
use wcf\data\condition\ConditionAction;
+use wcf\data\object\type\ObjectTypeCache;
use wcf\data\page\Page;
+use wcf\system\condition\ConditionHandler;
+use wcf\system\condition\page\MultiPageCondition;
use wcf\system\event\EventHandler;
use wcf\system\request\RequestHandler;
use wcf\system\SingletonFactory;
$statement->execute([$box->boxID, $page->pageID, $visible ? 1 : 0]);
}
}
+
+ $conditionObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
+ 'com.woltlab.wcf.condition.box',
+ 'com.woltlab.wcf.page'
+ );
+ $oldCondition = [];
+ foreach ($box->getConditions2() as $condition) {
+ if ($condition->objectTypeID === $conditionObjectTypeID) {
+ $oldCondition[] = $condition;
+ break;
+ }
+ }
+
+ // Create matching conditions.
+ $pageConditions = $this->createPageConditions(
+ $pages,
+ $box->visibleEverywhere,
+ $box
+ );
+
+ ConditionHandler::getInstance()->updateConditions(
+ $box->boxID,
+ $oldCondition,
+ $pageConditions
+ );
+ }
+
+ private function createPageConditions(array $pages, bool $reverseLogic, Box $box): array
+ {
+ $pageCondition = ObjectTypeCache::getInstance()->getObjectTypeByName(
+ 'com.woltlab.wcf.condition.box',
+ 'com.woltlab.wcf.page'
+ );
+
+ $pageIDs = \array_merge($box->getPageIDs(), \array_map(static function ($page) {
+ return $page->pageID;
+ }, $pages));
+
+ \assert($pageCondition->getProcessor() instanceof MultiPageCondition);
+
+ $pageCondition->getProcessor()->setData(new Condition(null, [
+ 'conditionData' => \serialize([
+ 'pageIDs' => \array_unique($pageIDs),
+ 'pageIDs_reverseLogic' => $reverseLogic,
+ ]),
+ ]));
+
+ return [
+ $pageCondition,
+ ];
}
/**