[FEATURE] Add backend user groups to backend user module 99/36499/14
authorIngo Pfennigstorf <i.pfennigstorf@gmail.com>
Mon, 2 Feb 2015 09:41:00 +0000 (10:41 +0100)
committerFrank Nägler <typo3@naegler.net>
Tue, 17 Mar 2015 09:20:11 +0000 (10:20 +0100)
The backend user module lacks the possibility to easily list and
edit backend user groups. Add this functionality now.

Resolves: #64686
Releases: master
Change-Id: I5ddbdd03de2248619e0937d4d35e3998cbc83e40
Reviewed-on: http://review.typo3.org/36499
Reviewed-by: Ingo Pfennigstorf <i.pfennigstorf@gmail.com>
Tested-by: Ingo Pfennigstorf <i.pfennigstorf@gmail.com>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
12 files changed:
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
typo3/sysext/beuser/Classes/Controller/BackendUserGroupController.php [new file with mode: 0644]
typo3/sysext/beuser/Classes/Domain/Model/BackendUserGroup.php
typo3/sysext/beuser/Classes/Domain/Repository/BackendUserGroupRepository.php
typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php
typo3/sysext/beuser/Configuration/TypoScript/setup.txt
typo3/sysext/beuser/Resources/Private/Language/locallang.xlf
typo3/sysext/beuser/Resources/Private/Layouts/Default.html
typo3/sysext/beuser/Resources/Private/Partials/BackendUserGroup/IndexListRow.html [new file with mode: 0644]
typo3/sysext/beuser/Resources/Private/Templates/BackendUserGroup/Index.html [new file with mode: 0644]
typo3/sysext/beuser/ext_tables.php
typo3/sysext/core/Documentation/Changelog/master/Feature-64686-AddBackendUserGroupsToBackendUserModule.rst [new file with mode: 0644]

index b0888b9..eb93857 100644 (file)
@@ -636,7 +636,7 @@ class ElementInformationController {
                        }
                        $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
                        $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
-                       $icon = IconUtility::getSpriteIconForRecord($row['tablename'], $record);
+                       $icon = (is_array($record)) ? IconUtility::getSpriteIconForRecord($row['tablename'], $record) : '';
                        $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
                        $editOnClick = BackendUtility::editOnClick('&edit[' . $row['tablename'] . '][' . $row['recuid'] . ']=edit', $GLOBALS['BACK_PATH']);
                        $infoData[] = '
diff --git a/typo3/sysext/beuser/Classes/Controller/BackendUserGroupController.php b/typo3/sysext/beuser/Classes/Controller/BackendUserGroupController.php
new file mode 100644 (file)
index 0000000..9587157
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+namespace TYPO3\CMS\Beuser\Controller;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+
+/**
+ * Backend module user group administration controller
+ *
+ * @author Ingo Pfennigstorf <i.pfennigstorf@gmail.com>
+ */
+class BackendUserGroupController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
+
+       /**
+        * @var \TYPO3\CMS\Beuser\Domain\Repository\BackendUserGroupRepository
+        * @inject
+        */
+       protected $backendUserGroupRepository;
+
+       /**
+        * Initialize actions
+        *
+        * @return void
+        * @throws \RuntimeException
+        */
+       public function initializeAction() {
+               // @TODO: Extbase backend modules relies on frontend TypoScript for view, persistence
+               // and settings. Thus, we need a TypoScript root template, that then loads the
+               // ext_typoscript_setup.txt file of this module. This is nasty, but can not be
+               // circumvented until there is a better solution in extbase.
+               // For now we throw an exception if no settings are detected.
+               if (empty($this->settings)) {
+                       throw new \RuntimeException('No settings detected. This module can not work then. This usually happens if there is no frontend TypoScript template with root flag set. ' . 'Please create a frontend page with a TypoScript root template.', 1344375003);
+               }
+       }
+
+       /**
+        * Displays all BackendUserGroups
+        *
+        * @return void
+        */
+       public function indexAction() {
+               $this->view->assign('backendUserGroups', $this->backendUserGroupRepository->findAll());
+       }
+}
index 118d059..f2e3a78 100644 (file)
@@ -27,6 +27,11 @@ class BackendUserGroup extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
        protected $title;
 
        /**
+        * @var bool
+        */
+       protected $hidden;
+
+       /**
         * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup>
         * @lazy
         */
@@ -47,6 +52,20 @@ class BackendUserGroup extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
        }
 
        /**
+        * @param bool $hidden
+        */
+       public function setHidden($hidden) {
+               $this->hidden = $hidden;
+       }
+
+       /**
+        * @return bool
+        */
+       public function getHidden() {
+               return $this->hidden;
+       }
+
+       /**
         * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $subGroups
         */
        public function setSubGroups($subGroups) {
index 0908f08..64cc0ec 100644 (file)
@@ -27,4 +27,15 @@ class BackendUserGroupRepository extends \TYPO3\CMS\Extbase\Persistence\Reposito
        protected $defaultOrderings = array(
                'title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
        );
+
+       /**
+        * Overwrite createQuery to don't respect enable fields
+        *
+        * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
+        */
+       public function createQuery() {
+               $query = parent::createQuery();
+               $query->getQuerySettings()->setIgnoreEnableFields(TRUE);
+               return $query;
+       }
 }
