diff --git a/lam/HISTORY b/lam/HISTORY index bf54cdaf..a686a3ae 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,5 +1,6 @@ June 2012 - quick (un)lock for users + - allow to disable tools - LAM Pro: -> Custom fields module allows to manage custom LDAP attributes in Self Service -> Separate group of names module for users allows to manage memberships if Unix module is not used (RFE 3504429) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 5d85e150..e250eae9 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -208,6 +208,9 @@ class LAMConfig { /** type settings */ private $typeSettings = array(); + + /** tool settings */ + private $toolSettings = array(); /** * Path to external lamdaemon script on server where it is executed @@ -281,7 +284,7 @@ class LAMConfig { /** List of all settings in config file */ private $settings = array("ServerURL", "useTLS", "Passwd", "Admins", "treesuffix", "defaultLanguage", "scriptPath", "scriptServer", "scriptRights", "cachetimeout", - "modules", "activeTypes", "types", "accessLevel", 'loginMethod', 'loginSearchSuffix', + "modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix', 'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject', 'lamProMailText', 'lamProMailIsHTML', 'httpAuthentication', 'loginSearchDN', 'loginSearchPassword'); @@ -336,6 +339,12 @@ class LAMConfig { $pos = strpos($option, ":"); $this->typeSettings[substr($option, 0, $pos)] = substr($option, $pos + 2); } + // tool settings + elseif (strtolower(substr($line, 0, $keylen + 2)) == "tools: ") { + $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); + $pos = strpos($option, ":"); + $this->toolSettings[substr($option, 0, $pos)] = substr($option, $pos + 2); + } // general settings else { $this->$keyword = substr($line, $keylen + 2, strlen($line) - $keylen - 2); @@ -419,6 +428,15 @@ class LAMConfig { $file_array[$i] = "types: " . $name . ": " . $this->typeSettings[$name] . "\n"; $mod_saved[] = $name; // mark keyword as saved } + // tool settings + elseif (strtolower(substr($line, 0, $keylen + 2)) == "tools: ") { + $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); + $pos = strpos($option, ":"); + $name = substr($option, 0, $pos); + if (!isset($this->toolSettings[$name])) continue; + $file_array[$i] = "tools: " . $name . ": " . $this->toolSettings[$name] . "\n"; + $mod_saved[] = $name; // mark keyword as saved + } // general settings else { $file_array[$i] = $keyword . ": " . $this->$keyword . "\n"; @@ -470,6 +488,13 @@ class LAMConfig { array_push($file_array, "types: " . $t_settings[$i] . ": " . $this->typeSettings[$t_settings[$i]] . "\n"); } } + // check if all tool settings were added + $tool_settings = array_keys($this->toolSettings); + for ($i = 0; $i < sizeof($tool_settings); $i++) { + if (!in_array($tool_settings[$i], $mod_saved)) { + array_push($file_array, "tools: " . $tool_settings[$i] . ": " . $this->toolSettings[$tool_settings[$i]] . "\n"); + } + } $file = @fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -992,6 +1017,27 @@ class LAMConfig { return $this->typeSettings; } + /** + * Returns the tool settings. + * + * @return array $toolSettings tool settings + */ + public function getToolSettings() { + return $this->toolSettings; + } + + /** + * Sets the tool settings. + * + * @param array $toolSettings tool settings + * @return boolean true if ok + */ + public function setToolSettings($toolSettings) { + if (!is_array($toolSettings)) return false; + $this->toolSettings = $toolSettings; + return true; + } + /** * Returns the access level for this profile. * diff --git a/lam/lib/tools.inc b/lam/lib/tools.inc index 63450070..678b8818 100644 --- a/lam/lib/tools.inc +++ b/lam/lib/tools.inc @@ -133,6 +133,13 @@ interface LAMTool { */ function isVisible(); + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable(); + } /** diff --git a/lam/lib/tools/fileUpload.inc b/lam/lib/tools/fileUpload.inc index 8332dcf1..9001f415 100644 --- a/lam/lib/tools/fileUpload.inc +++ b/lam/lib/tools/fileUpload.inc @@ -117,6 +117,15 @@ class toolFileUpload implements LAMTool { return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return false; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/ouEditor.inc b/lam/lib/tools/ouEditor.inc index ac215808..b44c8a70 100644 --- a/lam/lib/tools/ouEditor.inc +++ b/lam/lib/tools/ouEditor.inc @@ -117,6 +117,15 @@ class toolOUEditor implements LAMTool { return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/pdfEdit.inc b/lam/lib/tools/pdfEdit.inc index e0421a03..948bd1a7 100644 --- a/lam/lib/tools/pdfEdit.inc +++ b/lam/lib/tools/pdfEdit.inc @@ -117,6 +117,15 @@ class toolPDFEditor implements LAMTool { return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return false; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/profileEditor.inc b/lam/lib/tools/profileEditor.inc index 1e356788..d464bc52 100644 --- a/lam/lib/tools/profileEditor.inc +++ b/lam/lib/tools/profileEditor.inc @@ -117,6 +117,15 @@ class toolProfileEditor implements LAMTool { return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return false; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/schemaBrowser.inc b/lam/lib/tools/schemaBrowser.inc index 9cd28d9d..adea0b71 100644 --- a/lam/lib/tools/schemaBrowser.inc +++ b/lam/lib/tools/schemaBrowser.inc @@ -117,6 +117,15 @@ class toolSchemaBrowser implements LAMTool { return true; } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/serverInfo.inc b/lam/lib/tools/serverInfo.inc index b5f8d308..b49f27e5 100644 --- a/lam/lib/tools/serverInfo.inc +++ b/lam/lib/tools/serverInfo.inc @@ -117,6 +117,15 @@ class toolServerInformation implements LAMTool { return true; } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/lib/tools/tests.inc b/lam/lib/tools/tests.inc index dea93517..f0a8be2f 100644 --- a/lam/lib/tools/tests.inc +++ b/lam/lib/tools/tests.inc @@ -130,6 +130,15 @@ class toolTests implements LAMTool { return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); } + /** + * Returns if a tool may be hidden by configuration in the LAM server profile. + * + * @return boolean hideable + */ + function isHideable() { + return true; + } + } ?> \ No newline at end of file diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index a342535e..1ea5003f 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -33,9 +33,10 @@ $Id$ /** Access to config functions */ include_once("../../lib/config.inc"); - /** access to module settings */ include_once("../../lib/modules.inc"); +/** access to tools */ +include_once("../../lib/tools.inc"); // start session if (strtolower(session_module_name()) == 'files') { @@ -338,6 +339,44 @@ if (isLAMProVersion()) { $container->addElement(new htmlSpacer(null, '10px'), true); } +// tool settings +$toolSettings = $conf->getToolSettings(); +$toolSettingsContent = new htmlTable(); +$toolsLabel = new htmlOutputText(_('Hidden tools')); +$toolsLabel->colspan = 5; +$toolSettingsContent->addElement($toolsLabel, true); +$tools = getTools(); +for ($i = 0; $i < sizeof($tools); $i++) { + $tool = new $tools[$i](); + if ($tool->isHideable()) { + $tools[$i] = $tool; + } + else { + unset($tools[$i]); + $i--; + $tools = array_values($tools); + } +} +for ($r = 0; $r < (sizeof($tools) / 4); $r++) { + for ($c = 0; $c < 4; $c++) { + if (!isset($tools[($r * 4) + $c])) { + break; + } + $tool = $tools[($r * 4) + $c]; + $toolClass = get_class($tool); + $selected = false; + if (isset($toolSettings['tool_hide_' . $toolClass]) && ($toolSettings['tool_hide_' . $toolClass] === 'true')) { + $selected = true; + } + $toolSettingsContent->addElement(new htmlTableExtendedInputCheckbox('tool_hide_' . $toolClass, $selected, $tool->getName(), null, false)); + $toolSettingsContent->addElement(new htmlSpacer('10px', null)); + } + $toolSettingsContent->addNewLine(); +} +$toolSettingsFieldset = new htmlFieldset($toolSettingsContent, _("Tool settings"), '../../graphics/bigTools.png'); +$container->addElement($toolSettingsFieldset, true); +$container->addElement(new htmlSpacer(null, '10px'), true); + // security setings $securitySettingsContent = new htmlTable(); // login method @@ -499,6 +538,19 @@ function checkInput() { if (!$conf->set_scriptrights($chmod)) { $errors[] = array("ERROR", _("Script rights are invalid!")); } + // tool settings + $tools = getTools(); + $toolSettings = array(); + for ($i = 0; $i < sizeof($tools); $i++) { + $toolConfigID = 'tool_hide_' . $tools[$i]; + if ((isset($_POST[$toolConfigID])) && ($_POST[$toolConfigID] == 'on')) { + $toolSettings[$toolConfigID] = 'true'; + } + else { + $toolSettings[$toolConfigID] = 'false'; + } + } + $conf->setToolSettings($toolSettings); // check if password was changed if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) { if ($_POST['passwd1'] != $_POST['passwd2']) { diff --git a/lam/templates/main_header.php b/lam/templates/main_header.php index df408355..9be9dc07 100644 --- a/lam/templates/main_header.php +++ b/lam/templates/main_header.php @@ -75,6 +75,7 @@ foreach ($jsFiles as $jsEntry) { // get tool list $availableTools = getTools(); +$toolSettings = $_SESSION['config']->getToolSettings(); // sort tools $toSort = array(); for ($i = 0; $i < sizeof($availableTools); $i++) { @@ -89,6 +90,10 @@ for ($i = 0; $i < sizeof($availableTools); $i++) { if (!$myTool->isVisible()) { continue; } + // check if hidden by config + if (isset($toolSettings['tool_hide_' . get_class($myTool)]) && ($toolSettings['tool_hide_' . get_class($myTool)] == 'true')) { + continue; + } $toSort[$availableTools[$i]] = $myTool->getPosition(); } asort($toSort);