Enhances application management
authorMatthias Schmidt <gravatronics@live.com>
Sun, 11 Nov 2012 15:50:13 +0000 (16:50 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 11 Nov 2012 15:50:13 +0000 (16:50 +0100)
Changes:

* Adds missing permission for `wcf\acp\page\ApplicationManagementPage`.
* Adds check if a new application group can be added and displays the button only if that's the case.
* Changes applicationGroupAdd.tpl so that an error is shown if no application group can added.
* If an application group has been added and no further application group can be added, the user is redirected to the application group management.

wcfsetup/install/files/acp/templates/applicationGroupAdd.tpl
wcfsetup/install/files/acp/templates/applicationManagement.tpl
wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php
wcfsetup/install/files/lib/acp/page/ApplicationManagementPage.class.php

index d9b5a5b0976135424bc06cdc91531f5f34e1b656..9835c7bbf92ecc4190f574942e92b0d53f19783c 100644 (file)
        </nav>
 </div>
 
-<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>
+{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>
                        
-                       {if $availableApplications|count > 1}
+                       <fieldset{if $errorField == 'applications'} class="formError"{/if}>
+                               <legend>{lang}wcf.acp.application.group.availableApplications{/lang}</legend>
+                               
                                <div class="tabularBox">
                                        <table class="table">
                                                <thead>
                                                {/if}
                                        </small>
                                {/if}
-                       {else}
-                               <p class="info">{lang}wcf.acp.application.group.noAvailableApplications{/lang}</p>
-                       {/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>
+                       </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'}
index c308ea0dee87c3c1ec22022855cdea5d0de33d09..8083c34877b0862e345f0d72bdc8dac927c68c0e 100644 (file)
                        </tbody>
                </table>
        </div>
-       
+{/hascontent}
+
+{hascontent}
        <div class="contentNavigation">
                <nav>
                        <ul>
-                               <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>
+                               {content}
+                                       {if $canAddApplicationGroup}
+                                               <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>
index 58c395aef81175820afd57dba604238687bcfd7a..0037f93c9a264f0b1f03fe9997cd75c39bb4dfdf 100644 (file)
@@ -3,8 +3,10 @@ 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;
 
 /**
@@ -179,7 +181,11 @@ class ApplicationGroupAddForm extends ACPForm {
                // reload available applications
                $this->readAvailableApplications();
                
-               // show success.
+               if (count($this->availableApplications) <= 1) {
+                       HeaderUtil::redirect(LinkHandler::getInstance()->getLink('ApplicationManagement'));
+               }
+               
+               // show success
                WCF::getTPL()->assign(array(
                        'success' => true
                ));
index d3e0dbe750feda59927219e8f2c77c22a5feaa38..8c9da2497ccc75e3832e485b94970f60bb338fab 100644 (file)
@@ -15,7 +15,7 @@ use wcf\system\WCF;
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage acp.page
- * @category   Community Framework
+ * @category   Community Framework
  */
 class ApplicationManagementPage extends AbstractPage {
        /**
@@ -30,12 +30,23 @@ class ApplicationManagementPage extends AbstractPage {
         */
        public $applicationGroups = null;
        
+       /**
+        * indicates if an application group can be created
+        * @var boolean
+        */
+       public $canAddApplicationGroup = true;
+       
        /**
         * number of ungrouped applications
         * @var integer
         */
        public $ungroupedApplications = 0;
        
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.system.canManageApplication');
+       
        /**
         * @see wcf\page\IPage::readData()
         */
@@ -61,6 +72,8 @@ class ApplicationManagementPage extends AbstractPage {
                                $this->applicationGroups[$application->groupID]->addApplication($application);
                        }
                }
+               
+               $this->canAddApplicationGroup = count($applicationList) > 1 && count($this->applications) > 0;
        }
        
        /**
@@ -71,7 +84,8 @@ class ApplicationManagementPage extends AbstractPage {
                
                WCF::getTPL()->assign(array(
                        'applications' => $this->applications,
-                       'applicationGroups' => $this->applicationGroups
+                       'applicationGroups' => $this->applicationGroups,
+                       'canAddApplicationGroup' => $this->canAddApplicationGroup
                ));
        }
        
@@ -81,7 +95,7 @@ class ApplicationManagementPage extends AbstractPage {
        public function show() {
                // enable menu item
                ACPMenu::getInstance()->setActiveMenuItem('wcf.acp.menu.link.application.management');
-       
+               
                parent::show();
        }
 }