function bpminbox_check_special_fields($field_name, $source_object, $use_past_array = false, $context = null) { global $locale; // FIXME: Special cases for known non-db but allowed fields if ($field_name == 'full_name') { if ($use_past_array == false) { //use the future value return $locale->getLocaleFormattedName($source_object->first_name, $source_object->last_name); } else { //use the past value return $locale->getLocaleFormattedName($source_object->fetched_row['first_name'], $source_object->fetched_row['last_name']); } } elseif ($field_name == 'modified_by_name' && $use_past_array) { return $source_object->old_modified_by_name; } elseif ($field_name == 'assigned_user_name' && $use_past_array) { // We have to load the user here since fetched_row only has the ID, not the name return bpminbox_get_username_by_id($source_object->fetched_row['assigned_user_id']); } elseif ($field_name == 'team_name') { require_once 'modules/Teams/TeamSetManager.php'; if ($use_past_array == false) { if (empty($source_object->team_set_id)) { if (!empty($source_object->teams)) { $source_object->teams->save(); } } $team_set_id = $source_object->team_set_id; $team_id = $source_object->team_id; } else { $team_set_id = $source_object->fetched_row['team_set_id']; $team_id = $source_object->fetched_row['team_id']; } return TeamSetManager::getCommaDelimitedTeams($team_set_id, $team_id, true); } else { /* One off exception for if we are getting future date_created value. Use the fetched row for it. - jgreen */ if ($use_past_array == false && $field_name != "date_entered") { //use the future value return bpminbox_get_display_text($source_object, $field_name, $source_object->{$field_name}, null, null, $context); } else { //use the past value return bpminbox_get_display_text($source_object, $field_name, $source_object->fetched_row[$field_name], null, null, $context); } } //In future, check for maybe currency type //end function check_special_fields }
public function mergingTemplate($bean, $template, $component_array, $evaluate) { global $beanList; $replace_array = array(); $replace_type_array = array(); foreach ($component_array as $module_name => $module_array) { foreach ($module_array as $field => $field_array) { if (!isset($beanList[$field_array['filter']])) { $newBean = $this->pmseRelatedModule->getRelatedModule($bean, $field_array['filter']); } else { $newBean = $bean; } $field = $field_array['name']; if ($newBean instanceof SugarBean) { $def = $newBean->field_defs[$field]; if ($def['type'] == 'datetime' || $def['type'] == 'datetimecombo') { $value = !empty($newBean->fetched_row[$field]) ? $newBean->fetched_row[$field] : $newBean->{$field}; } else { if ($def['type'] == 'bool') { $value = $newBean->{$field} == 1 ? true : false; } else { $value = $newBean->{$field}; } } } else { $value = !empty($newBean) ? array_pop($newBean)->{$field_array}['name'] : null; } $replace_array[$field_array['original']] = bpminbox_get_display_text($newBean, $field, $value); } } foreach ($replace_array as $name => $replacement_value) { $replacement_value = nl2br($replacement_value); $template = str_replace($name, $replacement_value, $template); } return $template; }