Commit bec107dd authored by Victor Emanouilov's avatar Victor Emanouilov

[FIX] cloning tracker items via ListExecute keeps auto-assigned UserSelector...

[FIX] cloning tracker items via ListExecute keeps auto-assigned UserSelector values instead of resetting that to none or current user
parent 43e10f9d
Pipeline #126594793 passed with stages
in 11 minutes and 9 seconds
......@@ -53,7 +53,7 @@ class Search_Action_TrackerItemClone implements Search_Action_Action
}
$utilities = new Services_Tracker_Utilities;
$itemObject = $utilities->cloneItem($itemObject->getDefinition(), $itemData, $object_id);
$itemObject = $utilities->cloneItem($itemObject->getDefinition(), $itemData, $object_id, $strict = true);
if ($itemObject) {
$this->cloned_object_id = $itemObject->getId();
return true;
......
......@@ -597,18 +597,19 @@ EXPORT;
* @param Tracker_Definition $definition
* @param array $itemData
* @param int $itemId
* @param boolean $strict
*
* @return Tracker_Item
* @throws Exception
*/
function cloneItem($definition, $itemData, $itemId)
function cloneItem($definition, $itemData, $itemId, $strict = false)
{
$transaction = TikiLib::lib('tiki')->begin();
foreach ($definition->getFields() as $field) {
$handler = $definition->getFieldFactory()->getHandler($field, $itemData);
if (method_exists($handler, 'handleClone')) {
$newData = $handler->handleClone();
$newData = $handler->handleClone($strict);
$itemData['fields'][$field['permName']] = $newData['value'];
}
}
......@@ -632,7 +633,7 @@ EXPORT;
foreach ($childDefinition->getFields() as $field) {
$handler = $childDefinition->getFieldFactory()->getHandler($field, $data);
if (method_exists($handler, 'handleClone')) {
$newData = $handler->handleClone();
$newData = $handler->handleClone($strict);
$data['fields'][$field['permName']] = $newData['value'];
}
}
......
......@@ -557,7 +557,7 @@ class Tracker_Field_Files extends Tracker_Field_Abstract implements Tracker_Fiel
/**
* called from action_clone_item and duplicates the related files if option duplicateGalleryID is set
*/
function handleClone()
function handleClone($strict = false)
{
global $prefs;
......
......@@ -477,14 +477,19 @@ class Tracker_Field_UserSelector extends Tracker_Field_Abstract implements Track
/**
* called from action_clone_item - sets to current user if autoassign == 1 or 2 (Creator or Modifier)
* @param boolean $strict - strict copy will not modify values based on settings and logged user
*/
function handleClone()
function handleClone($strict = false)
{
global $user;
$value = $this->getValue('');
$autoassign = (int) $this->getOption('autoassign');
if ($strict) {
return ['value' => $value];
}
$autoassign = (int) $this->getOption('autoassign');
if ($autoassign === 1 || $autoassign === 2) {
if ($this->getOption('multiple') && $value) {
$value = TikiLib::lib('trk')->parse_user_field($value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment