From 537c01a47dd3b157cdc15591a81268e0221e1678 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 3 Dec 2010 21:06:36 +0000 Subject: [PATCH] display tools as menu --- lam/graphics/lamdaemonSmall.png | Bin 0 -> 528 bytes lam/graphics/schemaTest.png | Bin 0 -> 611 bytes lam/lib/html.inc | 4 +- lam/lib/tools.inc | 28 +++++++++++- lam/lib/tools/fileUpload.inc | 11 ++++- lam/lib/tools/ouEditor.inc | 11 ++++- lam/lib/tools/pdfEdit.inc | 11 ++++- lam/lib/tools/profileEditor.inc | 11 ++++- lam/lib/tools/schemaBrowser.inc | 11 ++++- lam/lib/tools/serverInfo.inc | 11 ++++- lam/lib/tools/tests.inc | 24 +++++++++- lam/templates/main_header.php | 76 +++++++++++++++++++++++++++++--- lam/templates/tests/index.php | 4 +- 13 files changed, 184 insertions(+), 18 deletions(-) create mode 100644 lam/graphics/lamdaemonSmall.png create mode 100644 lam/graphics/schemaTest.png diff --git a/lam/graphics/lamdaemonSmall.png b/lam/graphics/lamdaemonSmall.png new file mode 100644 index 0000000000000000000000000000000000000000..896498a85ba50c35b54ac0a1c71f2a69cedf1c30 GIT binary patch literal 528 zcmV+r0`L8aP);Don<25IFRW;zh-Q4^HKEx*Cox{C|1W6J^ghT`ooJ)u?5@Te& z+04C&@cH6`!C=6@C|)OC&bz5`HI?(gqA;66hyZ8Dq97>!0WO~cvQ z8I#Ebfc1LK-Q69l)$0Eu(lVIO=j3^gh%lK<@ZM8Z6%P*&WLZX6@ z|MiQ68OJ9lIOjUMPTD-_b&4_4G!47m?j?W$=jZ3BDn(I{Wf|UkoO6f>`#n)rLI{Kq zST2`;MT||9FIQKjX-dOhEe3<_zUB`ctTSGo S4BOWL0000Jb3WdljzkR{GcF|(vyluFRg+gWYdd{ z7ZIu;c#>RVM5(4qqswONE=jigK3+DVt$XML1H&-$V`i8U(=>@tB;or$T-QZ1nM6Du zho)&bsl~-b8Txt{K-Y1w{c0P{=4YghG%TwNrF>K>S1>m>J1VZ#YR74&Y0~pNuCJ|g zD5VsYQY6WH_aCs;`ohD*Lz1Lvnk0##X(X|^`3zUDT?a`hr9g5t(%n0^v9a+yaufj2 z`u#pSe-2Q{jYBB~MIK8a37kp6w(V$u<2c9_W<~)45QK%pPR7Txuq-PYU>F8m*MW#Y ziNFS+k)Q~aQel>cR4Nq>NF)-l_P=7^2Xqlo(*O~~M4;X=0ajL4FmquRw&R=~?cgLJ%9K*r+Sv|pUcXqJ0x;i;MU2N>_{hCC0+w?q-ytext = htmlspecialchars($text); diff --git a/lam/lib/tools.inc b/lam/lib/tools.inc index e789a917..ada048fc 100644 --- a/lam/lib/tools.inc +++ b/lam/lib/tools.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -119,6 +119,32 @@ interface LAMTool { */ function getPosition(); + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools(); + +} + +/** + * Represents a subtool. + * + * @author Roland Gruber + * @package tools + */ +class LAMSubTool { + + /** visible tool name */ + public $name; + /** tool description */ + public $description; + /** tool link (relative to templates/) */ + public $link; + /** image URL (relative to graphics/) */ + public $image; + } ?> \ No newline at end of file diff --git a/lam/lib/tools/fileUpload.inc b/lam/lib/tools/fileUpload.inc index f2b8f8b9..801933f2 100644 --- a/lam/lib/tools/fileUpload.inc +++ b/lam/lib/tools/fileUpload.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolFileUpload implements LAMTool { return 200; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/ouEditor.inc b/lam/lib/tools/ouEditor.inc index 7edcfe72..cf6480cf 100644 --- a/lam/lib/tools/ouEditor.inc +++ b/lam/lib/tools/ouEditor.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolOUEditor implements LAMTool { return 300; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/pdfEdit.inc b/lam/lib/tools/pdfEdit.inc index 7df41336..93c641b7 100644 --- a/lam/lib/tools/pdfEdit.inc +++ b/lam/lib/tools/pdfEdit.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolPDFEditor implements LAMTool { return 400; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/profileEditor.inc b/lam/lib/tools/profileEditor.inc index 008a7630..aad3c6e5 100644 --- a/lam/lib/tools/profileEditor.inc +++ b/lam/lib/tools/profileEditor.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolProfileEditor implements LAMTool { return 100; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/schemaBrowser.inc b/lam/lib/tools/schemaBrowser.inc index da26f017..25e31fd1 100644 --- a/lam/lib/tools/schemaBrowser.inc +++ b/lam/lib/tools/schemaBrowser.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolSchemaBrowser implements LAMTool { return 500; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/serverInfo.inc b/lam/lib/tools/serverInfo.inc index d2fabc69..bcc5acc1 100644 --- a/lam/lib/tools/serverInfo.inc +++ b/lam/lib/tools/serverInfo.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,15 @@ class toolServerInformation implements LAMTool { return 600; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + return array(); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/tests.inc b/lam/lib/tools/tests.inc index 5ca74501..b96d9615 100644 --- a/lam/lib/tools/tests.inc +++ b/lam/lib/tools/tests.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 Roland Gruber + Copyright (C) 2009 - 2010 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,28 @@ class toolTests implements LAMTool { return 1000; } + /** + * Returns a list of sub tools or an empty array. + * + * @return array list of subtools (LAMTool) + */ + function getSubTools() { + $return = array(); + $lamdaemonTest = new LAMSubTool(); + $lamdaemonTest->name = _("Lamdaemon test"); + $lamdaemonTest->link = 'tests/lamdaemonTest.php'; + $lamdaemonTest->description = _("Check if quotas and homedirectories can be managed."); + $lamdaemonTest->image = 'lamdaemonSmall.png'; + $return[] = $lamdaemonTest; + $schemaTest = new LAMSubTool(); + $schemaTest->name = _("Schema test"); + $schemaTest->link = 'tests/schemaTest.php'; + $schemaTest->description = _("Check if the LDAP schema fits the requirements of the selected account modules."); + $schemaTest->image = 'schemaTest.png'; + $return[] = $schemaTest; + return $return; + } + } ?> \ No newline at end of file diff --git a/lam/templates/main_header.php b/lam/templates/main_header.php index db6842b6..d6fd7b09 100644 --- a/lam/templates/main_header.php +++ b/lam/templates/main_header.php @@ -35,6 +35,9 @@ $headerPrefix = ""; if (is_file("../login.php")) $headerPrefix = "../"; elseif (is_file("../../login.php")) $headerPrefix = "../../"; +/** tool definitions */ +include_once($headerPrefix . "../lib/tools.inc"); + // HTML header and title echo $_SESSION['header']; echo "LDAP Account Manager\n"; @@ -62,6 +65,25 @@ foreach ($jsFiles as $jsEntry) { echo "\n"; } +// get tool list +$availableTools = getTools(); +// sort tools +$toSort = array(); +for ($i = 0; $i < sizeof($availableTools); $i++) { + $myTool = new $availableTools[$i](); + if ($myTool->getRequiresWriteAccess() && !checkIfWriteAccessIsAllowed()) { + continue; + } + if ($myTool->getRequiresPasswordChangeRights() && !checkIfPasswordChangeIsAllowed()) { + continue; + } + $toSort[$availableTools[$i]] = $myTool->getPosition(); +} +asort($toSort); +$tools = array(); +foreach ($toSort as $key => $value) { + $tools[] = new $key(); +} ?> @@ -69,23 +91,63 @@ foreach ($jsFiles as $jsEntry) { -
 LDAP Account Manager  LDAP Account Manager + +
+ +
    diff --git a/lam/templates/tests/index.php b/lam/templates/tests/index.php index f7827a49..9a1b07ef 100644 --- a/lam/templates/tests/index.php +++ b/lam/templates/tests/index.php @@ -47,13 +47,13 @@ echo "
    \n"; $container = new htmlTable(); $container->addElement(new htmlSubTitle(_("LAM tests")), true); -$container->addElement(new htmlLink(_("Lamdaemon test"), 'lamdaemonTest.php')); +$container->addElement(new htmlLink(_("Lamdaemon test"), 'lamdaemonTest.php', '../../graphics/lamdaemonSmall.png')); $container->addElement(new htmlSpacer('20px', null)); $container->addElement(new htmlOutputText(_("Check if quotas and homedirectories can be managed.")), true); $container->addElement(new htmlSpacer(null, '20px'), true); -$container->addElement(new htmlLink(_("Schema test"), 'schemaTest.php')); +$container->addElement(new htmlLink(_("Schema test"), 'schemaTest.php', '../../graphics/schemaTest.png')); $container->addElement(new htmlSpacer('20px', null)); $container->addElement(new htmlOutputText(_("Check if the LDAP schema fits the requirements of the selected account modules.")), true);