commit 360ad02dc699056639137475fe3127d687fc58f2 Author: ThomasDartsch Date: Wed Aug 7 14:50:54 2019 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa75bac --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# DisableAdminElements +Hide unused menu items in the oxid eshop admin + +## Features + +* you can hide any element of the xml files (e.g. menu.xml) like navigation or tab elements +* you only need the id of the element node (e.g. 'tbclorder_downloads' or 'mxwrapping') + + +## Install + +* Run this composer statement in your shop. Adjust this instruction if your installation requires it. + + `composer require d3/disableadminelements --update-no-dev` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c09ec23 --- /dev/null +++ b/composer.json @@ -0,0 +1,38 @@ +{ + "name": "d3/disableadminelements", + "description": "Ausblenden von Menuepunkten im Admin", + "type": "oxideshop-module", + "version": "1.0", + "keywords": [ + "oxid", + "modules", + "eShop", + "d3" + ], + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "http://www.d3data.de", + "role": "Owner" + } + ], + "homepage": "https://www.oxidmodule.com/", + "license": [ + "GPL-3.0-or-later" + ], + "extra": { + "oxideshop": { + "source-directory": "/src", + "target-directory": "d3/disableadminelements" + } + }, + "require": { + "oxid-esales/oxideshop-metapackage-ce": "~6.0.0 || ~6.1.0" + }, + "autoload": { + "psr-4": { + "D3\\DisableAdminElements\\": "../../../source/modules/d3/disableadminelements" + } + } +} diff --git a/src/Application/views/admin/de/disableadminelements_lang.php b/src/Application/views/admin/de/disableadminelements_lang.php new file mode 100644 index 0000000..d3475e9 --- /dev/null +++ b/src/Application/views/admin/de/disableadminelements_lang.php @@ -0,0 +1,10 @@ + 'UTF-8', + 'SHOP_MODULE_GROUP_d3disableAdminElements_group' => 'Einstellungen', + 'SHOP_MODULE_d3disableAdminElements_elemtentlist' => 'Trage hier alle Idents (id) der auszublendenen Menüpunkte aus der menu.xml ein. z.B. "tbclorder_downloads"', + +); diff --git a/src/Modules/Application/Controller/Admin/NavigationTree.php b/src/Modules/Application/Controller/Admin/NavigationTree.php new file mode 100644 index 0000000..55c10cc --- /dev/null +++ b/src/Modules/Application/Controller/Admin/NavigationTree.php @@ -0,0 +1,51 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\DisableAdminElements\Modules\Application\Controller\Admin; + +use OxidEsales\Eshop\Core\Registry; +use DOMXPath; + +class NavigationTree extends NavigationTree_parent +{ + + /** + * clean empty nodes from tree + * + * @param object $dom dom object + * @param string $parentXPath parent xpath + * @param string $childXPath child xpath from parent + */ + protected function _cleanEmptyParents($dom, $parentXPath, $childXPath) + { + parent::_cleanEmptyParents($dom, $parentXPath, $childXPath); + + $xPath = new DomXPath($dom); + $nodeList = $xPath->query($parentXPath); + + foreach ($nodeList as $node) { + $id = $node->getAttribute('id'); + $childList = $xPath->query("{$parentXPath}[@id='$id']/$childXPath"); + + $aListOfDisabledElements = Registry::getConfig()->getShopConfVar( 'd3disableAdminElements_elemtentlist'); + + foreach($childList as $id => $node) { + + if (in_array($node->getAttribute('id'), $aListOfDisabledElements) ) { + $node->parentNode->removeChild($node); + } + } + + } + + } +} \ No newline at end of file diff --git a/src/metadata.php b/src/metadata.php new file mode 100644 index 0000000..d42e8b7 --- /dev/null +++ b/src/metadata.php @@ -0,0 +1,42 @@ + 'disableadminelements', + 'title' => + (class_exists(d3utils::class) ? d3utils::getInstance()->getD3Logo() : 'D³') . ' Ausblenden von ungenutzen Menüpunkten im Admin', + 'description' => array( + 'de' => 'Tragen Sie in den Einstellungen die id der gewünschten Elemente (Menüpunkte, Tabs etc.) aus den menu.xml Dateien ein und das jeweilige Element wird für alle Adminbenutzer ausgeblendet.', + 'en' => '', + ), + 'thumbnail' => 'picture.png', + 'version' => '1.0', + 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', + 'email' => 'support@shopmodule.com', + 'url' => 'http://www.oxidmodule.com/', + 'extend' => [ + NavigationTree::class => D3NavigationTree::class, + ], + + 'settings' => array( + + array( + 'group' => 'd3disableAdminElements_group', + 'name' => 'd3disableAdminElements_elemtentlist', + 'type' => 'arr', + 'value' => array('tbclorder_downloads', 'tbclarticle_files'), + ), + + ), + +); \ No newline at end of file