Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-09-01 15:15:07 +02:00
commit a5994e3011
3 changed files with 22 additions and 11 deletions

View File

@ -190,6 +190,7 @@
- update to font-awesome 4.7.1 - update to font-awesome 4.7.1
- add new attribute types 'document', 'folder', 'user', 'group' - add new attribute types 'document', 'folder', 'user', 'group'
- overhaul of folder tree which can now be used more than once on a page - overhaul of folder tree which can now be used more than once on a page
- fix search of values in attributes of document content
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.18 Changes in version 5.1.18

View File

@ -168,6 +168,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
if(is_array($values)) { if(is_array($values)) {
if($values) { if($values) {
$vsep = $this->getValueSetSeparator();
if($valueset) { if($valueset) {
$error = false; $error = false;
foreach($values as $v) { foreach($values as $v) {
@ -176,9 +177,9 @@ class SeedDMS_Core_Attribute { /* {{{ */
if($error) if($error)
return false; return false;
$valuesetstr = $this->_attrdef->getValueSet(); $valuesetstr = $this->_attrdef->getValueSet();
$value = $valuesetstr[0].implode($valuesetstr[0], $values); $value = $vsep.implode($vsep, $values);
} else { } else {
$value = ','.implode(',', $values); $value = $vsep.implode($vsep, $values);
} }
} else { } else {
$value = ''; $value = '';
@ -649,10 +650,16 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
* @return string separator or an empty string if a value set is not set * @return string separator or an empty string if a value set is not set
*/ */
function getValueSetSeparator() { /* {{{ */ function getValueSetSeparator() { /* {{{ */
if(strlen($this->_valueset) > 1) if(strlen($this->_valueset) > 1) {
return $this->_valueset[0]; return $this->_valueset[0];
else } elseif($this->_multiple) {
if($this->_type == SeedDMS_Core_AttributeDefinition::type_user || $this->_type == SeedDMS_Core_AttributeDefinition::type_group)
return ',';
else
return '';
} else {
return ''; return '';
}
} /* }}} */ } /* }}} */
/** /**

View File

@ -2182,30 +2182,33 @@ class SeedDMS_Core_DMS {
if ($attributes) { if ($attributes) {
foreach($attributes as $attrdefid=>$attribute) { foreach($attributes as $attrdefid=>$attribute) {
if($attribute) { if($attribute) {
$lsearchAttributes = [];
$attrdef = $this->getAttributeDefinition($attrdefid); $attrdef = $this->getAttributeDefinition($attrdefid);
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) {
if($valueset = $attrdef->getValueSet()) { if($valueset = $attrdef->getValueSet()) {
if($attrdef->getMultipleValues()) { if($attrdef->getMultipleValues()) {
if(is_string($attribute)) if(is_string($attribute))
$attribute = array($attribute); $attribute = array($attribute);
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)";
} else } else
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentAttributes`.`value`='".$attribute."' AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentAttributes`.`value`='".$attribute."' AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)";
} else } else
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentAttributes`.`value` like '%".$attribute."%' AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentAttributes`.`value` like '%".$attribute."%' AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)";
} elseif($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { }
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) {
if($attrdef->getValueSet()) { if($attrdef->getValueSet()) {
if($attrdef->getMultipleValues()) { if($attrdef->getMultipleValues()) {
/** @noinspection PhpUndefinedVariableInspection */ /** @noinspection PhpUndefinedVariableInspection */
if(is_string($attribute)) if(is_string($attribute))
$attribute = array($attribute); $attribute = array($attribute);
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentContentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentContentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentContentAttributes`.`document` = `tblDocumentContent`.`id`)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentContentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentContentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentContentAttributes`.`content` = `tblDocumentContent`.`id`)";
} else { } else {
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value`='".$attribute."' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value`='".$attribute."' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)";
} }
} else } else
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value` like '%".$attribute."%' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)"; $lsearchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value` like '%".$attribute."%' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)";
} }
$searchAttributes[] = "(".implode(" OR ", $lsearchAttributes).")";
} }
} }
} }