Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10069 - Fix issue with workflow/report conditions not saving values when moving between modules #10534

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions modules/AOR_Conditions/AOR_Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ public function save_lines($post_data, $parent, $key = '')

$j = 0;
foreach ((array)$postData as $i => $field) {
$condition_module = $_REQUEST['report_module'];
if (!isset($post_data[$key . 'deleted'][$i])) {
LoggerManager::getLogger()->warn('AOR Condition trying to save lines but POST data does not contains the key "' . $key . 'deleted' . '" at index: ' . $i);
}

$flow_bean = BeanFactory::newBean($_REQUEST['report_module']);
if (isset($post_data[$key . 'deleted'][$i]) && $post_data[$key . 'deleted'][$i] == 1) {
$this->mark_deleted($post_data[$key . 'id'][$i]);
} else {
Expand All @@ -112,8 +113,23 @@ public function save_lines($post_data, $parent, $key = '')
}
} else {
if ($field_name == 'value' && $post_data[$key . 'value_type'][$i] === 'Value') {
$post_data[$key . $field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $condition->field, $post_data[$key . $field_name][$i]);
} else {
if (!empty($flow_bean)) {
$condition_relation = $post_data["aor_conditions_module_path"][$i];
$condition_relation_array = unserialize(base64_decode($condition_relation));
$rel_module = '';
foreach ($condition_relation_array as $relate){
$flow_bean->load_relationship($relate);
if ($flow_bean->$relate) {
$rel_module = $flow_bean->$relate->getRelatedModuleName();
$flow_bean = BeanFactory::newBean($rel_module);
}
}

if (!empty($rel_module) && $condition_module !== $rel_module) {
$condition_module = $rel_module;
}
}
$post_data[$key . $field_name][$i] = fixUpFormatting($condition_module, $condition->field, $post_data[$key . $field_name][$i]); } else {
if ($field_name == 'parameter') {
$post_data[$key . $field_name][$i] = isset($post_data[$key . $field_name][$i]);
} else {
Expand Down
12 changes: 11 additions & 1 deletion modules/AOR_Reports/aor_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ function requestToUserParameters($reportBean = null)
}

$condition = BeanFactory::getBean('AOR_Conditions', $_REQUEST['parameter_id'][$key]);
$flow_bean = BeanFactory::newBean($reportBean->report_module);
$modulePathArray = unserialize(base64_decode($condition->module_path));
$rel_module = $reportBean->report_module;
foreach ($modulePathArray as $relate){
$flow_bean->load_relationship($relate);
if ($flow_bean->$relate) {
$rel_module = $flow_bean->$relate->getRelatedModuleName();
$flow_bean = BeanFactory::newBean($rel_module);
}
}
$value = $_REQUEST['parameter_value'][$key];
if ($reportBean && $condition && !array_key_exists($value, $app_list_strings['date_time_period_list'])) {
$value = fixUpFormatting($reportBean->report_module, $condition->field, $value);
$value = fixUpFormatting($rel_module, $condition->field, $value);
}

$params[$parameterId] = array(
Expand Down
4 changes: 2 additions & 2 deletions modules/AOR_Reports/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function action_changeReportPage()
$offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
$group = !empty($_REQUEST['group']) ? $_REQUEST['group'] : '';
if (!empty($this->bean->id)) {
$this->bean->user_parameters = requestToUserParameters();
$this->bean->user_parameters = requestToUserParameters($this->bean);
echo $this->bean->build_group_report($offset, true, array(), $group);
}

Expand Down Expand Up @@ -144,7 +144,7 @@ protected function action_addToProspectList()

$key = Relationship::retrieve_by_modules($this->bean->report_module, 'ProspectLists', $GLOBALS['db']);
if (!empty($key)) {
$this->bean->user_parameters = requestToUserParameters();
$this->bean->user_parameters = requestToUserParameters($this->bean);
$sql = $this->bean->build_report_query();
$result = $this->bean->db->query($sql);
$beans = array();
Expand Down
20 changes: 18 additions & 2 deletions modules/AOW_Conditions/AOW_Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function save_lines($post_data, $parent, $key = '')
$line_count = count((array)$postedField);
$j = 0;
for ($i = 0; $i < $line_count; ++$i) {
$condition_module = $_REQUEST['flow_module'] ?? '';
if (!isset($post_data[$key . 'deleted'][$i])) {
LoggerManager::getLogger()->warn('AOR Condition trying to save lines but POST data does not contains the key "' . $key . 'deleted' . '" at index: ' . $i);
}
Expand All @@ -106,11 +107,14 @@ public function save_lines($post_data, $parent, $key = '')
$this->mark_deleted($post_data[$key . 'id'][$i] ?? '');
} else {
$condition = BeanFactory::newBean('AOW_Conditions');
$condition_relation = '';
$flow_bean = BeanFactory::newBean($condition_module);
foreach ($this->field_defs as $field_def) {
$field_name = $field_def['name'];
if (isset($post_data[$key . $field_name][$i])) {
if (is_array($post_data[$key . $field_name][$i])) {
if ($field_name == 'module_path') {
$condition_relation = $post_data[$key . $field_name][$i];
$post_data[$key . $field_name][$i] = base64_encode(serialize($post_data[$key . $field_name][$i]));
} else {
switch ($condition->value_type) {
Expand All @@ -123,8 +127,20 @@ public function save_lines($post_data, $parent, $key = '')
}
} else {
if ($field_name === 'value' && $post_data[$key . 'value_type'][$i] === 'Value') {
$post_data[$key . $field_name][$i] = fixUpFormatting($_REQUEST['flow_module'], $condition->field, $post_data[$key . $field_name][$i]);
}
if (!empty($flow_bean)) {
foreach ($condition_relation as $relate){
$flow_bean->load_relationship($relate);
$rel_module = '';
if ($flow_bean->$relate) {
$rel_module = $flow_bean->$relate->getRelatedModuleName();
$flow_bean = BeanFactory::newBean($rel_module);
}
}
if (!empty($rel_module) && $condition_module !== $rel_module) {
$condition_module = $rel_module;
}
}
$post_data[$key . $field_name][$i] = fixUpFormatting($condition_module, $condition->field, $post_data[$key . $field_name][$i]); }
}
$condition->$field_name = $post_data[$key . $field_name][$i];
}
Expand Down