<categoryname>general.page</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
- <enableoptions>enable_desktop_notifications</enableoptions>
+ <enableoptions>enable_desktop_notifications,desktop_notification_package_id</enableoptions>
</option>
<option name="enable_desktop_notifications">
<categoryname>general.page</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
+ <enableoptions>desktop_notification_package_id</enableoptions>
+ </option>
+ <option name="desktop_notification_package_id">
+ <categoryname>general.page</categoryname>
+ <optiontype>desktopNotificationApplicationSelect</optiontype>
+ <defaultvalue>1</defaultvalue>
</option>
<option name="head_code">
<categoryname>general.page</categoryname>
{if ENABLE_POLLING && $__wcf->user->userID}
require(['WoltLabSuite/Core/Notification/Handler'], function(NotificationHandler) {
NotificationHandler.setup({
- enableNotifications: {if ENABLE_DESKTOP_NOTIFICATIONS}true{else}false{/if},
+ enableNotifications: {if $__wcf->useDesktopNotifications()}true{else}false{/if},
icon: '{$__wcf->getStyleHandler()->getStyle()->getFaviconAppleTouchIcon()}',
sessionKeepAlive: {@$__sessionKeepAlive}
});
{include file='formError'}
{/if}
-<div id="loginForm" class="loginForm{if REGISTER_DISABLED} loginFormLoginOnly{/if}">
+<div id="loginForm" class="section loginForm{if REGISTER_DISABLED} loginFormLoginOnly{/if}">
<form method="post" action="{@$loginController}">
<section class="section loginFormLogin">
<h2 class="sectionTitle">{lang}wcf.user.login.login{/lang}</h2>
define('MODULE_TROPHY', 1);
define('ENABLE_DEVELOPER_TOOLS', 0);
define('FORCE_LOGIN', 0);
+define('DESKTOP_NOTIFICATION_PACKAGE_ID', 1);
--- /dev/null
+{if $isMultiDomainSetup}
+ <select name="values[{$option->optionName}]" id="{$option->optionName}">
+ {foreach from=$applications item=application}
+ <option value="{@$application->packageID}"{if $application->packageID == $value} selected{/if}>{$application->getPackage()}</option>
+ {/foreach}
+ </select>
+{else}
+ {* TODO: hide *}
+ <input type="hidden" name="values[{$option->optionName}]" value="1">
+ <script>
+ (function() {
+ {* pretend that this option does not exist *}
+ var container = elBySel('.{$option->optionName}Input');
+ container.style.setProperty('margin', '0', 'important');
+ container.style.setProperty('max-height', '0', 'important');
+ container.style.setProperty('overflow', 'hidden', 'important');
+ })();
+ </script>
+{/if}
<body id="tpl{$templateName|ucfirst}" data-template="{$templateName}" data-application="{$templateNameApplication}" class="wcfAcp">
<a id="top"></a>
-<div id="pageContainer" class="pageContainer">
+<div id="pageContainer" class="pageContainer acpPageHiddenMenu">
<div class="pageHeaderContainer">
<header id="pageHeaderFacade" class="pageHeaderFacade">
<div class="layoutBoundary">
return self::getPath() . $favicon;
}
+ /**
+ * Returns true if the desktop notifications should be enabled.
+ *
+ * @return boolean
+ */
+ public function useDesktopNotifications() {
+ if (!ENABLE_DESKTOP_NOTIFICATIONS) {
+ return false;
+ }
+ else if (ApplicationHandler::getInstance()->isMultiDomainSetup()) {
+ $application = ApplicationHandler::getInstance()->getApplicationByID(DESKTOP_NOTIFICATION_PACKAGE_ID);
+ // mismatch, default to Core
+ if ($application === null) $application = ApplicationHandler::getInstance()->getApplicationByID(1);
+
+ $currentApplication = ApplicationHandler::getInstance()->getActiveApplication();
+ if ($currentApplication->domainName != $application->domainName) {
+ // different domain
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/**
* Returns true if currently active request represents the landing page.
*
*/
protected $cache;
+ /**
+ * true for multi-domain setups
+ * @var boolean
+ */
+ protected $isMultiDomain;
+
/**
* list of page URLs
* @var string[]
return false;
}
+ /**
+ * Returns true if this is a multi-domain setup.
+ *
+ * @return boolean
+ * @since 3.1
+ */
+ public function isMultiDomainSetup() {
+ if ($this->isMultiDomain === null) {
+ $this->isMultiDomain = false;
+
+ $domainName = $this->getApplicationByID(1)->domainName;
+ foreach ($this->getApplications() as $application) {
+ if ($application->domainName !== $domainName) {
+ $this->isMultiDomain = true;
+ break;
+ }
+ }
+ }
+
+ return $this->isMultiDomain;
+ }
+
/**
* Rebuilds cookie domain/path for all applications.
*/
--- /dev/null
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\application\ApplicationHandler;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+
+/**
+ * Option type implementation for the desktop notification application selection. This
+ * option is intentionally designed to be invisible at most times.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Option
+ */
+class DesktopNotificationApplicationSelectOptionType extends AbstractOptionType {
+ /**
+ * @inheritDoc
+ */
+ public function getFormElement(Option $option, $value) {
+ return WCF::getTPL()->fetch('desktopNotificationApplicationSelectOptionType', 'wcf', [
+ 'applications' => ApplicationHandler::getInstance()->getApplications(),
+ 'isMultiDomainSetup' => ApplicationHandler::getInstance()->isMultiDomainSetup(),
+ 'option' => $option,
+ 'value' => $value
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validate(Option $option, $newValue) {
+ if (ApplicationHandler::getInstance()->isMultiDomainSetup()) {
+ if (ApplicationHandler::getInstance()->getApplicationByID($newValue) === null) {
+ throw new UserInputException($option->optionName, 'validationFailed');
+ }
+ }
+ }
+}
namespace wcf\system\search\acp;
use wcf\data\option\category\OptionCategoryList;
use wcf\data\option\Option;
+use wcf\system\application\ApplicationHandler;
use wcf\system\cache\builder\OptionCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\request\LinkHandler;
$optionCategories = OptionCacheBuilder::getInstance()->getData([], 'categories');
+ /** @var Option $option */
while ($option = $statement->fetchObject(Option::class)) {
// category is not accessible
if (!$this->isValid($option->categoryName)) {
continue;
}
+ // hide special option for multi-domain setups if not applicable
+ if ($option->optionName === 'desktop_notification_package_id' && !ApplicationHandler::getInstance()->isMultiDomainSetup()) {
+ continue;
+ }
+
$link = LinkHandler::getInstance()->getLink('Option', [
'id' => $this->getCategoryID($this->getTopCategory($option->categoryName)->parentCategoryName)
], 'optionName='.$option->optionName.'#category_'.$this->getCategoryName($option->categoryName));
<item name="wcf.acp.option.enable_developer_tools.description"><![CDATA[Aktiviert spezielle Werkzeuge die für die Plugin-Entwicklung verwendet werden. Diese Option sollte im Live-Betrieb abgeschaltet werden.]]></item>
<item name="wcf.acp.option.force_login"><![CDATA[Anmeldung erzwingen]]></item>
<item name="wcf.acp.option.force_login.description"><![CDATA[Besucher werden aufgefordert sich anzumelden, um auf die Inhalte zugreifen zu können.]]></item>
+ <item name="wcf.acp.option.desktop_notification_package_id"><![CDATA[Primäre Domain für Desktop-Benachrichtigungen]]></item>
+ <item name="wcf.acp.option.desktop_notification_package_id.description"><![CDATA[Desktop-Benachrichtigungen werden nur für die ausgewählte App aktiviert, einschließlich aller anderen Apps die auf der identischen Domain laufen.]]></item>
</category>
<category name="wcf.acp.customOption">
<item name="wcf.acp.option.enable_developer_tools.description"><![CDATA[Enables a set of specialized tools that are used for plugin development. Should always be disabled in production environments.]]></item>
<item name="wcf.acp.option.force_login"><![CDATA[Force login]]></item>
<item name="wcf.acp.option.force_login.description"><![CDATA[Visitors are required to log-in themselves to access the page.]]></item>
+ <item name="wcf.acp.option.desktop_notification_package_id"><![CDATA[Primary Domain for Desktop Notifications]]></item>
+ <item name="wcf.acp.option.desktop_notification_package_id.description"><![CDATA[Desktop Notifications will be enabled for the selected app only, including all other apps that use the exact same domain.]]></item>
</category>
<category name="wcf.acp.customOption">