Commit ba07ee10 authored by Eutyche odimba's avatar Eutyche odimba Committed by Victor Emanouilov
Browse files

[Fix] correction of errors found by michael on the insert action

parent d740efd2
Pipeline #645740713 failed with stages
in 46 minutes and 52 seconds
......@@ -47,6 +47,7 @@
$definition = Tracker_Definition::get($to_tracker);
$utilities = new Services_Tracker_Utilities();
$value = $this->stripNp($value);
$inserted = [];
if (! empty($field) and ! empty($value)) {
$inserted[$field] = $value;
......@@ -88,5 +89,10 @@
}
return $data;
}
private function stripNp($value)
{
return str_replace(['~np~', '~/np~'], '', $value);
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ class Search_Action_TrackerItemModify implements Search_Action_Action
{
$object_type = $data->object_type->text();
$object_id = $data->object_id->int();
$tracker_id = $data->tracker_id->text();
$field = $data->field->word();
$value = $data->value->text();
$calc = $data->calc->text();
......@@ -61,9 +62,6 @@ class Search_Action_TrackerItemModify implements Search_Action_Action
throw new Search_Action_Exception(tr('Tracker item %0 not found.', $object_id));
}
$definition = Tracker_Definition::get($info['trackerId']);
if (! $definition->getFieldFromPermName($field)) {
throw new Search_Action_Exception(tr('Tracker field %0 not found for tracker %1.', $field, $info['trackerId']));
}
}
if (empty($value) && empty($calc) && empty($add) && empty($remove) && empty($method)) {
......@@ -76,8 +74,17 @@ class Search_Action_TrackerItemModify implements Search_Action_Action
public function execute(JitFilter $data)
{
$object_id = $data->object_id->int();
$field = $data->field->word();
$aggregateFields = $data->aggregate_fields->none();
$trklib = TikiLib::lib('trk');
$info = $trklib->get_item_info($object_id);
$definition = Tracker_Definition::get($info['trackerId']);
if (! $definition->getFieldFromPermName($field)) {
throw new Search_Action_Exception(tr('Tracker field %0 not found for tracker %1.', $field, $info['trackerId']));
}
if ($aggregateFields) {
$unifiedsearchlib = TikiLib::lib('unifiedsearch');
$index = $unifiedsearchlib->getIndex();
......@@ -129,6 +136,7 @@ class Search_Action_TrackerItemModify implements Search_Action_Action
$trklib = TikiLib::lib('trk');
$value = $this->stripNp($value);
$info = $trklib->get_tracker_item($object_id);
$definition = Tracker_Definition::get($info['trackerId']);
......@@ -208,4 +216,9 @@ class Search_Action_TrackerItemModify implements Search_Action_Action
]
);
}
private function stripNp($value)
{
return str_replace(['~np~', '~/np~'], '', $value);
}
}
Supports Markdown
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