From 2a5a5b205349de4203bb760d77ef581d9eba2310 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 5 Mar 2021 18:46:20 +0100 Subject: [PATCH 1/5] pass $document not $folder to hook addDocumentContentAttributes --- views/bootstrap/class.UpdateDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.UpdateDocument.php b/views/bootstrap/class.UpdateDocument.php index b855d89ee..780e5c78d 100644 --- a/views/bootstrap/class.UpdateDocument.php +++ b/views/bootstrap/class.UpdateDocument.php @@ -290,7 +290,7 @@ console.log(element); } } } - $arrs = $this->callHook('addDocumentContentAttributes', $folder); + $arrs = $this->callHook('addDocumentContentAttributes', $document); if(is_array($arrs)) { foreach($arrs as $arr) { $this->formField($arr[0], $arr[1]); From ceed62bf2bbf6111dc2b35c40d6a660268074d92 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 6 Mar 2021 15:26:18 +0100 Subject: [PATCH 2/5] do not validate value in SeedDMS_Core_Attribute::setValue(), it should have been done before --- SeedDMS_Core/Core/inc.ClassAttribute.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SeedDMS_Core/Core/inc.ClassAttribute.php b/SeedDMS_Core/Core/inc.ClassAttribute.php index b6f342295..3e77a5c16 100644 --- a/SeedDMS_Core/Core/inc.ClassAttribute.php +++ b/SeedDMS_Core/Core/inc.ClassAttribute.php @@ -177,12 +177,14 @@ class SeedDMS_Core_Attribute { /* {{{ */ if($values) { $vsep = $this->getValueSetSeparator(); if($valueset) { + /* Validation should have been done before $error = false; foreach($values as $v) { if(!in_array($v, $valueset)) { $error = true; break; } } if($error) return false; + */ $valuesetstr = $this->_attrdef->getValueSet(); $value = $vsep.implode($vsep, $values); } else { @@ -203,12 +205,14 @@ class SeedDMS_Core_Attribute { /* {{{ */ } if($valueset) { + /* Validation should have been done before $error = false; foreach($values as $v) { if(!in_array($v, $valueset)) { $error = true; break; } } if($error) return false; + */ $value = $valuesetstr[0].implode($valuesetstr[0], $values); } else { $value = ','.implode(',', $values); From 3acd9a22372367309228afe6698fac14dbcc9751 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 6 Mar 2021 15:27:03 +0100 Subject: [PATCH 3/5] add some comments --- SeedDMS_Core/Core/inc.ClassObject.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SeedDMS_Core/Core/inc.ClassObject.php b/SeedDMS_Core/Core/inc.ClassObject.php index ed5daa457..bc02592fa 100644 --- a/SeedDMS_Core/Core/inc.ClassObject.php +++ b/SeedDMS_Core/Core/inc.ClassObject.php @@ -244,6 +244,7 @@ class SeedDMS_Core_Object { /* {{{ */ $sep = substr($attrdef->getValueSet(), 0, 1); $value = $sep.implode($sep, $value); } + /* Handle the case if an attribute is not set already */ if(!isset($this->_attributes[$attrdef->getId()])) { switch(get_class($this)) { case $this->_dms->getClassname('document'): @@ -271,6 +272,7 @@ class SeedDMS_Core_Object { /* {{{ */ return true; } + /* The attribute already exists. setValue() will either update or delete it. */ $this->_attributes[$attrdef->getId()]->setValue($value); return true; From 34c81e7220478ed3599589b84eef23a2904bb84b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 6 Mar 2021 15:27:17 +0100 Subject: [PATCH 4/5] add note for 5.1.22 --- SeedDMS_Core/package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index bd45f9e19..d9c5cccf7 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -29,6 +29,7 @@ - add SeedDMS_Core_User->getDMS() and SeedDMS_Core_Group->getDMS() - add new parameter to SeedDMS_Core_DMS->getDocumentList() for skipping expired documents - add parameter $incdisabled to SeedDMS_Core_Folder::getNotifyList() +- do not validate value in SeedDMS_Core_Attribute::setValue(), it should have been done before From 6dfe43a4c45090d1823288368818487d0b307268 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 6 Mar 2021 15:35:23 +0100 Subject: [PATCH 5/5] version attributes were not used due to wrong parameter name --- views/bootstrap/class.UpdateDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.UpdateDocument.php b/views/bootstrap/class.UpdateDocument.php index 780e5c78d..4276f8bc0 100644 --- a/views/bootstrap/class.UpdateDocument.php +++ b/views/bootstrap/class.UpdateDocument.php @@ -286,7 +286,7 @@ console.log(element); } elseif(is_string($arr)) { echo $arr; } else { - $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, $document->getAttribute($attrdef))); + $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, $document->getAttribute($attrdef), 'attributes_version')); } } }