allow to disable tools
This commit is contained in:
parent
c46d809739
commit
2affd78df8
|
@ -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)
|
||||
|
|
|
@ -209,6 +209,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.
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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']) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue