diff --git a/CHANGELOG b/CHANGELOG index 91da876b4..16cdda846 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -296,6 +296,7 @@ document, still send it to uploader of version - set default language in login form if language selector is turned off - do not show full list of notifiers to none admins +- do not list document/folders in sequence selector if its number exceeds 50 -------------------------------------------------------------------------------- Changes in version 5.1.33 diff --git a/controllers/class.AddDocument.php b/controllers/class.AddDocument.php index 079de59dc..e27ea3b5a 100644 --- a/controllers/class.AddDocument.php +++ b/controllers/class.AddDocument.php @@ -56,13 +56,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)) { @@ -80,13 +107,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/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index d6050a9a7..4b2d20102 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -644,7 +644,7 @@ class SeedDMS_NotificationService { $params['name'] = $document->getName(); $params['document_id'] = $document->getId(); $params['attribute_name'] = $attribute->getAttributeDefinition()->getName(); - $params['attribute_old_value'] = $oldattributes[$attrdefid]->getValue(); + $params['attribute_old_value'] = $oldattributes[$attrdefid]->getValueAsString(); $params['attribute_new_value'] = isset($newattributes[$attrdefid]) ? $newattributes[$attrdefid]->getValue() : ''; $params['folder_path'] = $folder->getFolderPathPlain(); $params['username'] = $user->getFullName(); @@ -669,7 +669,7 @@ class SeedDMS_NotificationService { $params['name'] = $document->getName(); $params['document_id'] = $document->getId(); $params['attribute_name'] = $dms->getAttributeDefinition($attrdefid)->getName(); - $params['attribute_value'] = $attribute->getValue(); + $params['attribute_value'] = $attribute->getValueAsString(); $params['folder_path'] = $folder->getFolderPathPlain(); $params['username'] = $user->getFullName(); $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); @@ -699,8 +699,8 @@ class SeedDMS_NotificationService { $params['name'] = $folder->getName(); $params['folder_id'] = $folder->getId(); $params['attribute_name'] = $attribute->getAttributeDefinition()->getName(); - $params['attribute_old_value'] = $oldattributes[$attrdefid]->getValue(); - $params['attribute_new_value'] = isset($newattributes[$attrdefid]) ? $newattributes[$attrdefid]->getValue() : ''; + $params['attribute_old_value'] = $oldattributes[$attrdefid]->getValueAsString(); + $params['attribute_new_value'] = isset($newattributes[$attrdefid]) ? $newattributes[$attrdefid]->getValueAsString() : ''; $params['folder_path'] = $folder->getFolderPathPlain(); $params['username'] = $user->getFullName(); $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID(); @@ -722,8 +722,9 @@ class SeedDMS_NotificationService { $message = "folder_attribute_added_email_body"; $params = array(); $params['name'] = $folder->getName(); + $params['folder_id'] = $folder->getId(); $params['attribute_name'] = $dms->getAttributeDefinition($attrdefid)->getName(); - $params['attribute_value'] = $attribute->getValue(); + $params['attribute_value'] = $attribute->getValueAsString(); $params['folder_path'] = $folder->getFolderPathPlain(); $params['username'] = $user->getFullName(); $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID(); diff --git a/op/op.EditAttributes.php b/op/op.EditAttributes.php index cae040121..6497c5e1c 100644 --- a/op/op.EditAttributes.php +++ b/op/op.EditAttributes.php @@ -75,27 +75,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.AddDocument.php b/views/bootstrap/class.AddDocument.php index 2761a713b..51c1dcb01 100644 --- a/views/bootstrap/class.AddDocument.php +++ b/views/bootstrap/class.AddDocument.php @@ -256,7 +256,7 @@ console.log(params); } } if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) { - $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s')).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); + $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder, 'd').($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); } else { $minmax = $folder->getDocumentsMinMax(); if($this->params['defaultposition'] == 'start') { diff --git a/views/bootstrap/class.AddSubFolder.php b/views/bootstrap/class.AddSubFolder.php index 1cf7a286c..fea0a7f98 100644 --- a/views/bootstrap/class.AddSubFolder.php +++ b/views/bootstrap/class.AddSubFolder.php @@ -98,7 +98,7 @@ $(document).ready( function() { ) ); if(!$nofolderformfields || !in_array('sequence', $nofolderformfields)) { - $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getSubFolders('s')).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); + $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder, 'f').($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); } else { $minmax = $folder->getFoldersMinMax(); if($this->params['defaultposition'] == 'start') { diff --git a/views/bootstrap/class.AttributeMgr.php b/views/bootstrap/class.AttributeMgr.php index 9e9b78582..1701efc17 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 6763c879f..d4dd177c3 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -1714,17 +1714,43 @@ $(document).ready(function() { print ""; } /* }}} */ - function printSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - echo $this->getSequenceChooser($objArr, $keepID); + function printSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */ + echo $this->getSequenceChooser($parent, $type, $keepID); } /* }}} */ - function getSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - if (count($objArr) > 0) { - $max = $objArr[count($objArr)-1]->getSequence() + 1; - $min = $objArr[0]->getSequence() - 1; + /** + * Return html code for sequence chooser + * + * This method will return the html code of the ѕelect menu for setting + * the ѕequence number of a document or folder. The select menu will contain + * a list of all siblings to select to positon relative to a sibling. + * For performance reasons the select menu will not contain any siblings + * if the number of siblings is greater than 50. + * + * @param $parent object parent folder of new or updated document/folder + * @param $type string type of new object 'f'=folder, 'd'=document + * @param $keepID integer id of current object + */ + function getSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */ + $objArr = []; + if($type == 'd') { + if(($c = $parent->hasDocuments()) < 50) + $objArr = $parent->getDocuments('s'); + $minmax = $parent->getDocumentsMinMax(); + } elseif($type = 'f') { + if(($c = $parent->hasSubFolders()) < 50) + $objArr = $parent->getSubFolders('s'); + $minmax = $parent->getFoldersMinMax(); + } else + return ''; + + if ($objArr) { + $min = $minmax['min']-1.0; + $max = $minmax['max']+1.0; } else { - $max = 1.0; + $min = (float) $minmax['min']; + $max = $minmax['max']+1.0; } $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(), M_READ, -1, $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; @@ -2089,7 +2106,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.EditDocument.php b/views/bootstrap/class.EditDocument.php index 634d9f5ba..48c1d47c0 100644 --- a/views/bootstrap/class.EditDocument.php +++ b/views/bootstrap/class.EditDocument.php @@ -201,7 +201,7 @@ $(document).ready( function() { } if(!$nodocumentformfields || !in_array('sequence', $nodocumentformfields)) { if ($folder->getAccessMode($user) > M_READ) { - $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder->getDocuments('s'), $document->getID()).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); + $this->formField(getMLText("sequence"), $this->getSequenceChooser($folder, 'd', $document->getID()).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); } } if($attrdefs) { diff --git a/views/bootstrap/class.EditFolder.php b/views/bootstrap/class.EditFolder.php index 4a44d5c2b..b7a47f479 100644 --- a/views/bootstrap/class.EditFolder.php +++ b/views/bootstrap/class.EditFolder.php @@ -108,7 +108,7 @@ $(document).ready(function() { $parent = ($folder->getID() == $rootfolderid) ? false : $folder->getParent(); if(!$nofolderformfields || !in_array('sequence', $nofolderformfields)) { if ($parent && $parent->getAccessMode($user) > M_READ) { - $this->formField(getMLText("sequence"), $this->getSequenceChooser($parent->getSubFolders('s'), $folder->getID()).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); + $this->formField(getMLText("sequence"), $this->getSequenceChooser($parent, 'f', $folder->getID()).($orderby != 's' ? "
".getMLText('order_by_sequence_off') : '')); } } if($attrdefs) { diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 18b30851b..f403c91fe 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -1517,7 +1517,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 7a2fe40b1..7624e04c5 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -1671,17 +1671,43 @@ $(document).ready(function() { print ""; } /* }}} */ - function printSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - echo $this->getSequenceChooser($objArr, $keepID); + function printSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */ + echo $this->getSequenceChooser($parent, $type, $keepID); } /* }}} */ - function getSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - if (count($objArr) > 0) { - $max = $objArr[count($objArr)-1]->getSequence() + 1; - $min = $objArr[0]->getSequence() - 1; + /** + * Return html code for sequence chooser + * + * This method will return the html code of the ѕelect menu for setting + * the ѕequence number of a document or folder. The select menu will contain + * a list of all siblings to select to positon relative to a sibling. + * For performance reasons the select menu will not contain any siblings + * if the number of siblings is greater than 50. + * + * @param $parent object parent folder of new or updated document/folder + * @param $type string type of new object 'f'=folder, 'd'=document + * @param $keepID integer id of current object + */ + function getSequenceChooser($parent, $type, $keepID = -1) { /* {{{ */ + $objArr = []; + if($type == 'd') { + if(($c = $parent->hasDocuments()) < 50) + $objArr = $parent->getDocuments('s'); + $minmax = $parent->getDocumentsMinMax(); + } elseif($type = 'f') { + if(($c = $parent->hasSubFolders()) < 50) + $objArr = $parent->getSubFolders('s'); + $minmax = $parent->getFoldersMinMax(); + } else + return ''; + + if ($objArr) { + $min = $minmax['min']-1.0; + $max = $minmax['max']+1.0; } else { - $max = 1.0; + $min = (float) $minmax['min']; + $max = $minmax['max']+1.0; } $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 = '
- +
@@ -2026,23 +2042,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(), M_READ, -1, $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; @@ -2062,7 +2073,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;