WCF.ACP.Application = { };
/**
- * Namespace for ACP application group management.
- */
-WCF.ACP.Application.Group = { };
-
-/**
- * Provides the ability to remove application groups.
+ * Provides the ability to set an application as primary.
*
- * @param string redirectURL
+ * @param integer packageID
*/
-WCF.ACP.Application.Group.Delete = Class.extend({
+WCF.ACP.Application.SetAsPrimary = Class.extend({
/**
- * redirect URL
- * @var string
+ * application package id
+ * @var integer
*/
- _redirectURL: '',
+ _packageID: 0,
/**
- * Initializes the WCF.ACP.Application.Group.Delete class.
+ * Initializes the WCF.ACP.Application.SetAsPrimary class.
*
- * @param string redirectURL
+ * @param integer packageID
*/
- init: function(redirectURL) {
- this._redirectURL = redirectURL || '';
+ init: function(packageID) {
+ this._packageID = packageID;
- $('.jsDeleteApplicationGroup').click($.proxy(this._click, this));
+ $('#setAsPrimary').click($.proxy(this._click, this));
},
/**
- * Shows a confirmation dialog to remove an application group.
- *
- * @param object event
+ * Shows a confirmation dialog to set current application as primary.
*/
- _click: function(event) {
- var $button = $(event.currentTarget);
-
- WCF.System.Confirmation.show($button.data('confirmMessage'), $.proxy(function(action) {
+ _click: function() {
+ WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.application.setAsPrimary.confirmMessage'), $.proxy(function(action) {
if (action === 'confirm') {
- this._remove($button.data('groupID'));
+ this._setAsPrimary();
}
}, this));
},
/**
- * Removes an application group.
- *
- * @param integer groupID
+ * Sets an application as primary.
*/
- _remove: function(groupID) {
+ _setAsPrimary: function(groupID) {
new WCF.Action.Proxy({
autoSend: true,
data: {
- actionName: 'delete',
- className: 'wcf\\data\\application\\group\\ApplicationGroupAction',
- objectIDs: [ groupID ]
+ actionName: 'setAsPrimary',
+ className: 'wcf\\data\\application\\ApplicationAction',
+ objectIDs: [ this._packageID ]
},
success: $.proxy(function(data, textStatus, jqXHR) {
- var $notification = new WCF.System.Notification(WCF.Language.get('wcf.acp.application.group.delete.success'));
- $notification.show($.proxy(function() {
- if (this._redirectURL) {
- window.location = this._redirectURL;
- }
- else {
- window.location.reload();
- }
- }, this));
+ var $notification = new WCF.System.Notification(WCF.Language.get('wcf.acp.application.setAsPrimary.success'));
+ $notification.show();
+
+ // remove button
+ $('#setAsPrimary').parent().remove();
+
+ // insert icon
+ WCF.DOMNodeInsertedHandler.enable();
+ $('<img src="' + WCF.Icon.get('wcf.icon.home') + '" alt="" class="icon16 jsTooltip" title="' + WCF.Language.get('wcf.acp.application.primaryApplication') + '" />').appendTo($('.boxHeadline > hgroup > h1'));
+ WCF.DOMNodeInsertedHandler.disable();
}, this)
});
}
<th class="columnID columnSessionAccessLogID{if $sortField == 'sessionAccessLogID'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=sessionAccessLogID&sortOrder={if $sortField == 'sessionAccessLogID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}{if $sortField == 'sessionAccessLogID'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<th class="columnURL columnIpAddress{if $sortField == 'ipAddress'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=ipAddress&sortOrder={if $sortField == 'ipAddress' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.user.ipAddress{/lang}{if $sortField == 'ipAddress'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<th class="columnDate{if $sortField == 'time'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=time&sortOrder={if $sortField == 'time' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.sessionLog.time{/lang}{if $sortField == 'time'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
- <th class="columnTitle columnPackageName{if $sortField == 'packageName'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=packageName&sortOrder={if $sortField == 'packageName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.sessionLog.packageName{/lang}{if $sortField == 'packageName'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<th class="columnText columnClassName{if $sortField == 'className'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=className&sortOrder={if $sortField == 'className' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.sessionLog.className{/lang}{if $sortField == 'className'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<th class="columnURL columnRequestURI{if $sortField == 'requestURI'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=requestURI&sortOrder={if $sortField == 'requestURI' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.sessionLog.requestURI{/lang}{if $sortField == 'requestURI'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<th class="columnText columnRequestMethod{if $sortField == 'requestMethod'} active{/if}"><a href="{link controller='ACPSessionLog' id=$sessionLogID}pageNo={@$pageNo}&sortField=requestMethod&sortOrder={if $sortField == 'requestMethod' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.sessionLog.requestMethod{/lang}{if $sortField == 'requestMethod'} <img src="{@$__wcf->getPath()}icon/sort{@$sortOrder}.svg" alt="" />{/if}</a></th>
<td class="columnID columnSessionAccessLogID"><p>{@$sessionAccessLog->sessionAccessLogID}</p></td>
<td class="columnURL columnIpAddress{if $sessionAccessLog->ipAddress != $sessionLog->ipAddress} hot{/if}"><p>{$sessionAccessLog->ipAddress}</p></td>
<td class="columnDate columnTime"><p>{@$sessionAccessLog->time|time}</p></td>
- <td class="columnTitle columnPackageName"><p>{$sessionAccessLog->packageName|language}</p></td>
<td class="columnText columnClassName"><p>{$sessionAccessLog->className}</p></td>
<td class="columnURL columnRequestURI" title="{$sessionAccessLog->requestURI}"><p>{if !$sessionAccessLog->hasProtectedURI()}<a href="{$sessionAccessLog->requestURI}{@SID_ARG_2ND}">{$sessionAccessLog->requestURI|truncate:50}</a>{else}{$sessionAccessLog->requestURI|truncate:50}{/if}</p></td>
<td class="columnTextolumnRequestMethod"><p>{$sessionAccessLog->requestMethod}</p></td>
{include file='header' pageTitle='wcf.acp.application.edit'}
+{if $application->packageID != 1 && !$application->isPrimary}
+ <script type="text/javascript">
+ //<![CDATA[
+ $(function() {
+ WCF.Icon.addObject({
+ 'wcf.icon.home': '{@$__wcf->getPath()}icon/home.svg'
+ });
+ WCF.Language.addObject({
+ 'wcf.acp.application.primaryApplication': '{lang}wcf.acp.application.primaryApplication{/lang}',
+ 'wcf.acp.application.setAsPrimary.confirmMessage': '{lang}wcf.acp.application.setAsPrimary.confirmMessage{/lang}',
+ 'wcf.acp.application.setAsPrimary.success': '{lang}wcf.acp.application.setAsPrimary.success{/lang}'
+ });
+
+ new WCF.ACP.Application.SetAsPrimary({@$application->packageID});
+ });
+ //]]>
+ </script>
+{/if}
+
<header class="boxHeadline">
<hgroup>
- <h1>{lang}wcf.acp.application.edit.title{/lang}</h1>
+ <h1>{lang}wcf.acp.application.edit.title{/lang}{if $application->isPrimary} <img src="{@$__wcf->getPath()}icon/home.svg" alt="" class="icon16 jsTooltip" title="{lang}wcf.acp.application.primaryApplication{/lang}" />{/if}</h1>
</hgroup>
</header>
<div class="contentNavigation">
<nav>
<ul>
+ {if $application->packageID != 1 && !$application->isPrimary}<li><a id="setAsPrimary" class="button"><img src="{@$__wcf->getPath()}icon/default.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.application.setAsPrimary{/lang}</span></a></li>{/if}
<li><a href="{link controller='ApplicationManagement'}{/link}" title="{lang}wcf.acp.application.management{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/list.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.application.management{/lang}</span></a></li>
{event name='largeButtons'}
+++ /dev/null
-{include file='header' pageTitle='wcf.acp.application.group.'|concat:$action}
-
-<script type="text/javascript">
- //<![CDATA[
- $(function() {
- new WCF.ACP.Application.Group.Delete('{link controller='ApplicationManagement'}{/link}');
-
- WCF.Language.addObject({
- 'wcf.acp.application.group.delete.success': '{lang}wcf.acp.application.group.delete.success{/lang}'
- });
- });
- //]]>
-</script>
-
-<header class="boxHeadline">
- <hgroup>
- <h1>{lang}wcf.acp.application.group.{$action}{/lang}</h1>
- </hgroup>
-</header>
-
-{if $errorField}
- <p class="error">{lang}wcf.global.form.error{/lang}</p>
-{/if}
-
-{if $success|isset}
- <p class="success">{lang}wcf.global.form.{$action}.success{/lang}</p>
-{/if}
-
-<div class="contentNavigation">
- <nav>
- <ul>
- {if $action == 'edit'}<li><a class="button jsDeleteApplicationGroup" data-confirm-message="{lang}wcf.acp.application.group.delete.confirmMessage{/lang}" data-group-id="{@$applicationGroup->groupID}"><img src="{@RELATIVE_WCF_DIR}icon/delete.svg" class="icon24" /> <span>{lang}wcf.acp.application.group.delete{/lang}</span></a></li>{/if}
- <li><a href="{link controller='ApplicationManagement'}{/link}" class="button"><img src="{@RELATIVE_WCF_DIR}icon/list.svg" alt="" /> <span>{lang}wcf.acp.application.management{/lang}</span></a></li>
- </ul>
- </nav>
-</div>
-
-{if $availableApplications|count > 1}
- <div class="container containerPadding marginTop">
- <form method="post" action="{if $action == 'add'}{link controller='ApplicationGroupAdd'}{/link}{else}{link controller='ApplicationGroupEdit' id=$applicationGroup->groupID}{/link}{/if}">
- <fieldset>
- <legend>{lang}wcf.acp.application.group.data{/lang}</legend>
-
- <dl{if $errorField == 'groupName'} class="formError"{/if}>
- <dt><label for="groupName">{lang}wcf.acp.application.group.groupName{/lang}</label></dt>
- <dd>
- <input type="text" name="groupName" id="groupName" value="{$groupName}" class="long" required="required" />
- {if $errorField == 'groupName'}
- <small class="innerError">
- {if $errorType == 'empty'}
- {lang}wcf.global.form.error.empty{/lang}
- {else}
- {lang}wcf.acp.application.group.groupName.error.{$errorType}{/lang}
- {/if}
- </small>
- {/if}
- </dd>
- </dl>
- </fieldset>
-
- <fieldset{if $errorField == 'applications'} class="formError"{/if}>
- <legend>{lang}wcf.acp.application.group.availableApplications{/lang}</legend>
-
- <div class="tabularBox">
- <table class="table">
- <thead>
- <tr>
- <th class="columnID columnPackageID" colspan="3">{lang}wcf.global.objectID{/lang}</th>
- <th class="columnMark columnPrimaryApplication">{lang}wcf.acp.application.primaryApplication{/lang}</th>
- <th class="columnText columnPackageName">{lang}wcf.acp.package.name{/lang}</th>
- <th class="columnText columnDomainName">{lang}wcf.acp.application.domainName{/lang}</th>
- <th class="columnText columnDomainPath">{lang}wcf.acp.application.domainPath{/lang}</th>
- <th class="columnText columnCookieDomain">{lang}wcf.acp.application.cookieDomain{/lang}</th>
- <th class="columnText columnCookiePath">{lang}wcf.acp.application.cookiePath{/lang}</th>
-
- {event name='headColumns'}
- </tr>
- </thead>
-
- <tbody>
- {foreach from=$availableApplications item=application}
- <tr data-package="{$application->package}">
- <td class="columnMark"><input type="checkbox" name="applications[]" value="{@$application->packageID}"{if $application->packageID|in_array:$applications} checked="checked"{/if} /></td>
- <td class="columnIcon"><a href="{link controller='ApplicationEdit' id=$application->packageID}{/link}"><img src="{@RELATIVE_WCF_DIR}icon/edit.svg" alt="" class="icon16 jsTooltip" title="{lang}wcf.global.button.edit{/lang}" /></a></td>
- <td class="columnID columnPackageID">{#$application->packageID}</td>
- <td class="columnMark columnPrimaryApplication"><input type="radio" name="primaryApplication" value="{@$application->packageID}" required="required"{if $primaryApplication == $application->packageID} checked="checked"{/if} /></td>
- <td class="columnText columnPackageName"><a href="{link controller='PackageView' id=$application->packageID}{/link}">{lang}{$application->getPackage()->getName()}{/lang}</a></td>
- <td class="columnText columnDomainName">{$application->domainName}</td>
- <td class="columnText columnDomainPath">{$application->domainPath}</td>
- <td class="columnText columnCookieDomain">{$application->cookieDomain}</td>
- <td class="columnText columnCookiePath">{$application->cookiePath}</td>
-
- {event name='columns'}
- </tr>
- {/foreach}
- </tbody>
- </table>
- </div>
-
- {if $errorField == 'applications'}
- <small class="innerError">
- {if $errorType == 'empty'}
- {lang}wcf.global.form.error.empty{/lang}
- {else}
- {lang}wcf.acp.application.group.applications.error.{$errorType}{/lang}
- {/if}
- </small>
- {/if}
- </fieldset>
-
- <div class="formSubmit">
- <input type="submit" value="{lang}wcf.global.button.submit{/lang}" />
- </div>
- </form>
- </div>
-
- <div class="contentNavigation">
- <nav>
- <ul>
- <li><a href="{link controller='ApplicationManagement'}{/link}" class="button"><img src="{@RELATIVE_WCF_DIR}icon/list.svg" alt="" /> <span>{lang}wcf.acp.application.management{/lang}</span></a></li>
- </ul>
- </nav>
- </div>
-{else}
- <p class="error">{lang}wcf.acp.application.group.noAvailableApplications{/lang}</p>
-{/if}
-
-{include file='footer'}
{include file='header' pageTitle='wcf.acp.application.management'}
-<script type="text/javascript">
- //<![CDATA[
- $(function() {
- new WCF.ACP.Application.Group.Delete();
-
- WCF.Language.addObject({
- 'wcf.acp.application.group.delete.success': '{lang}wcf.acp.application.group.delete.success{/lang}'
- });
- });
- //]]>
-</script>
-
-{foreach from=$applicationGroups item=applicationGroup}
- <header class="boxHeadline">
- <hgroup>
- <h1>{lang}wcf.acp.application.group.title{/lang} <span class="badge">{#$applicationGroup|count}</span></h1>
- </hgroup>
- </header>
-
- <div class="tabularBox marginTop">
- <table class="table">
- <thead>
- <tr>
- <th class="columnID columnPackageID" colspan="2">{lang}wcf.global.objectID{/lang}</th>
- <th class="columnText columnPackageName">{lang}wcf.acp.package.name{/lang}</th>
- <th class="columnText columnDomainName">{lang}wcf.acp.application.domainName{/lang}</th>
- <th class="columnText columnDomainPath">{lang}wcf.acp.application.domainPath{/lang}</th>
- <th class="columnText columnCookieDomain">{lang}wcf.acp.application.cookieDomain{/lang}</th>
- <th class="columnText columnCookiePath">{lang}wcf.acp.application.cookiePath{/lang}</th>
-
- {event name='headColumns'}
- </tr>
- </thead>
-
- <tbody>
- {foreach from=$applicationGroup item=application}
- <tr>
- <td class="columnIcon"><a href="{link controller='ApplicationEdit' id=$application->packageID}{/link}"><img src="{@RELATIVE_WCF_DIR}icon/edit.svg" alt="" class="icon16 jsTooltip" title="{lang}wcf.global.button.edit{/lang}" /></a></td>
- <td class="columnID columnPackageID">{#$application->packageID}</td>
- <td class="columnText columnPackageName">
- <a href="{link controller='PackageView' id=$application->packageID}{/link}">{lang}{$application->getPackage()->getName()}{/lang}</a>
-
- {if $application->isPrimary}
- <aside class="statusDisplay">
- <ul class="statusIcons">
- <li><img src="{@RELATIVE_WCF_DIR}icon/home.svg" alt="" class="icon16 jsTooltip" title="{lang}{lang}wcf.acp.application.primaryApplication{/lang}{/lang}" /></li>
- </ul>
- </aside>
- {/if}
- </td>
- <td class="columnText columnDomainName">{$application->domainName}</td>
- <td class="columnText columnDomainPath">{$application->domainPath}</td>
- <td class="columnText columnCookieDomain">{$application->cookieDomain}</td>
- <td class="columnText columnCookiePath">{$application->cookiePath}</td>
- </tr>
- {/foreach}
- </tbody>
- </table>
- </div>
-
- <div class="contentNavigation">
- <nav>
- <ul>
- <li><a class="button jsDeleteApplicationGroup" data-confirm-message="{lang}wcf.acp.application.group.delete.confirmMessage{/lang}" data-group-id="{@$applicationGroup->groupID}"><img src="{@RELATIVE_WCF_DIR}icon/delete.svg" class="icon24" /> <span>{lang}wcf.acp.application.group.delete{/lang}</span></a></li>
- <li><a href="{link controller='ApplicationGroupEdit' id=$applicationGroup->groupID}{/link}" class="button"><img src="{@RELATIVE_WCF_DIR}icon/edit.svg" class="icon24" /> <span>{lang}wcf.acp.application.group.edit{/lang}</span></a></li>
- </ul>
- </nav>
- </div>
-{/foreach}
+<div class="contentNavigation">
+ {* todo: event *}
+</div>
{hascontent}
<header class="boxHeadline">
<hgroup>
- <h1>{lang}wcf.acp.application.independentApplications{/lang} <span class="badge">{#$applications|count}</span></h1>
+ <h1>{lang}wcf.acp.application.list{/lang} <span class="badge">{#$applicationList|count}</span></h1>
</hgroup>
</header>
<tbody>
{content}
- {foreach from=$applications item=application}
+ {foreach from=$applicationList item=application}
<tr>
- <td class="columnIcon"><a href="{link controller='ApplicationEdit' id=$application->packageID}{/link}"><img src="{@RELATIVE_WCF_DIR}icon/edit.svg" alt="" class="icon16 jsTooltip" title="{lang}wcf.global.button.edit{/lang}" /></a></td>
+ <td class="columnIcon"><a href="{link controller='ApplicationEdit' id=$application->packageID}{/link}"><img src="{@$__wcf->getPath()}icon/edit.svg" alt="" class="icon16 jsTooltip" title="{lang}wcf.global.button.edit{/lang}" /></a></td>
<td class="columnID columnPackageID">{#$application->packageID}</td>
<td class="columnText columnPackageName"><a href="{link controller='PackageView' id=$application->packageID}{/link}">{lang}{$application->getPackage()->getName()}{/lang}</a></td>
<td class="columnText columnDomainName">{$application->domainName}</td>
</div>
{/hascontent}
-{hascontent}
- <div class="contentNavigation">
- <nav>
- <ul>
- {content}
- {if $applications|count > 1}
- <li><a href="{link controller='ApplicationGroupAdd'}{/link}" class="button"><img src="{@RELATIVE_WCF_DIR}icon/add.svg" class="icon24" /> <span>{lang}wcf.acp.application.group.add{/lang}</span></a></li>
- {/if}
-
- {* todo: event *}
- {/content}
- </ul>
- </nav>
- </div>
-{/hascontent}
+<div class="contentNavigation">
+ {* todo: event *}
+</div>
{include file='footer'}
use wcf\data\application\Application;
use wcf\data\application\ApplicationAction;
use wcf\data\application\ViewableApplication;
+use wcf\system\application\ApplicationHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
use wcf\system\Regex;
'domainPath' => $this->domainPath
)));
$this->objectAction->executeAction();
+
$this->saved();
+ // re-calculate cookie settings
+ ApplicationHandler::rebuild();
+
// show success.
WCF::getTPL()->assign(array(
'success' => true
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\application\ViewableApplicationList;
-use wcf\data\application\group\ApplicationGroupAction;
-use wcf\system\exception\UserInputException;
-use wcf\system\request\LinkHandler;
-use wcf\system\WCF;
-use wcf\util\ArrayUtil;
-use wcf\util\HeaderUtil;
-use wcf\util\StringUtil;
-
-/**
- * Shows the application group add form.
- *
- * @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.form
- * @category Community Framework
- */
-class ApplicationGroupAddForm extends ACPForm {
- /**
- * @see wcf\acp\form\ACPForm::$activeMenuItem
- */
- public $activeMenuItem = 'wcf.acp.menu.link.application';
-
- /**
- * list of application package ids
- * @var array<integer>
- */
- public $applications = array();
-
- /**
- * list of available applications
- * @var array<wcf\data\application\ViewableApplication>
- */
- public $availableApplications = array();
-
- /**
- * group name
- * @var string
- */
- public $groupName = '';
-
- /**
- * @see wcf\page\AbstractPage::$neededPermissions
- */
- public $neededPermissions = array('admin.system.canManageApplication');
-
- /**
- * primary application's package id
- * @var integer
- */
- public $primaryApplication = 0;
-
- /**
- * @see wcf\page\IPage::readParameters()
- */
- public function readParameters() {
- parent::readParameters();
-
- $this->readAvailableApplications();
- }
-
- /**
- * Reads the list of available applications.
- */
- protected function readAvailableApplications() {
- $applicationList = new ViewableApplicationList();
- $applicationList->getConditionBuilder()->add("application.groupID IS NULL");
- $applicationList->sqlLimit = 0;
- $applicationList->readObjects();
-
- $this->availableApplications = $applicationList->getObjects();
- }
-
- /**
- * @see wcf\form\IForm::readFormParameters()
- */
- public function readFormParameters() {
- parent::readFormParameters();
-
- if (isset($_POST['applications']) && is_array($_POST['applications'])) $this->applications = ArrayUtil::toIntegerArray($_POST['applications']);
- if (isset($_POST['groupName'])) $this->groupName = StringUtil::trim($_POST['groupName']);
- if (isset($_POST['primaryApplication'])) $this->primaryApplication = intval($_POST['primaryApplication']);
- }
-
- /**
- * @see wcf\form\IForm::validate()
- */
- public function validate() {
- parent::validate();
-
- // validate group name
- $this->validateGroupName();
-
- // validate application package ids
- if (empty($this->applications)) {
- throw new UserInputException('applications');
- }
- else {
- $this->applications = array_unique($this->applications);
-
- // require at least two applications
- if (count($this->applications) == 1) {
- throw new UserInputException('applications', 'single');
- }
-
- $packages = array();
- foreach ($this->applications as $packageID) {
- // unknown package id
- if (!isset($this->availableApplications[$packageID])) {
- throw new UserInputException('applications', 'notValid');
- }
-
- $application = $this->availableApplications[$packageID];
-
- // cannot group two or more applications of the same type
- if (in_array($application->getPackage()->package, $packages)) {
- throw new UserInputException('applications', 'duplicate');
- }
-
- $packages[] = $application->getPackage()->package;
- }
- }
-
- if ($this->primaryApplication == 0) {
- throw new UserInputException('applications', 'primaryApplication.empty');
- }
- else {
- if (!in_array($this->primaryApplication, $this->applications)) {
- throw new UserInputException('applications', 'primaryApplication.notValid');
- }
- }
- }
-
- /**
- * Validates group name.
- */
- protected function validateGroupName() {
- if (empty($this->groupName)) {
- throw new UserInputException('groupName');
- }
- else {
- // check for duplicates
- $sql = "SELECT COUNT(*) AS count
- FROM wcf".WCF_N."_application_group
- WHERE groupName = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->groupName));
- $row = $statement->fetchArray();
- if ($row['count']) {
- throw new UserInputException('groupName', 'notUnique');
- }
- }
- }
-
- /**
- * @see wcf\form\IForm::save()
- */
- public function save() {
- parent::save();
-
- // save group
- $this->objectAction = new ApplicationGroupAction(array(), 'create', array(
- 'applications' => $this->applications,
- 'data' => array(
- 'groupName' => $this->groupName
- ),
- 'primaryApplication' => $this->primaryApplication
- ));
- $this->objectAction->executeAction();
- $this->saved();
-
- // reset values
- $this->applications = array();
- $this->groupName = '';
- $this->primaryApplication = 0;
-
- // reload available applications
- $this->readAvailableApplications();
-
- if (count($this->availableApplications) <= 1) {
- HeaderUtil::redirect(LinkHandler::getInstance()->getLink('ApplicationManagement'));
- }
-
- // show success
- WCF::getTPL()->assign(array(
- 'success' => true
- ));
- }
-
- /**
- * @see wcf\page\IPage::assignVariables()
- */
- public function assignVariables() {
- parent::assignVariables();
-
- WCF::getTPL()->assign(array(
- 'action' => 'add',
- 'applications' => $this->applications,
- 'availableApplications' => $this->availableApplications,
- 'groupName' => $this->groupName,
- 'primaryApplication' => $this->primaryApplication,
- ));
- }
-}
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\application\group\ApplicationGroup;
-use wcf\data\application\group\ApplicationGroupAction;
-use wcf\data\application\ViewableApplicationList;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\UserInputException;
-use wcf\system\WCF;
-
-/**
- * Shows the application group edit form.
- *
- * @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.form
- * @category Community Framework
- */
-class ApplicationGroupEditForm extends ApplicationGroupAddForm {
- /**
- * application group object
- * @var wcf\data\application\group\ApplicationGroup
- */
- public $applicationGroup = null;
-
- /**
- * groupd id
- * @var integer
- */
- public $groupID = 0;
-
- /**
- * @see wcf\page\IPage::readParameters()
- */
- public function readParameters() {
- if (isset($_REQUEST['id'])) $this->groupID = intval($_REQUEST['id']);
- $this->applicationGroup = new ApplicationGroup($this->groupID);
- if (!$this->applicationGroup->groupID) {
- throw new IllegalLinkException();
- }
-
- parent::readParameters();
- }
-
- /**
- * Reads the list of available applications.
- */
- protected function readAvailableApplications() {
- $applicationList = new ViewableApplicationList();
- $applicationList->getConditionBuilder()->add("(application.groupID = ? OR application.groupID IS NULL)", array($this->applicationGroup->groupID));
- $applicationList->sqlLimit = 0;
- $applicationList->readObjects();
-
- $this->availableApplications = $applicationList->getObjects();
- foreach ($this->availableApplications as $application) {
- if ($application->groupID == $this->applicationGroup->groupID) {
- $this->applications[] = $application->packageID;
- }
- }
- }
-
- /**
- * @see wcf\acp\form\ApplicationGroupAddForm::validateGroupName()
- */
- protected function validateGroupName() {
- if (empty($this->groupName)) {
- throw new UserInputException('groupName');
- }
- else {
- // check for duplicates
- $sql = "SELECT COUNT(*) AS count
- FROM wcf".WCF_N."_application_group
- WHERE groupName = ?
- AND groupID <> ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $this->groupName,
- $this->applicationGroup->groupID
- ));
- $row = $statement->fetchArray();
- if ($row['count']) {
- throw new UserInputException('groupName', 'notUnique');
- }
- }
- }
-
- /**
- * @see wcf\page\IPage::readData()
- */
- public function readData() {
- parent::readData();
-
- if (empty($_POST)) {
- $this->groupName = $this->applicationGroup->groupName;
-
- foreach ($this->availableApplications as $application) {
- if ($application->isPrimary) {
- $this->primaryApplication = $application->packageID;
- break;
- }
- }
- }
- }
-
- /**
- * @see wcf\form\IForm::save()
- */
- public function save() {
- ACPForm::save();
-
- // save group
- $this->objectAction = new ApplicationGroupAction(array($this->applicationGroup), 'update', array(
- 'applications' => $this->applications,
- 'data' => array(
- 'groupName' => $this->groupName
- ),
- 'primaryApplication' => $this->primaryApplication
- ));
- $this->objectAction->executeAction();
- $this->saved();
-
- // show success.
- WCF::getTPL()->assign(array(
- 'success' => true
- ));
- }
-
- /**
- * @see wcf\page\IPage::assignVariables()
- */
- public function assignVariables() {
- parent::assignVariables();
-
- WCF::getTPL()->assign(array(
- 'action' => 'edit',
- 'applicationGroup' => $this->applicationGroup,
- 'groupID' => $this->groupID
- ));
- }
-}
/**
* @see wcf\page\SortablePage::$validSortFields
*/
- public $validSortFields = array('sessionAccessLogID', 'ipAddress', 'time', 'requestURI', 'requestMethod', 'className', 'packageName');
+ public $validSortFields = array('sessionAccessLogID', 'ipAddress', 'time', 'requestURI', 'requestMethod', 'className');
/**
* session log id
* @see wcf\page\MultipleLinkPage::readObjects()
*/
protected function readObjects() {
- $this->sqlOrderBy = ($this->sortField != 'packageName' ? 'acp_session_access_log.' : '').$this->sortField." ".$this->sortOrder;
+ $this->sqlOrderBy = 'acp_session_access_log.'.$this->sortField." ".$this->sortOrder;
parent::readObjects();
}
<?php
namespace wcf\acp\page;
use wcf\data\application\ViewableApplicationList;
-use wcf\data\application\group\ApplicationGroupList;
-use wcf\data\application\group\ViewableApplicationGroup;
use wcf\page\AbstractPage;
use wcf\system\menu\acp\ACPMenu;
use wcf\system\WCF;
*/
class ApplicationManagementPage extends AbstractPage {
/**
- * list of ungrouped applications
- * @var array<wcf\data\application\Application>
+ * list of applications
+ * @var wcf\data\application\ViewableApplicationList
*/
- public $applications = null;
-
- /**
- * list of viewable application groups
- * @var array<wcf\data\application\group\ViewableApplicationGroup>
- */
- public $applicationGroups = null;
-
- /**
- * number of ungrouped applications
- * @var integer
- */
- public $ungroupedApplications = 0;
+ public $applicationList = null;
/**
* @see wcf\page\AbstractPage::$neededPermissions
public function readData() {
parent::readData();
- $applicationList = new ViewableApplicationList();
- $applicationList->sqlLimit = 0;
- $applicationList->readObjects();
-
- $applicationGroupList = new ApplicationGroupList();
- $applicationGroupList->sqlLimit = 0;
- $applicationGroupList->readObjects();
- foreach ($applicationGroupList as $applicationGroup) {
- $this->applicationGroups[$applicationGroup->groupID] = new ViewableApplicationGroup($applicationGroup);
- }
-
- foreach ($applicationList as $application) {
- if (!$application->groupID) {
- $this->applications[$application->packageID] = $application;
- }
- else {
- $this->applicationGroups[$application->groupID]->addApplication($application);
- }
- }
+ $this->applicationList = new ViewableApplicationList();
+ $this->applicationList->sqlLimit = 0;
+ $this->applicationList->readObjects();
}
/**
parent::assignVariables();
WCF::getTPL()->assign(array(
- 'applications' => $this->applications,
- 'applicationGroups' => $this->applicationGroups
+ 'applicationList' => $this->applicationList
));
}
* @see wcf\page\MultipleLinkPage::readObjects()
*/
protected function readObjects() {
- $this->sqlOrderBy = 'package.'.($this->sortField == 'packageType' ? 'isApplication '.$this->sortOrder.', '.$this->sortOrder : $this->sortField.' '.$this->sortOrder).($this->sortField != 'packageName' ? ', package.packageName ASC' : '');
+ $this->sqlOrderBy = 'package.'.($this->sortField == 'packageType' ? 'isApplication '.$this->sortOrder : $this->sortField.' '.$this->sortOrder).($this->sortField != 'packageName' ? ', package.packageName ASC' : '');
parent::readObjects();
}
* @see wcf\data\DatabaseObjectList::$className
*/
public $className = 'wcf\data\acp\session\access\log\ACPSessionAccessLog';
-
- /**
- * @see wcf\data\DatabaseObjectList::readObjects()
- */
- public function readObjects() {
- if (!empty($this->sqlSelects)) $this->sqlSelects .= ',';
- $this->sqlSelects .= "CASE WHEN package.instanceName <> '' THEN package.instanceName ELSE package.packageName END AS packageName";
- $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_package package ON (package.packageID = ".$this->getDatabaseTableAlias().".packageID)";
-
- parent::readObjects();
- }
}
use wcf\data\package\Package;
use wcf\data\package\PackageCache;
use wcf\system\cache\CacheHandler;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\exception\UserInputException;
use wcf\system\WCF;
use wcf\util\FileUtil;
*/
protected $className = 'wcf\data\application\ApplicationEditor';
+ /**
+ * application editor object
+ * @var wcf\data\application\ApplicationEditor
+ */
+ public $applicationEditor = null;
+
/**
* Assigns a list of applications to a group and computes cookie domain and path.
*/
$this->rebuild();
}
+
+ /**
+ * Validates parameters to set an application as primary.
+ */
+ public function validateSetAsPrimary() {
+ WCF::getSession()->checkPermissions(array('admin.system.canManageApplication'));
+
+ $this->applicationEditor = $this->getSingleObject();
+ if (!$this->applicationEditor->packageID || $this->applicationEditor->packageID == 1) {
+ throw new UserInputException('objectIDs');
+ }
+ else if ($this->applicationEditor->isPrimary) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * Sets an application as primary.
+ */
+ public function setAsPrimary() {
+ $this->applicationEditor->setAsPrimary();
+ }
}
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(
1,
- $this->applicationID
+ $this->packageID
));
self::resetCache();
public static function setup() {
$sql = "SELECT COUNT(*) AS count
FROM wcf".WCF_N."_application
- WHERE isApplication = ?";
+ WHERE isPrimary = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(1));
$row = $statement->fetchArray();
<?php
namespace wcf\data\application;
-use wcf\data\package\PackageCache;
/**
* Represents a list of viewable applications.
* @category Community Framework
*/
class ViewableApplicationList extends ApplicationList {
- /**
- * @see wcf\data\DatabaseObjectList::__construct()
- */
- public function __construct() {
- parent::__construct();
-
- // exclude WCF pseudo-application
- $this->getConditionBuilder()->add("application.packageID <> ?", array(1));
- }
-
/**
* @see wcf\data\DatabaseObjectList::readObjects()
*/
// find existing items
$itemList = new LanguageItemList();
$itemList->getConditionBuilder()->add("language_item.languageItem IN (?)", array(array_keys($items)));
- $itemList->getConditionBuilder()->add("language_item.packageID = ? AND language_item.languageID = ?", array($packageID, $this->languageID));
+ $itemList->getConditionBuilder()->add("language_item.languageID = ?", array($this->languageID));
$itemList->sqlLimit = 0;
$itemList->readObjects();
<item name="wcf.acp.application.domainPath.description"><![CDATA[Geben Sie den Pfad an, über den diese Anwendung erreichbar ist. Wenn Ihre Anwendung zum Beispiel unter „http://www.example.com/community/forum/“ erreichbar ist, so geben Sie bitte „/community/forum/“ ein.]]></item>
<item name="wcf.acp.application.edit"><![CDATA[Anwendung bearbeiten]]></item>
<item name="wcf.acp.application.edit.title"><![CDATA[Anwendung bearbeiten: „<a href="{link controller='PackageView' id=$application->packageID}{/link}">{$application->getPackage()->getName()}</a>“]]></item>
- <item name="wcf.acp.application.group.add"><![CDATA[Anwendungsgruppe hinzufügen]]></item>
- <item name="wcf.acp.application.group.applications.error.duplicate"><![CDATA[Zwei oder mehr Anwendungen des selben Typs können nicht in einer Gruppe zusammengefasst werden.]]></item>
- <item name="wcf.acp.application.group.applications.error.notValid"><![CDATA[Eine oder mehrere ausgewählte Anwendungen sind nicht mehr verfügbar.]]></item>
- <item name="wcf.acp.application.group.applications.error.single"><![CDATA[Eine Gruppe muss aus mindestens zwei Anwendungen bestehen.]]></item>
- <item name="wcf.acp.application.group.availableApplications"><![CDATA[Verfügbare Anwendungen]]></item>
- <item name="wcf.acp.application.group.data"><![CDATA[Allgemein]]></item>
- <item name="wcf.acp.application.group.delete"><![CDATA[Anwendungsgruppe löschen]]></item>
- <item name="wcf.acp.application.group.delete.confirmMessage"><![CDATA[Wollen Sie die Anwendungsgruppe „{$applicationGroup->groupName}“ wirklich löschen?]]></item>
- <item name="wcf.acp.application.group.delete.success"><![CDATA[Anwendungsgruppe erfolgreich gelöscht]]></item>
- <item name="wcf.acp.application.group.edit"><![CDATA[Anwendungsgruppe bearbeiten]]></item>
- <item name="wcf.acp.application.group.groupName"><![CDATA[Name]]></item>
- <item name="wcf.acp.application.group.groupName.error.notUnique"><![CDATA[Der Gruppenname muss einzigartig sein.]]></item>
- <item name="wcf.acp.application.group.noAvailableApplications"><![CDATA[Es ist derzeit keine ausreichende Anzahl Anwendungen verfügbar, um eine Anwendungsgruppe zu erstellen.]]></item>
- <item name="wcf.acp.application.group.title"><![CDATA[Anwendungsgruppe: „{$applicationGroup->groupName}“]]></item>
- <item name="wcf.acp.application.independentApplications"><![CDATA[Unabhängige Anwendungen]]></item>
+ <item name="wcf.acp.application.list"><![CDATA[Installierte Anwendungen]]></item>
<item name="wcf.acp.application.management"><![CDATA[Anwendungen verwalten]]></item>
<item name="wcf.acp.application.primaryApplication"><![CDATA[Primäre Anwendung]]></item>
+ <item name="wcf.acp.application.setAsPrimary"><![CDATA[Als primäre Anwendung festlegen]]></item>
+ <item name="wcf.acp.application.setAsPrimary.confirmMessage"><![CDATA[Möchten Sie „{$application->getPackage()->getName()}“ wirklich als primäre Anwendung festlegen?]]></item>
+ <item name="wcf.acp.application.setAsPrimary.success"><![CDATA[„{$application->getPackage()->getName()}“ ist nun die primäre Anwendung]]></item>
</category>
<category name="wcf.acp.cache">