From 55e4ba8634caf29c1e8a7f90d4ec9be9d47555a5 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 19 May 2011 16:25:07 +0000 Subject: [PATCH] hide tools that are not usable --- lam/lib/tools.inc | 9 ++++++++- 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 | 11 ++++++++++- lam/templates/main_header.php | 4 ++++ lam/templates/tools.php | 6 +++++- 10 files changed, 87 insertions(+), 9 deletions(-) diff --git a/lam/lib/tools.inc b/lam/lib/tools.inc index ada048fc..63450070 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -126,6 +126,13 @@ interface LAMTool { */ function getSubTools(); + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible(); + } /** diff --git a/lam/lib/tools/fileUpload.inc b/lam/lib/tools/fileUpload.inc index 801933f2..8332dcf1 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolFileUpload implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/ouEditor.inc b/lam/lib/tools/ouEditor.inc index cf6480cf..ac215808 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolOUEditor implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/pdfEdit.inc b/lam/lib/tools/pdfEdit.inc index 93c641b7..e0421a03 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolPDFEditor implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/profileEditor.inc b/lam/lib/tools/profileEditor.inc index aad3c6e5..1e356788 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolProfileEditor implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/schemaBrowser.inc b/lam/lib/tools/schemaBrowser.inc index 25e31fd1..9cd28d9d 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolSchemaBrowser implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/serverInfo.inc b/lam/lib/tools/serverInfo.inc index bcc5acc1..b5f8d308 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -108,6 +108,15 @@ class toolServerInformation implements LAMTool { return array(); } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/tests.inc b/lam/lib/tools/tests.inc index b96d9615..dea93517 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 - 2010 Roland Gruber + Copyright (C) 2009 - 2011 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 @@ -121,6 +121,15 @@ class toolTests implements LAMTool { return $return; } + /** + * Returns if the tool is visible in the menu. + * + * @return boolean visible + */ + function isVisible() { + return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); + } + } ?> \ No newline at end of file diff --git a/lam/templates/main_header.php b/lam/templates/main_header.php index 55dd52f7..fec02a3a 100644 --- a/lam/templates/main_header.php +++ b/lam/templates/main_header.php @@ -77,6 +77,10 @@ for ($i = 0; $i < sizeof($availableTools); $i++) { if ($myTool->getRequiresPasswordChangeRights() && !checkIfPasswordChangeIsAllowed()) { continue; } + // check visibility + if (!$myTool->isVisible()) { + continue; + } $toSort[$availableTools[$i]] = $myTool->getPosition(); } asort($toSort); diff --git a/lam/templates/tools.php b/lam/templates/tools.php index ad5b5ac7..f7a04996 100644 --- a/lam/templates/tools.php +++ b/lam/templates/tools.php @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2010 Roland Gruber + Copyright (C) 2003 - 2011 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 @@ -70,6 +70,10 @@ for ($i = 0; $i < sizeof($tools); $i++) { if ($tools[$i]->getRequiresPasswordChangeRights() && !checkIfPasswordChangeIsAllowed()) { continue; } + // check visibility + if (!$tools[$i]->isVisible()) { + continue; + } // add tool $container->addElement(new htmlLink($tools[$i]->getName(), $tools[$i]->getLink(), '../graphics/' . $tools[$i]->getImageLink())); $container->addElement(new htmlSpacer('10px', null));