/** * returns text that describes the action * @param WorkFlowActionShell $action_shell - the WorkFlowActionShell to use to process * @return an array containing the relevant data for use in UI * @access public */ function get_action_shell_display_text($action_shell, $get_all_fields = true) { $action_processed = false; $workflow_object = $action_shell->get_workflow_object(); if ($action_shell->action_type == "update") { $temp_module = BeanFactory::getBean($workflow_object->base_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "update_rel") { $rel_module = $workflow_object->get_rel_module($action_shell->rel_module); $temp_module = BeanFactory::getBean($rel_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "new") { $rel_module = $workflow_object->get_rel_module($action_shell->action_module); $temp_module = BeanFactory::getBean($rel_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "new_rel") { $rel_handler = $workflow_object->call_relationship_handler("base_module", true); $rel_handler->set_rel_vardef_fields($action_shell->rel_module, $action_shell->action_module); $rel_handler->build_info(true); $temp_module = $rel_handler->rel2_bean; $meta_filter = "action_filter"; $action_processed = true; } //BEGIN WFLOW PLUGINS if ($action_processed == false) { $opt['object'] = $this; $opt['workflow_object'] = $workflow_object; $opt['action_shell'] = $action_shell; $list_data_array = get_plugin("workflow", "action_createstep2", $opt); if (!empty($list_data_array['action_processed']) && $list_data_array['action_processed'] == true) { return $list_data_array['results']; } } //END WFLOW PLUGINS //Using VarDef Handler Object to obtain filtered array $temp_module->call_vardef_handler($meta_filter); $field_array = $temp_module->vardef_handler->get_vardef_array(); $field_count = 0; $result_array = array(); $actions = $action_shell->get_actions($action_shell->id); $action_fields = array(); foreach ($actions as $action) { if (!empty($action->field)) { //Check if the actions field is still valid (was not deleted or changed) if (empty($field_array[$action->field])) { //invalid field $result_array[] = array("ACTION_VALUE" => "", "ACTION_ACTION_ID" => "", "ACTION_SET_TYPE" => "", "ACTION_ADV_TYPE" => "", "START_DISPLAY" => "", "FIELD_NUM" => $field_count, "FIELD_VALUE" => $action->field, "FIELD_VALUE" => $action->field, "ACTION_DISPLAY_TEXT" => false, "ACTION_ADV_VALUE" => "", "ACTION_EXT1" => "", "ACTION_EXT2" => "", "ACTION_EXT3" => ""); if (!$get_all_fields) { ++$field_count; } continue; } $action_fields[$action->field] = $action->field; } } /* We should NOT be itterating over every field in the module per actionshell, * calling multiple queries per field just to throw out the results. * We should start with the list of actions and the fields they provide * if we are not attempting to add a new action. (when $get_all_fields is false) */ if (!$get_all_fields) { $field_array = $action_fields; } foreach ($field_array as $key => $value) { //check to see if this record exists already if (!empty($action_shell->id) && $action_shell->id != "") { $action_id = $action_shell->get_action_id($key); if ($action_id !== false) { $action_object = BeanFactory::getBean('WorkFlowActions', $action_id); $act_action_value = $action_object->value; $start_display = "none"; $act_id = $action_object->id; $act_set_type = $action_object->set_type; $act_adv_type = $action_object->adv_type; $start_display = ""; } else { $start_display = $this->target_bean->check_required_field("start_display", $temp_module, $key); $act_action_value = ""; $act_id = ""; $act_set_type = ""; $act_adv_type = ""; } } else { $action_id = false; $start_display = $this->target_bean->check_required_field("start_display", $temp_module, $key); $act_action_value = ""; $act_id = ""; $act_set_type = ""; $act_adv_type = ""; } if ($action_id !== false) { $act_adv_value = $action_object->value; $act_ext1 = $action_object->ext1; $act_ext2 = $action_object->ext2; $act_ext3 = $action_object->ext3; } else { $act_adv_value = ""; $act_ext1 = ""; $act_ext2 = ""; $act_ext3 = ""; } // get the label for the field $field = $temp_module->getFieldDefinition($value); $field_label = $value; if (is_array($field) && isset($field['vname'])) { // lets get the correct label $mod_strings = return_module_language($GLOBALS['current_language'], $temp_module->module_name); if (isset($mod_strings[$field['vname']])) { $field_label = str_replace(':', '', $mod_strings[$field['vname']]); } } $sub_array = array(); $sub_array["ACTION_VALUE"] = $act_action_value; $sub_array["ACTION_ACTION_ID"] = $act_id; $sub_array["ACTION_SET_TYPE"] = $act_set_type; $sub_array["ACTION_ADV_TYPE"] = $act_adv_type; $sub_array["START_DISPLAY"] = $start_display; $sub_array["FIELD_NUM"] = $field_count; $sub_array["FIELD_VALUE"] = $key; $sub_array["FIELD_NAME"] = $field_label; $sub_array["ACTION_DISPLAY_TEXT"] = get_display_text($temp_module, $key, $act_action_value, $act_adv_type, $act_ext1, array('for_action_display' => true)); $sub_array["ACTION_ADV_VALUE"] = $act_adv_value; $sub_array["ACTION_EXT1"] = $act_ext1; $sub_array["ACTION_EXT2"] = $act_ext2; $sub_array["ACTION_EXT3"] = $act_ext3; $result_array[] = $sub_array; ++$field_count; //end foreach } $combined_results = array(); $combined_results["RESULT_ARRAY"] = $result_array; $combined_results["TEMP_MODULE_DIR"] = $temp_module->module_dir; return $combined_results; }
function 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->formatName($source_object); } else { //use the past value return $locale->formatName($source_object, $source_object->fetched_row); } } elseif ($field_name == 'modified_by_name' && $use_past_array) { return $source_object->old_modified_by_name; } elseif ($field_name == 'assigned_user_name') { //load the user for either the current value or past value. // We have to load the user here since fetched_row only has the ID, not the name if ($use_past_array) { //return previous assigned user from fetched row return get_username_by_id($source_object->fetched_row['assigned_user_id']); } //return current assigned user in source object return get_username_by_id($source_object->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 get_display_text($source_object, $field_name, $source_object->{$field_name}, null, null, $context); } else { //use the past value return 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 }