diff --git a/lam/HISTORY b/lam/HISTORY
index 035a7e09a..8b715d611 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -4,6 +4,8 @@ June 2025 9.2
- Multi-edit tool: change operations are combined by DN to allow e.g. adding object classes with required attributes (408)
- Windows users: support thumbnail images (needs to be activated in server profile) (431)
- Tree view: better editing of olcAccess (420)
+ - LAM Pro:
+ -> Custom scripts: split config by account type (409)
- Fixed bugs:
-> Unix: profile editor for users not working (418)
-> Custom fields: problems with deleting facsimileTelephoneNumber (419)
diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml
index 7bbb52c74..9acaaaff7 100644
--- a/lam/docs/manual-sources/chapter-installation.xml
+++ b/lam/docs/manual-sources/chapter-installation.xml
@@ -608,6 +608,38 @@
version. Unless explicitly noticed there is no need to install an
intermediate release.
+
+ 9.1 -> 9.2
+
+ LAM Pro:
+
+
+
+ Custom scripts: The settings in server profile were split by
+ account type. If you use custom scripts then you need to perform
+ these steps for each server profile that uses them (no scripts
+ will be executed till migration was done):
+
+
+
+ Open server profile and switch to tab "Module
+ settings"
+
+
+
+ Review the automated migration of the custom scripts
+ settings (complex configurations will need manual
+ adaptions)
+
+
+
+ Save the server profile
+
+
+
+
+
+
9.0 -> 9.1
diff --git a/lam/lib/config.inc b/lam/lib/config.inc
index 52ce8d7dd..4d933bc02 100644
--- a/lam/lib/config.inc
+++ b/lam/lib/config.inc
@@ -120,9 +120,9 @@ function setlanguage() {
* @param string $target owner, group or other
* @param string $chmod the chmod rights
*
- * @return true, if the chmod $right for $target were set
+ * @return bool true, if the chmod $right for $target were set
*/
-function checkChmod($right, $target, $chmod) {
+function checkChmod($right, $target, $chmod): bool {
$right_arr = ["read", "write", "execute"];
$target_arr = ["owner", "group", "other"];
@@ -133,13 +133,13 @@ function checkChmod($right, $target, $chmod) {
$chmod_num = -1;
// owner:
- if ($target == "owner") {
+ if ($target === "owner") {
$chmod_num = 0;
}
- if ($target == "group") {
+ if ($target === "group") {
$chmod_num = 1;
}
- if ($target == "other") {
+ if ($target === "other") {
$chmod_num = 2;
}
@@ -153,9 +153,9 @@ function checkChmod($right, $target, $chmod) {
$write = [2, 3, 6, 7];
// What numbers allow "execute"
$execute = [1, 3, 5, 7];
- return (($right == "read") && in_array($chmod_num, $read))
- || (($right == "write") && in_array($chmod_num, $write))
- || (($right == "execute") && in_array($chmod_num, $execute));
+ return (($right === "read") && in_array($chmod_num, $read))
+ || (($right === "write") && in_array($chmod_num, $write))
+ || (($right === "execute") && in_array($chmod_num, $execute));
}
/**
diff --git a/lam/tests/lib/modules/CustomScriptsTest.php b/lam/tests/lib/modules/CustomScriptsTest.php
index cdb0e4d9d..d0b95566d 100644
--- a/lam/tests/lib/modules/CustomScriptsTest.php
+++ b/lam/tests/lib/modules/CustomScriptsTest.php
@@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2024 Roland Gruber
+ Copyright (C) 2024 - 2025 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
@@ -51,16 +51,13 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
'LAM_TEXT_COMMENT: Comment=no comment',
'LAM_TEXT_AMOUNT:Amount',
'LAM_GROUP: Group 1',
- 'user manual LAMLABEL="echo uid" echo $uid$',
+ 'manual LAMLABEL="echo uid" echo $uid$',
'LAM_GROUP: Group 2',
- 'user manual echo $description$',
- 'user postModify echo $dn$',
- 'gon preModify echo NEW $member$ OLD $ORIG.member$',
+ 'manual echo $description$',
+ 'postModify echo $dn$',
'',
' ',
- 'group:group_3 manual echo group3',
- 'group:group_3 postCreate echo group3',
- 'group preCreate echo group',
+ 'preCreate echo user',
];
$this->configLinesSelfService = [
'postModify echo $dn$',
@@ -70,17 +67,12 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
public function testCustomScriptParser() {
$parser = new \CustomScriptParser();
- $scripts = $parser->parse($this->configLines, false);
+ $scripts = $parser->parse($this->configLines);
$this->assertNotEmpty($scripts);
- $this->assertEquals(7, count($scripts));
- $typeManager = new TypeManager();
+ $this->assertEquals(4, count($scripts));
$script = $scripts[0];
- $configuredType = new ConfiguredType($typeManager, 'user', 'user');
- $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
$this->assertTrue($script->isManual());
$this->assertEquals('echo $uid$', $script->getCommand());
$this->assertEquals('manual', $script->getType());
@@ -88,10 +80,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
$this->assertEquals('Group 1', $script->getGroupLabel());
$script = $scripts[1];
- $configuredType = new ConfiguredType($typeManager, 'user', 'user');
- $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
$this->assertTrue($script->isManual());
$this->assertEquals('echo $description$', $script->getCommand());
$this->assertEquals('manual', $script->getType());
@@ -99,10 +87,6 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
$this->assertEquals('Group 2', $script->getGroupLabel());
$script = $scripts[2];
- $configuredType = new ConfiguredType($typeManager, 'user', 'user');
- $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
$this->assertFalse($script->isManual());
$this->assertEquals('echo $dn$', $script->getCommand());
$this->assertEquals('postModify', $script->getType());
@@ -110,44 +94,8 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
$this->assertEquals(_('Post-modify'), $script->getTypeLabel());
$script = $scripts[3];
- $configuredType = new ConfiguredType($typeManager, 'gon', 'gon_1');
- $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
$this->assertFalse($script->isManual());
- $this->assertEquals('echo NEW $member$ OLD $ORIG.member$', $script->getCommand());
- $this->assertEquals('preModify', $script->getType());
- $this->assertNull($script->getLabel());
- $this->assertEquals(_('Pre-modify'), $script->getTypeLabel());
-
- $script = $scripts[4];
- $configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
- $configuredWrongType = new ConfiguredType($typeManager, 'group', 'group_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
- $this->assertTrue($script->isManual());
- $this->assertEquals('echo group3', $script->getCommand());
- $this->assertEquals('manual', $script->getType());
- $this->assertNull($script->getLabel());
-
- $script = $scripts[5];
- $configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
- $configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
- $this->assertFalse($script->isManual());
- $this->assertEquals('echo group3', $script->getCommand());
- $this->assertEquals('postCreate', $script->getType());
- $this->assertNull($script->getLabel());
- $this->assertEquals(_('Post-create'), $script->getTypeLabel());
-
- $script = $scripts[6];
- $configuredType = new ConfiguredType($typeManager, 'group', 'group_3');
- $configuredWrongType = new ConfiguredType($typeManager, 'gon', 'gon_1');
- $this->assertTrue($script->matchesConfiguredType($configuredType));
- $this->assertFalse($script->matchesConfiguredType($configuredWrongType));
- $this->assertFalse($script->isManual());
- $this->assertEquals('echo group', $script->getCommand());
+ $this->assertEquals('echo user', $script->getCommand());
$this->assertEquals('preCreate', $script->getType());
$this->assertNull($script->getLabel());
$this->assertEquals(_('Pre-create'), $script->getTypeLabel());
@@ -174,7 +122,7 @@ if (is_readable(__DIR__ . '/../../../lib/modules/customScripts.inc')) {
public function testCustomScriptParserSelfService() {
$parser = new \CustomScriptParser();
- $scripts = $parser->parse($this->configLinesSelfService, true);
+ $scripts = $parser->parse($this->configLinesSelfService);
$this->assertNotEmpty($scripts);
$this->assertEquals(2, count($scripts));