index 1d4ef60..d9111e5 100644 (file)
@@ -42,6 +42,9 @@ class SpriteIconForRecordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\Abst
                if (method_exists($object, 'getIsDisabled')) {
                        $row['disable'] = $object->getIsDisabled();
                }
+               if (method_exists($object, 'getHidden')) {
+                       $row['hidden'] = $object->getHidden();
+               }
                if ($table === 'be_users' && $object instanceof \TYPO3\CMS\Beuser\Domain\Model\BackendUser) {
                        $row['admin'] = $object->getIsAdministrator();
                }
index 918cb33..6ec5be8 100644 (file)
@@ -27,10 +27,10 @@ module.tx_beuser {
        }
 
        settings {
-                       // This is a dummy entry. It is used in  Tx_Beuser_Controller_BackendUserController
-                       // to test that some TypoScript configuration is set.
-                       // This entry can be removed if extbase setup is made frontend TS independent
-                       // or if there are other settings set.
+               // This is a dummy entry. It is used in \TYPO3\CMS\Beuser\Controller\BackendUserController
+               // to test that some TypoScript configuration is set.
+               // This entry can be removed if extbase setup is made frontend TS independent
+               // or if there are other settings set.
                dummy = foo
        }
 }
\ No newline at end of file
index 5231242..95a811c 100644 (file)
@@ -21,6 +21,9 @@
                        <trans-unit id="backendUserListing" xml:space="preserve">
                                <source>Backend User Listing</source>
                        </trans-unit>
+                       <trans-unit id="subGroups" xml:space="preserve">
+                               <source>Sub Groups</source>
+                       </trans-unit>
                        <trans-unit id="email" xml:space="preserve">
                                <source>Email</source>
                        </trans-unit>
                        <trans-unit id="backendUsers" xml:space="preserve">
                                <source>Backend users</source>
                        </trans-unit>
+                       <trans-unit id="backendUserGroupsMenu" xml:space="preserve">
+                               <source>Backend user groups</source>
+                       </trans-unit>
                        <trans-unit id="onlineUsers" xml:space="preserve">
                                <source>Online users</source>
                        </trans-unit>
                        <trans-unit id="terminateSessionSuccess" xml:space="preserve">
                                <source>Session successfully terminated.</source>
                        </trans-unit>
+                       <trans-unit id="backendUserGroupListing" xml:space="preserve">
+                               <source>Backend User Group Listing</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index ae428ab..f01c92b 100644 (file)
@@ -6,6 +6,7 @@
                                        <f:be.buttons.csh />
                                        <f:be.menus.actionMenu>
                                                <f:be.menus.actionMenuItem label="{f:translate(key: 'backendUsers')}" controller="BackendUser" action="index" />
+                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'backendUserGroupsMenu')}" controller="BackendUserGroup" action="index" />
                                                <f:be.menus.actionMenuItem label="{f:translate(key: 'onlineUsers')}" controller="BackendUser" action="online" />
                                        </f:be.menus.actionMenu>
                                </div>
diff --git a/typo3/sysext/beuser/Resources/Private/Partials/BackendUserGroup/IndexListRow.html b/typo3/sysext/beuser/Resources/Private/Partials/BackendUserGroup/IndexListRow.html
new file mode 100644 (file)
index 0000000..99a169c
--- /dev/null
@@ -0,0 +1,38 @@
+{namespace be = TYPO3\CMS\Backend\ViewHelpers}
+{namespace bu = TYPO3\CMS\Beuser\ViewHelpers}
+
+<tr>
+       <td class="col-icon">
+               <a href="#" class="t3-js-clickmenutrigger" data-table="be_groups" data-uid="{backendUserGroup.uid}" data-listframe="1" title="id={backendUserGroup.uid}">
+                       <bu:spriteIconForRecord table="be_groups" object="{backendUserGroup}" />
+               </a>
+       </td>
+       <td class="col-title">
+               <a href="#" onclick="document.location.href='alt_doc.php?edit[be_groups][{backendUserGroup.uid}]=edit&amp;returnUrl='+T3_THIS_LOCATION">
+                       <b>{backendUserGroup.title}</b><br />
+                       {backendUser.realName}
+               </a>
+       </td>
+       <td>
+               <f:for each="{backendUserGroup.subgroups}" as="subgroup" iteration="subGroupIterator">
+                       <a href="alt_doc.php?edit[be_groups][{subgroup.uid}]=edit&amp;returnUrl={returnUrl}">
+                               {subgroup.title}
+                       </a>
+                       <f:if condition="{subGroupIterator.isLast}"><f:else>, </f:else></f:if>
+               </f:for>
+       </td>
+       <td class="col-control">
+               <div class="btn-group" role="group">
+                       <a class="btn btn-default" href="#" onclick="top.launchView('be_groups', '{backendUserGroup.uid}'); return false;"><be:spriteManagerIcon iconName="actions-document-info" /></a>
+                       <a class="btn btn-default" href="#" onclick="document.location.href='alt_doc.php?edit[be_groups][{backendUserGroup.uid}]=edit&amp;returnUrl='+T3_THIS_LOCATION"><be:spriteManagerIcon iconName="actions-document-open" /></a>
+                       <f:if condition="{backendUserGroup.hidden}">
+                               <f:then>
+                                       <a class="btn btn-default" href="{bu:issueCommand(parameters: 'data[be_groups][{backendUserGroup.uid}][hidden]=0', redirectUrl: redirectUrl)}"><be:spriteManagerIcon iconName="actions-edit-unhide" options="{title: 'unhide'}" /></a>
+                               </f:then>
+                               <f:else>
+                                       <a class="btn btn-default" href="{bu:issueCommand(parameters: 'data[be_groups][{backendUserGroup.uid}][hidden]=1', redirectUrl: redirectUrl)}"><be:spriteManagerIcon iconName="actions-edit-hide" options="{title: 'hide'}" /></a>
+                               </f:else>
+                       </f:if>
+               </div>
+       </td>
+</tr>
diff --git a/typo3/sysext/beuser/Resources/Private/Templates/BackendUserGroup/Index.html b/typo3/sysext/beuser/Resources/Private/Templates/BackendUserGroup/Index.html
new file mode 100644 (file)
index 0000000..f3096da
--- /dev/null
@@ -0,0 +1,47 @@
+{namespace be = TYPO3\CMS\Backend\ViewHelpers}
+{namespace bu = TYPO3\CMS\Beuser\ViewHelpers}
+
+<f:layout name="Default" />
+
+<f:section name="iconButtons">
+       <a href="#" onclick="window.location.href='alt_doc.php?returnUrl=' + T3_THIS_LOCATION + '&amp;edit[be_groups][0]=new'; return false;"><be:spriteManagerIcon iconName="actions-document-new" /></a>
+</f:section>
+
+<f:section name="headline">
+       <h1><f:translate key="backendUserGroupListing" /></h1>
+</f:section>
+
+<f:section name="content">
+
+       <f:comment>
+               Listing of all user groups
+       </f:comment>
+       <f:be.widget.paginate objects="{backendUserGroups}" as="paginatedBackendUserGroups" configuration="{itemsPerPage: 50, insertBelow: 1}">
+               <div class="table-fit">
+                       <table class="table table-striped table-hover">
+                               <thead>
+                                       <tr>
+                                               <th class="col-icon"></th>
+                                               <th class="col-title"><f:translate key="backendUserGroup" /></th>
+                                               <th><f:translate key="subGroups" /></th>
+                                               <th class="col-control"></th>
+                                       </tr>
+                               </thead>
+                               <tbody>
+                                       <f:for each="{paginatedBackendUserGroups}" as="backendUserGroup">
+                                               <f:render partial="BackendUserGroup/IndexListRow" arguments="{demand: demand, backendUserGroup: backendUserGroup, dateFormat: dateFormat, timeFormat: timeFormat, returnUrl: returnUrl}" />
+                                       </f:for>
+                                       <f:comment>
+                                               Footer row: no officially defined style yet
+                                       </f:comment>
+                                       <tr>
+                                               <td colspan="4">
+                                                       <f:count subject="{backendUserGroups}" /> <f:translate key="LLL:EXT:lang/locallang_tca.xlf:be_groups" />s
+                                               </td>
+                                       </tr>
+                               </tbody>
+                       </table>
+               </div>
+       </f:be.widget.paginate>
+
+</f:section>
index e628fdb..87109d6 100644 (file)
@@ -9,7 +9,8 @@ if (TYPO3_MODE === 'BE') {
                'tx_Beuser',
                'top',
                array(
-                       'BackendUser' => 'index, addToCompareList, removeFromCompareList, compare, online, terminateBackendUserSession'
+                       'BackendUser' => 'index, addToCompareList, removeFromCompareList, compare, online, terminateBackendUserSession',
+                       'BackendUserGroup' => 'index'
                ),
                array(
                        'access' => 'admin',
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-64686-AddBackendUserGroupsToBackendUserModule.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-64686-AddBackendUserGroupsToBackendUserModule.rst
new file mode 100644 (file)
index 0000000..f58c3c3
--- /dev/null
@@ -0,0 +1,9 @@
+================================================================
+Feature: #64686 - Add backend user groups to backend user module
+================================================================
+
+Description
+===========
+
+The backend user groups can be maintained in a submodule of the
+"Backend users" backend module now.
\ No newline at end of file