From 2fe99c29054e082a38be75eee5761a8963fc27f9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 25 Mar 2024 14:18:36 +0100 Subject: [PATCH] attributes of type user, group, document, folder are now an object --- controllers/class.AddDocument.php | 62 +++++++++++++++++++-- controllers/class.AddSubFolder.php | 31 ++++++++++- controllers/class.EditDocument.php | 29 +++++++++- controllers/class.EditFolder.php | 76 ++++++++++++++++++-------- op/op.EditAttributes.php | 66 +++++++++++++++------- views/bootstrap/class.AttributeMgr.php | 16 +++++- views/bootstrap/class.Bootstrap.php | 38 ++++++------- views/bootstrap/class.Search.php | 2 +- views/bootstrap4/class.Bootstrap4.php | 48 ++++++---------- 9 files changed, 263 insertions(+), 105 deletions(-) diff --git a/controllers/class.AddDocument.php b/controllers/class.AddDocument.php index bf6e9fb69..7f2a73cbe 100644 --- a/controllers/class.AddDocument.php +++ b/controllers/class.AddDocument.php @@ -55,13 +55,40 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common { $reqversion = $this->getParam('reqversion'); $version_comment = $this->getParam('versioncomment'); $attributes = $this->getParam('attributes'); - foreach($attributes as $attrdefid=>$attribute) { + foreach($attributes as $attrdefid=>&$attribute) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if($attribute) { switch($attrdef->getType()) { case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); break; } if(!$attrdef->validate($attribute, null, true)) { @@ -79,13 +106,40 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common { } } if($attributes_version = $this->getParam('attributesversion')) { - foreach($attributes_version as $attrdefid=>$attribute) { + foreach($attributes_version as $attrdefid=>&$attribute) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if($attribute) { switch($attrdef->getType()) { case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); break; } if(!$attrdef->validate($attribute, null, true)) { diff --git a/controllers/class.AddSubFolder.php b/controllers/class.AddSubFolder.php index 24a609cb8..10e99d00c 100644 --- a/controllers/class.AddSubFolder.php +++ b/controllers/class.AddSubFolder.php @@ -41,13 +41,40 @@ class SeedDMS_Controller_AddSubFolder extends SeedDMS_Controller_Common { $comment = $this->getParam('comment'); $sequence = $this->getParam('sequence'); $attributes = $this->getParam('attributes'); - foreach($attributes as $attrdefid=>$attribute) { + foreach($attributes as $attrdefid=>&$attribute) { if($attrdef = $dms->getAttributeDefinition($attrdefid)) { if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { if($attribute) { switch($attrdef->getType()) { case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); break; } if(!$attrdef->validate($attribute, null, true)) { diff --git a/controllers/class.EditDocument.php b/controllers/class.EditDocument.php index bfe0dac30..cd86dfedf 100644 --- a/controllers/class.EditDocument.php +++ b/controllers/class.EditDocument.php @@ -122,7 +122,34 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common { if($attribute) { switch($attrdef->getType()) { case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); break; } if(!$attrdef->validate($attribute, $document, false)) { diff --git a/controllers/class.EditFolder.php b/controllers/class.EditFolder.php index 94a1fa066..2df566189 100644 --- a/controllers/class.EditFolder.php +++ b/controllers/class.EditFolder.php @@ -51,33 +51,61 @@ class SeedDMS_Controller_EditFolder extends SeedDMS_Controller_Common { $oldattributes = $folder->getAttributes(); if($attributes) { foreach($attributes as $attrdefid=>$attribute) { - $attrdef = $dms->getAttributeDefinition($attrdefid); - if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { - if($attribute) { - switch($attrdef->getType()) { - case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); - break; - } - if(!$attrdef->validate($attribute, $folder, false)) { - $this->errormsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); - return false; - } + if($attrdef = $dms->getAttributeDefinition($attrdefid)) { + if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) { + if($attribute) { + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_date: + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); + break; + } + if(!$attrdef->validate($attribute, $folder, false)) { + $this->errormsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); + return false; + } - if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) { - if(!$folder->setAttributeValue($dms->getAttributeDefinition($attrdefid), $attribute)) + if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) { + if(!$folder->setAttributeValue($dms->getAttributeDefinition($attrdefid), $attribute)) + return false; + } + } elseif($attrdef->getMinValues() > 0) { + $this->errormsg = getMLText("attr_min_values", array("attrname"=>$attrdef->getName())); + return false; + } elseif(isset($oldattributes[$attrdefid])) { + if(!$folder->removeAttribute($dms->getAttributeDefinition($attrdefid))) + return false; + } + } else { + if($ret === false) return false; } - } elseif($attrdef->getMinValues() > 0) { - $this->errormsg = getMLText("attr_min_values", array("attrname"=>$attrdef->getName())); - return false; - } elseif(isset($oldattributes[$attrdefid])) { - if(!$folder->removeAttribute($dms->getAttributeDefinition($attrdefid))) - return false; - } - } else { - if($ret === false) - return false; } } } diff --git a/op/op.EditAttributes.php b/op/op.EditAttributes.php index 8e4d3c01e..7476c68d8 100644 --- a/op/op.EditAttributes.php +++ b/op/op.EditAttributes.php @@ -70,27 +70,55 @@ foreach($version->getAttributes() as $ai=>$aa) $attributes = $_POST["attributes"]; if($attributes) { foreach($attributes as $attrdefid=>$attribute) { - $attrdef = $dms->getAttributeDefinition($attrdefid); - if($attribute) { - switch($attrdef->getType()) { - case SeedDMS_Core_AttributeDefinition::type_date: - $attribute = date('Y-m-d', makeTsFromDate($attribute)); - break; - } - if(!$attrdef->validate($attribute, $version, false)) { - $errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg); - } - if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) { - if(!$version->setAttributeValue($dms->getAttributeDefinition($attrdefid), $attribute)) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); + if($attrdef = $dms->getAttributeDefinition($attrdefid)) { + if($attribute) { + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_date: + if(is_array($attribute)) + $attribute = array_map(fn($value): string => date('Y-m-d', makeTsFromDate($value)), $attribute); + else + $attribute = date('Y-m-d', makeTsFromDate($attribute)); + break; + case SeedDMS_Core_AttributeDefinition::type_folder: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getFolder((int) $value), $attribute); + else + $attribute = $dms->getFolder((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_document: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getDocument((int) $value), $attribute); + else + $attribute = $dms->getDocument((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_user: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getUser((int) $value), $attribute); + else + $attribute = $dms->getUser((int) $attribute); + break; + case SeedDMS_Core_AttributeDefinition::type_group: + if(is_array($attribute)) + $attribute = array_map(fn($value): object => $dms->getGroup((int) $value), $attribute); + else + $attribute = $dms->getGroup((int) $attribute); + break; } + if(!$attrdef->validate($attribute, $version, false)) { + $errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute); + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg); + } + if(!isset($oldattributes[$attrdefid]) || $attribute != $oldattributes[$attrdefid]->getValue()) { + if(!$version->setAttributeValue($dms->getAttributeDefinition($attrdefid), $attribute)) { + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); + } + } + } elseif($attrdef->getMinValues() > 0) { + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName()))); + } elseif(isset($oldattributes[$attrdefid])) { + if(!$version->removeAttribute($dms->getAttributeDefinition($attrdefid))) + UI::exitError(getMLText("document_title", array("documentname" => $folder->getName())),getMLText("error_occured")); } - } elseif($attrdef->getMinValues() > 0) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("attr_min_values", array("attrname"=>$attrdef->getName()))); - } elseif(isset($oldattributes[$attrdefid])) { - if(!$version->removeAttribute($dms->getAttributeDefinition($attrdefid))) - UI::exitError(getMLText("document_title", array("documentname" => $folder->getName())),getMLText("error_occured")); } } } diff --git a/views/bootstrap/class.AttributeMgr.php b/views/bootstrap/class.AttributeMgr.php index 1fe5fddb7..5e16006ab 100644 --- a/views/bootstrap/class.AttributeMgr.php +++ b/views/bootstrap/class.AttributeMgr.php @@ -93,14 +93,26 @@ $(document).ready( function() { $content .= "\n\n"; $separator = $selattrdef->getValueSetSeparator(); foreach($res['frequencies'][$type] as $entry) { - $value = $selattrdef->parseValue($entry['value']); + if(is_array($entry['value'])) { + $values = $entry['value']; + } else { + $values = [$entry['value']]; + } + $value = []; + foreach($values as $v) { + if(is_object($v)) + $value[] = $v->getId(); + else + $value[] = $v; + } +// $value = $selattrdef->parseValue($entry['value']); $content .= ""; $content .= "".htmlspecialchars(implode(''.($separator ? ' '.$separator.' ' : ' ; ').'', $value)).""; $content .= "getType() == SeedDMS_Core_AttributeDefinition::type_date) $content .= "attributes[".$selattrdef->getID()."][from]=".urlencode($entry['value'])."&attributes[".$selattrdef->getID()."][to]=".urlencode($entry['value']); else - $content .= "attributes[".$selattrdef->getID()."]=".urlencode($entry['value']); + $content .= "attributes[".$selattrdef->getID()."]=".urlencode($value[0]); $content .= "\">".urlencode($entry['c']).""; $content .= ""; /* various checks, if the value is valid */ diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 18ff23438..b228624e6 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -1879,26 +1879,23 @@ $(document).ready(function() { case SeedDMS_Core_AttributeDefinition::type_folder: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - if($targetfolder = $dms->getFolder(intval($attr))) - $tmp[] = ''.htmlspecialchars($targetfolder->getName()).''; + foreach($attrs as $targetfolder) { + $tmp[] = ''.htmlspecialchars($targetfolder->getName()).''; } return implode('
', $tmp); break; case SeedDMS_Core_AttributeDefinition::type_document: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - if($targetdoc = $dms->getDocument(intval($attr))) - $tmp[] = ''.htmlspecialchars($targetdoc->getName()).''; + foreach($attrs as $targetdoc) { + $tmp[] = ''.htmlspecialchars($targetdoc->getName()).''; } return implode('
', $tmp); break; case SeedDMS_Core_AttributeDefinition::type_user: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - $curuser = $dms->getUser((int) $attr); + foreach($attrs as $curuser) { $tmp[] = htmlspecialchars($curuser->getFullname()." (".$curuser->getLogin().")"); } return implode('
', $tmp); @@ -1906,8 +1903,7 @@ $(document).ready(function() { case SeedDMS_Core_AttributeDefinition::type_group: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - $curgroup = $dms->getGroup((int) $attr); + foreach($attrs as $curgroup) { $tmp[] = htmlspecialchars($curgroup->getName()); } return implode('
', $tmp); @@ -1957,23 +1953,18 @@ $(document).ready(function() { $content .= "getMinValues() > 0) ? ' required="required"' : '')." data-rule-number=\"true\"/>"; break; */ case SeedDMS_Core_AttributeDefinition::type_folder: - $objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; - if($objvalue) - $target = $dms->getFolder($objvalue); - else - $target = null; + $target = $attribute ? $attribute->getValue() : null; $content .= $this->getFolderChooserHtml("attr".$attrdef->getId(), M_READWRITE, -1, $target, $attr_name, false); break; case SeedDMS_Core_AttributeDefinition::type_document: - $objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; - if($objvalue) - $target = $dms->getDocument($objvalue); - else - $target = null; + $target = $attribute ? $attribute->getValue() : null; $content .= $this->getDocumentChooserHtml("attr".$attrdef->getId(), $target, $attr_name); break; case SeedDMS_Core_AttributeDefinition::type_user: - $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : (is_string($attribute) ? [$attribute] : $attribute)) : array(); + $target = $attribute ? $attribute->getValueAsArray() : []; + $objvalue = []; + foreach($target as $t) + $objvalue[] = $t->getId(); $users = $dms->getAllUsers(); if($users) { $allowempty = $attrdef->getMinValues() == 0; @@ -1993,7 +1984,10 @@ $(document).ready(function() { } break; case SeedDMS_Core_AttributeDefinition::type_group: - $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : (is_string($attribute) ? [$attribute] : $attribute)) : array(); + $target = $attribute ? $attribute->getValueAsArray() : []; + $objvalue = []; + foreach($target as $t) + $objvalue[] = $t->getId(); $groups = $dms->getAllGroups(); if($groups) { $allowempty = $attrdef->getMinValues() == 0; diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 7bca0863d..c22b4bbc2 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -1498,7 +1498,7 @@ $(document).ready(function() { $attrstr .= $arr; } else { $attrdef = $docattribute->getAttributeDefinition(); - $attrstr .= "".htmlspecialchars($attrdef->getName())."".htmlspecialchars(implode(', ', $docattribute->getValueAsArray()))."\n"; + $attrstr .= "".htmlspecialchars($attrdef->getName())."".htmlspecialchars($docattribute->getValueAsString())."\n"; } } $attrstr .= "\n"; diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index 65351411b..81f140366 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -1917,26 +1917,23 @@ $(document).ready(function() { case SeedDMS_Core_AttributeDefinition::type_folder: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - if($targetfolder = $dms->getFolder(intval($attr))) - $tmp[] = ''.htmlspecialchars($targetfolder->getName()).''; + foreach($attrs as $targetfolder) { + $tmp[] = ''.htmlspecialchars($targetfolder->getName()).''; } return implode('
', $tmp); break; case SeedDMS_Core_AttributeDefinition::type_document: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - if($targetdoc = $dms->getDocument(intval($attr))) - $tmp[] = ''.htmlspecialchars($targetdoc->getName()).''; + foreach($attrs as $targetdoc) { + $tmp[] = ''.htmlspecialchars($targetdoc->getName()).''; } return implode('
', $tmp); break; case SeedDMS_Core_AttributeDefinition::type_user: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - $curuser = $dms->getUser((int) $attr); + foreach($attrs as $curuser) { $tmp[] = htmlspecialchars($curuser->getFullname()." (".$curuser->getLogin().")"); } return implode('
', $tmp); @@ -1944,8 +1941,7 @@ $(document).ready(function() { case SeedDMS_Core_AttributeDefinition::type_group: $attrs = $attribute->getValueAsArray(); $tmp = array(); - foreach($attrs as $attr) { - $curgroup = $dms->getGroup((int) $attr); + foreach($attrs as $curgroup) { $tmp[] = htmlspecialchars($curgroup->getName()); } return implode('
', $tmp); @@ -1979,17 +1975,11 @@ $(document).ready(function() { $content .= ""; break; case SeedDMS_Core_AttributeDefinition::type_date: - $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : ''; + $objvalue = $attribute ? getReadableDate((is_object($attribute) ? $attribute->getValue() : $attribute)) : ''; $dateformat = getConvertDateFormat($this->params['settings']->_dateformat); - /* - $content .= ' - - - '; - */ $content = '
- +
@@ -2005,23 +1995,18 @@ $(document).ready(function() { $content .= "getMinValues() > 0) ? ' required="required"' : '')." data-rule-number=\"true\"/>"; break; */ case SeedDMS_Core_AttributeDefinition::type_folder: - $objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; - if($objvalue) - $target = $dms->getFolder($objvalue); - else - $target = null; + $target = $attribute ? $attribute->getValue() : null; $content .= $this->getFolderChooserHtml("attr".$attrdef->getId(), M_READWRITE, -1, $target, $attr_name, false); break; case SeedDMS_Core_AttributeDefinition::type_document: - $objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; - if($objvalue) - $target = $dms->getDocument($objvalue); - else - $target = null; + $target = $attribute ? $attribute->getValue() : null; $content .= $this->getDocumentChooserHtml("attr".$attrdef->getId(), $target, $attr_name); break; case SeedDMS_Core_AttributeDefinition::type_user: - $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : (is_string($attribute) ? [$attribute] : $attribute)) : array(); + $target = $attribute ? $attribute->getValueAsArray() : []; + $objvalue = []; + foreach($target as $t) + $objvalue[] = $t->getId(); $users = $dms->getAllUsers(); if($users) { $allowempty = $attrdef->getMinValues() == 0; @@ -2041,7 +2026,10 @@ $(document).ready(function() { } break; case SeedDMS_Core_AttributeDefinition::type_group: - $objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : (is_string($attribute) ? [$attribute] : $attribute)) : array(); + $target = $attribute ? $attribute->getValueAsArray() : []; + $objvalue = []; + foreach($target as $t) + $objvalue[] = $t->getId(); $groups = $dms->getAllGroups(); if($groups) { $allowempty = $attrdef->getMinValues() == 0;