Added ability to remove application groups
authorAlexander Ebert <ebert@woltlab.com>
Sun, 4 Nov 2012 23:00:48 +0000 (00:00 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 4 Nov 2012 23:00:48 +0000 (00:00 +0100)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/applicationManagement.tpl
wcfsetup/install/files/lib/data/application/group/ApplicationGroupAction.class.php
wcfsetup/install/lang/de.xml

index 2b2fcdcce5b3bc1b05e42dc86c819a06a065028e..f8b33b61d562d149bc0db6ea4134046afe0307b0 100644 (file)
  */
 WCF.ACP = {};
 
+/**
+ * Namespace for ACP application management.
+ */
+WCF.ACP.Application = { };
+
+/**
+ * Namespace for ACP application group management.
+ */
+WCF.ACP.Application.Group = { };
+
+/**
+ * Provides the ability to remove application groups.
+ */
+WCF.ACP.Application.Group.Delete = Class.extend({
+       /**
+        * Initializes the WCF.ACP.Application.Group.Delete class.
+        */
+       init: function() {
+               $('.jsDeleteApplicationGroup').click($.proxy(this._click, this));
+       },
+       
+       /**
+        * Shows a confirmation dialog to remove an application group.
+        * 
+        * @param       object          event
+        */
+       _click: function(event) {
+               var $button = $(event.currentTarget);
+               
+               WCF.System.Confirmation.show($button.data('confirmMessage'), $.proxy(function(action) {
+                       if (action === 'confirm') {
+                               this._remove($button.data('groupID'));
+                       }
+               }, this));
+       },
+       
+       /**
+        * Removes an application group.
+        * 
+        * @param       integer         groupID
+        */
+       _remove: function(groupID) {
+               new WCF.Action.Proxy({
+                       autoSend: true,
+                       data: {
+                               actionName: 'delete',
+                               className: 'wcf\\data\\application\\group\\ApplicationGroupAction',
+                               objectIDs: [ groupID ]
+                       },
+                       success: $.proxy(function(data, textStatus, jqXHR) {
+                               var $notification = new WCF.System.Notification(WCF.Language.get('wcf.acp.application.group.delete.success'));
+                               $notification.show(function() {
+                                       window.location.reload();
+                               });
+                       }, this)
+               });
+       }
+});
+
 /**
  * Handles ACPMenu.
  * 
index 31de66ab166b9f358acced51d6b5062f4f7224a3..a0efef1c43433d63652a10ddee290fd1eed00f2a 100644 (file)
@@ -1,5 +1,17 @@
 {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>
@@ -42,7 +54,7 @@
                <nav>
                        <ul>
                                <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>
-                               <li><a href="{link controller='ApplicationGroupDelete' id=$applicationGroup->groupID}{/link}" class="button"><img src="{@RELATIVE_WCF_DIR}icon/delete.svg" class="icon24" /> <span>{lang}wcf.acp.application.group.delete{/lang}</span></a></li>
+                               <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>
                        </ul>
                </nav>
        </div>
index dba0c9ba3c07ec70c8892a1e3d34105a1d16d9d6..3db19655c1f9840b63bd946e7e394fbcdad915d7 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\application\group;
 use wcf\data\application\ApplicationAction;
+use wcf\data\application\ApplicationList;
 use wcf\data\AbstractDatabaseObjectAction;
 
 /**
@@ -19,6 +20,11 @@ class ApplicationGroupAction extends AbstractDatabaseObjectAction {
         */
        protected $className = 'wcf\data\application\group\ApplicationGroupEditor';
        
+       /**
+        * @see wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
+        */
+       protected $permissionsDelete = array('admin.system.canManageApplication');
+       
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::create()
         */
@@ -32,4 +38,25 @@ class ApplicationGroupAction extends AbstractDatabaseObjectAction {
                
                return $applicationGroup;
        }
+       
+       /**
+        * @see wcf\data\AbstractDatabaseObjectAction::delete()
+        */
+       public function delete() {
+               $groupIDs = array();
+               foreach ($this->objects as $applicationGroup) {
+                       $groupIDs[] = $applicationGroup->groupID;
+               }
+               
+               // read all applications associated by affected groups
+               $applicationList = new ApplicationList();
+               $applicationList->getConditionBuilder()->add("application.groupID IN (?)", array($groupIDs));
+               $applicationList->sqlLimit = 0;
+               $applicationList->readObjects();
+               
+               $applicationAction = new ApplicationAction($applicationList->getObjects(), 'ungroup');
+               $applicationAction->executeAction();
+               
+               return parent::delete();
+       }
 }
index ef85012233ab92a126c406253a8b5b980208a5f2..83fab5c3bfac554c6627a26ce5b35fa3d9556837 100644 (file)
@@ -27,6 +27,8 @@
                <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 &bdquo;{$applicationGroup->groupName}&ldquo; 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>