diff --git a/SeedDMS_Core/Core/inc.ClassAttribute.php b/SeedDMS_Core/Core/inc.ClassAttribute.php index 4d4d7776a..2a7220cf9 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); 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; diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index 66ed077d0..e49e23c68 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -1883,6 +1883,7 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp() - 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 diff --git a/views/bootstrap/class.UpdateDocument.php b/views/bootstrap/class.UpdateDocument.php index c5f749b16..ffac31d71 100644 --- a/views/bootstrap/class.UpdateDocument.php +++ b/views/bootstrap/class.UpdateDocument.php @@ -295,11 +295,11 @@ 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')); } } } - $arrs = $this->callHook('addDocumentContentAttributes', $folder); + $arrs = $this->callHook('addDocumentContentAttributes', $document); if(is_array($arrs)) { foreach($arrs as $arr) { $this->formField($arr[0], $arr[1]);