diff --git a/lam/HISTORY b/lam/HISTORY index 82d941e80..cc5dff57b 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -2,6 +2,7 @@ June 2025 9.2 - TAK support added - Active Directory: allow to restore deleted entries in tree view (415) - Multi-edit tool: change operations are combined by DN to allow e.g. adding object classes with required attributes (408) + - Tree view: better editing of olcAccess (420) - Fixed bugs: -> Unix: profile editor for users not working (418) -> Custom fields: problems with deleting facsimileTelephoneNumber (419) diff --git a/lam/lib/treeview.inc b/lam/lib/treeview.inc index e63b48a37..062bfac49 100644 --- a/lam/lib/treeview.inc +++ b/lam/lib/treeview.inc @@ -754,7 +754,8 @@ class TreeView { if (($schemaAttribute !== null) && $schemaAttribute->isBinary()) { $value = base64_encode($value); } - if ($isMultiLine) { + $value = $this->preProcessValue(strtolower($attributeName), $value); + if ($isMultiLine || $this->isPseudoMultiLine(strtolower($attributeName))) { $inputField = new htmlInputTextarea('lam_attr_' . $attributeName, $value, 50, 5); } else { @@ -1056,6 +1057,12 @@ class TreeView { } } } + // olcAccess needs removal of newlines + if (isset($ldapChanges['olcaccess'])) { + for ($i = 0; $i < count($ldapChanges['olcaccess']); $i++) { + $ldapChanges['olcaccess'][$i] = str_replace("\n", ' ', $ldapChanges['olcaccess'][$i]); + } + } // add ";binary" to binary attributes foreach ($ldapChanges as $attributeName => $value) { if (!isset($schemaAttributes[$attributeName])) { @@ -1709,6 +1716,30 @@ class TreeView { return json_encode([]); } + /** + * Returns if the attribute should be rendered multi-line even if it is single-line defined in schema. + * + * @param string $attributeName attribute name + * @return bool render multi-line + */ + private function isPseudoMultiLine(string $attributeName): bool { + return ($attributeName === 'olcaccess'); + } + + /** + * Preprocesses the value before rendering. + * + * @param string $attributeName attribute name + * @param string $value value + * @return string preprocessed value + */ + private function preProcessValue(string $attributeName, string $value): string { + if ($attributeName === 'olcaccess') { + return preg_replace('/\s+by\s+/', "\r\nby ", $value); + } + return $value; + } + } /** diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 5a58d3ca6..b780f9ad4 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -3182,7 +3182,10 @@ window.lam.treeview.updateAttributePositionData = function(containerId) { const container = document.getElementById(containerId); const childLiElements = container.children; for (let i = 0; i < childLiElements.length; i++) { - const inputField = childLiElements[i].querySelector('input'); + let inputField = childLiElements[i].querySelector('input'); + if (inputField === null) { + inputField = childLiElements[i].querySelector('textarea'); + } inputField.value = '{' + i + '}' + inputField.value.replace(/^\{[0-9]+\}/, ''); } }