/** * Localizes one raw history item specified by set the next parameters: $p_field_name, $p_type, $p_old_value, $p_new_value * Returns array with two elements indexed as 'note' and 'change' * @param string $p_field_name The field name of the field being localized. * @param integer $p_type The type of the history entry. * @param string $p_old_value The old value of the field. * @param string $p_new_value The new value of the field. * @param boolean $p_linkify Whether to return a string containing hyperlinks. * @return array */ function history_localize_item($p_field_name, $p_type, $p_old_value, $p_new_value, $p_linkify = true) { $t_note = ''; $t_change = ''; $t_field_localized = $p_field_name; $t_raw = true; if (PLUGIN_HISTORY == $p_type) { $t_note = lang_get_defaulted('plugin_' . $p_field_name, $p_field_name); $t_change = isset($p_new_value) ? $p_old_value . ' => ' . $p_new_value : $p_old_value; return array('note' => $t_note, 'change' => $t_change, 'raw' => true); } switch ($p_field_name) { case 'category': $t_field_localized = lang_get('category'); break; case 'status': $p_old_value = get_enum_element('status', $p_old_value); $p_new_value = get_enum_element('status', $p_new_value); $t_field_localized = lang_get('status'); break; case 'severity': $p_old_value = get_enum_element('severity', $p_old_value); $p_new_value = get_enum_element('severity', $p_new_value); $t_field_localized = lang_get('severity'); break; case 'reproducibility': $p_old_value = get_enum_element('reproducibility', $p_old_value); $p_new_value = get_enum_element('reproducibility', $p_new_value); $t_field_localized = lang_get('reproducibility'); break; case 'resolution': $p_old_value = get_enum_element('resolution', $p_old_value); $p_new_value = get_enum_element('resolution', $p_new_value); $t_field_localized = lang_get('resolution'); break; case 'priority': $p_old_value = get_enum_element('priority', $p_old_value); $p_new_value = get_enum_element('priority', $p_new_value); $t_field_localized = lang_get('priority'); break; case 'eta': $p_old_value = get_enum_element('eta', $p_old_value); $p_new_value = get_enum_element('eta', $p_new_value); $t_field_localized = lang_get('eta'); break; case 'view_state': $p_old_value = get_enum_element('view_state', $p_old_value); $p_new_value = get_enum_element('view_state', $p_new_value); $t_field_localized = lang_get('view_status'); break; case 'projection': $p_old_value = get_enum_element('projection', $p_old_value); $p_new_value = get_enum_element('projection', $p_new_value); $t_field_localized = lang_get('projection'); break; case 'sticky': $p_old_value = gpc_string_to_bool($p_old_value) ? lang_get('yes') : lang_get('no'); $p_new_value = gpc_string_to_bool($p_new_value) ? lang_get('yes') : lang_get('no'); $t_field_localized = lang_get('sticky_issue'); break; case 'project_id': if (project_exists($p_old_value)) { $p_old_value = project_get_field($p_old_value, 'name'); } else { $p_old_value = '@' . $p_old_value . '@'; } # Note that the new value maybe an intermediately project and not the # current one. if (project_exists($p_new_value)) { $p_new_value = project_get_field($p_new_value, 'name'); } else { $p_new_value = '@' . $p_new_value . '@'; } $t_field_localized = lang_get('email_project'); break; case 'handler_id': $t_field_localized = lang_get('assigned_to'); case 'reporter_id': if ('reporter_id' == $p_field_name) { $t_field_localized = lang_get('reporter'); } if (0 == $p_old_value) { $p_old_value = ''; } else { $p_old_value = user_get_name($p_old_value); } if (0 == $p_new_value) { $p_new_value = ''; } else { $p_new_value = user_get_name($p_new_value); } break; case 'version': $t_field_localized = lang_get('product_version'); break; case 'fixed_in_version': $t_field_localized = lang_get('fixed_in_version'); break; case 'target_version': $t_field_localized = lang_get('target_version'); break; case 'date_submitted': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('date_submitted'); break; case 'last_updated': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('last_update'); break; case 'os': $t_field_localized = lang_get('os'); break; case 'os_build': $t_field_localized = lang_get('os_version'); break; case 'build': $t_field_localized = lang_get('build'); break; case 'platform': $t_field_localized = lang_get('platform'); break; case 'summary': $t_field_localized = lang_get('summary'); break; case 'duplicate_id': $t_field_localized = lang_get('duplicate_id'); break; case 'sponsorship_total': $t_field_localized = lang_get('sponsorship_total'); break; case 'due_date': if ($p_old_value !== '') { $p_old_value = date(config_get('normal_date_format'), (int) $p_old_value); } if ($p_new_value !== '') { $p_new_value = date(config_get('normal_date_format'), (int) $p_new_value); } $t_field_localized = lang_get('due_date'); break; default: # assume it's a custom field name $t_field_id = custom_field_get_id_from_name($p_field_name); if (false !== $t_field_id) { $t_cf_type = custom_field_type($t_field_id); if ('' != $p_old_value) { $p_old_value = string_custom_field_value_for_email($p_old_value, $t_cf_type); } $p_new_value = string_custom_field_value_for_email($p_new_value, $t_cf_type); $t_field_localized = lang_get_defaulted($p_field_name); } } if (NORMAL_TYPE != $p_type) { switch ($p_type) { case NEW_BUG: $t_note = lang_get('new_bug'); break; case BUGNOTE_ADDED: $t_note = lang_get('bugnote_added') . ': ' . $p_old_value; break; case BUGNOTE_UPDATED: $t_note = lang_get('bugnote_edited') . ': ' . $p_old_value; $t_old_value = (int) $p_old_value; $t_new_value = (int) $p_new_value; if ($p_linkify && bug_revision_exists($t_new_value)) { if (bugnote_exists($t_old_value)) { $t_bug_revision_view_page_argument = 'bugnote_id=' . $t_old_value . '#r' . $t_new_value; } else { $t_bug_revision_view_page_argument = 'rev_id=' . $t_new_value; } $t_change = '<a href="bug_revision_view_page.php?' . $t_bug_revision_view_page_argument . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case BUGNOTE_DELETED: $t_note = lang_get('bugnote_deleted') . ': ' . $p_old_value; break; case DESCRIPTION_UPDATED: $t_note = lang_get('description_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case ADDITIONAL_INFO_UPDATED: $t_note = lang_get('additional_information_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case STEP_TO_REPRODUCE_UPDATED: $t_note = lang_get('steps_to_reproduce_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case FILE_ADDED: $t_note = lang_get('file_added') . ': ' . $p_old_value; break; case FILE_DELETED: $t_note = lang_get('file_deleted') . ': ' . $p_old_value; break; case BUGNOTE_STATE_CHANGED: $p_old_value = get_enum_element('view_state', $p_old_value); $t_note = lang_get('bugnote_view_state') . ': ' . $p_new_value . ': ' . $p_old_value; break; case BUG_MONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_monitor') . ': ' . $p_old_value; break; case BUG_UNMONITOR: if ($p_old_value !== '') { $p_old_value = user_get_name($p_old_value); } $t_note = lang_get('bug_end_monitor') . ': ' . $p_old_value; break; case BUG_DELETED: $t_note = lang_get('bug_deleted') . ': ' . $p_old_value; break; case BUG_ADD_SPONSORSHIP: $t_note = lang_get('sponsorship_added'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_UPDATE_SPONSORSHIP: $t_note = lang_get('sponsorship_updated'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_DELETE_SPONSORSHIP: $t_note = lang_get('sponsorship_deleted'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_PAID_SPONSORSHIP: $t_note = lang_get('sponsorship_paid'); $t_change = user_get_name($p_old_value) . ': ' . get_enum_element('sponsorship', $p_new_value); break; case BUG_ADD_RELATIONSHIP: $t_note = lang_get('relationship_added'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_REPLACE_RELATIONSHIP: $t_note = lang_get('relationship_replaced'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_DEL_RELATIONSHIP: $t_note = lang_get('relationship_deleted'); # Fix for #7846: There are some cases where old value is empty, this may be due to an old bug. if (!is_blank($p_old_value) && $p_old_value > 0) { $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); } else { $t_change = bug_format_id($p_new_value); } break; case BUG_CLONED_TO: $t_note = lang_get('bug_cloned_to') . ': ' . bug_format_id($p_new_value); break; case BUG_CREATED_FROM: $t_note = lang_get('bug_created_from') . ': ' . bug_format_id($p_new_value); break; case TAG_ATTACHED: $t_note = lang_get('tag_history_attached') . ': ' . $p_old_value; break; case TAG_DETACHED: $t_note = lang_get('tag_history_detached') . ': ' . $p_old_value; break; case TAG_RENAMED: $t_note = lang_get('tag_history_renamed'); $t_change = $p_old_value . ' => ' . $p_new_value; break; case BUG_REVISION_DROPPED: $t_note = lang_get('bug_revision_dropped_history') . ': ' . bug_revision_get_type_name($p_new_value) . ': ' . $p_old_value; break; case BUGNOTE_REVISION_DROPPED: $t_note = lang_get('bugnote_revision_dropped_history') . ': ' . $p_new_value . ': ' . $p_old_value; break; } } # output special cases if (NORMAL_TYPE == $p_type) { $t_note = $t_field_localized; $t_change = $p_old_value . ' => ' . $p_new_value; } # end if DEFAULT return array('note' => $t_note, 'change' => $t_change, 'raw' => $t_raw); }
function history_localize_item($p_field_name, $p_type, $p_old_value, $p_new_value) { $t_note = ''; $t_change = ''; $t_field_localized = $p_field_name; switch ($p_field_name) { case 'category': $t_field_localized = lang_get('category'); break; case 'status': $p_old_value = get_enum_element('status', $p_old_value); $p_new_value = get_enum_element('status', $p_new_value); $t_field_localized = lang_get('status'); break; case 'severity': $p_old_value = get_enum_element('severity', $p_old_value); $p_new_value = get_enum_element('severity', $p_new_value); $t_field_localized = lang_get('severity'); break; case 'reproducibility': $p_old_value = get_enum_element('reproducibility', $p_old_value); $p_new_value = get_enum_element('reproducibility', $p_new_value); $t_field_localized = lang_get('reproducibility'); break; case 'resolution': $p_old_value = get_enum_element('resolution', $p_old_value); $p_new_value = get_enum_element('resolution', $p_new_value); $t_field_localized = lang_get('resolution'); break; case 'priority': $p_old_value = get_enum_element('priority', $p_old_value); $p_new_value = get_enum_element('priority', $p_new_value); $t_field_localized = lang_get('priority'); break; case 'eta': $p_old_value = get_enum_element('eta', $p_old_value); $p_new_value = get_enum_element('eta', $p_new_value); $t_field_localized = lang_get('eta'); break; case 'view_state': $p_old_value = get_enum_element('view_state', $p_old_value); $p_new_value = get_enum_element('view_state', $p_new_value); $t_field_localized = lang_get('view_status'); break; case 'projection': $p_old_value = get_enum_element('projection', $p_old_value); $p_new_value = get_enum_element('projection', $p_new_value); $t_field_localized = lang_get('projection'); break; case 'sticky': $p_old_value = gpc_string_to_bool($p_old_value) ? lang_get('yes') : lang_get('no'); $p_new_value = gpc_string_to_bool($p_new_value) ? lang_get('yes') : lang_get('no'); $t_field_localized = lang_get('sticky_issue'); break; case 'project_id': if (project_exists($p_old_value)) { $p_old_value = project_get_field($p_old_value, 'name'); } else { $p_old_value = '@' . $p_old_value . '@'; } # Note that the new value maybe an intermediately project and not the # current one. if (project_exists($p_new_value)) { $p_new_value = project_get_field($p_new_value, 'name'); } else { $p_new_value = '@' . $p_new_value . '@'; } $t_field_localized = lang_get('email_project'); break; case 'handler_id': $t_field_localized = lang_get('assigned_to'); case 'reporter_id': if ('reporter_id' == $p_field_name) { $t_field_localized = lang_get('reporter'); } if (0 == $p_old_value) { $p_old_value = ''; } else { $p_old_value = user_get_name($p_old_value); } if (0 == $p_new_value) { $p_new_value = ''; } else { $p_new_value = user_get_name($p_new_value); } break; case 'fixed_in_version': $t_field_localized = lang_get('fixed_in_version'); break; case 'date_submitted': $t_field_localized = lang_get('date_submitted'); break; case 'last_updated': $t_field_localized = lang_get('last_update'); break; case 'summary': $t_field_localized = lang_get('summary'); break; case 'duplicate_id': $t_field_localized = lang_get('duplicate_id'); break; case 'sponsorship_total': $t_field_localized = lang_get('sponsorship_total'); break; default: # assume it's a custom field name $t_field_id = custom_field_get_id_from_name($p_field_name); if (false !== $t_field_id) { $t_cf_type = custom_field_type($t_field_id); if ('' != $p_old_value) { $p_old_value = string_custom_field_value_for_email($p_old_value, $t_cf_type); } $p_new_value = string_custom_field_value_for_email($p_new_value, $t_cf_type); } } if (NORMAL_TYPE != $p_type) { switch ($p_type) { case NEW_BUG: $t_note = lang_get('new_bug'); break; case BUGNOTE_ADDED: $t_note = lang_get('bugnote_added') . ": " . $p_old_value; break; case BUGNOTE_UPDATED: $t_note = lang_get('bugnote_edited') . ": " . $p_old_value; break; case BUGNOTE_DELETED: $t_note = lang_get('bugnote_deleted') . ": " . $p_old_value; break; case DESCRIPTION_UPDATED: $t_note = lang_get('description_updated'); break; case ADDITIONAL_INFO_UPDATED: $t_note = lang_get('additional_information_updated'); break; case STEP_TO_REPRODUCE_UPDATED: $t_note = lang_get('steps_to_reproduce_updated'); break; case FILE_ADDED: $t_note = lang_get('file_added') . ": " . $p_old_value; break; case FILE_DELETED: $t_note = lang_get('file_deleted') . ": " . $p_old_value; break; case BUGNOTE_STATE_CHANGED: $p_old_value = get_enum_element('view_state', $p_old_value); $t_note = lang_get('bugnote_view_state') . ": " . $p_old_value . ": " . $p_new_value; break; case BUG_MONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_monitor') . ": " . $p_old_value; break; case BUG_UNMONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_end_monitor') . ": " . $p_old_value; break; case BUG_DELETED: $t_note = lang_get('bug_deleted') . ": " . $p_old_value; break; case BUG_ADD_SPONSORSHIP: $t_note = lang_get('sponsorship_added'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_UPDATE_SPONSORSHIP: $t_note = lang_get('sponsorship_updated'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_DELETE_SPONSORSHIP: $t_note = lang_get('sponsorship_deleted'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_PAID_SPONSORSHIP: $t_note = lang_get('sponsorship_paid'); $t_change = user_get_name($p_old_value) . ': ' . get_enum_element('sponsorship', $p_new_value); break; case BUG_ADD_RELATIONSHIP: $t_note = lang_get('relationship_added'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_REPLACE_RELATIONSHIP: $t_note = lang_get('relationship_replaced'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_DEL_RELATIONSHIP: $t_note = lang_get('relationship_deleted'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_CLONED_TO: $t_note = lang_get('bug_cloned_to'); $t_change = bug_format_id($p_new_value); break; case BUG_CREATED_FROM: $t_note = lang_get('bug_created_from'); $t_change = bug_format_id($p_new_value); break; case CHECKIN: $t_note = lang_get('checkin'); break; } } # output special cases if (NORMAL_TYPE == $p_type) { $t_note = $t_field_localized; $t_change = $p_old_value . ' => ' . $p_new_value; } # end if DEFAULT return array('note' => $t_note, 'change' => $t_change); }
/** * Build the bug info part of the message * @param array $p_visible_bug_data * @return string */ function email_format_bug_message($p_visible_bug_data) { $t_normal_date_format = config_get('normal_date_format'); $t_complete_date_format = config_get('complete_date_format'); $t_email_separator1 = config_get('email_separator1'); $t_email_separator2 = config_get('email_separator2'); $t_email_padding_length = config_get('email_padding_length'); $t_status = $p_visible_bug_data['email_status']; $p_visible_bug_data['email_date_submitted'] = date($t_complete_date_format, $p_visible_bug_data['email_date_submitted']); $p_visible_bug_data['email_last_modified'] = date($t_complete_date_format, $p_visible_bug_data['email_last_modified']); $p_visible_bug_data['email_status'] = get_enum_element('status', $t_status); $p_visible_bug_data['email_severity'] = get_enum_element('severity', $p_visible_bug_data['email_severity']); $p_visible_bug_data['email_priority'] = get_enum_element('priority', $p_visible_bug_data['email_priority']); $p_visible_bug_data['email_reproducibility'] = get_enum_element('reproducibility', $p_visible_bug_data['email_reproducibility']); $t_message = $t_email_separator1 . " \n"; if (isset($p_visible_bug_data['email_bug_view_url'])) { $t_message .= $p_visible_bug_data['email_bug_view_url'] . " \n"; $t_message .= $t_email_separator1 . " \n"; } $t_message .= email_format_attribute($p_visible_bug_data, 'email_reporter'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_handler'); $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_project'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_bug'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_category'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_reproducibility'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_severity'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_priority'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_status'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_target_version'); # custom fields formatting foreach ($p_visible_bug_data['custom_fields'] as $t_custom_field_name => $t_custom_field_data) { $t_message .= utf8_str_pad(lang_get_defaulted($t_custom_field_name, null) . ': ', $t_email_padding_length, ' ', STR_PAD_RIGHT); $t_message .= string_custom_field_value_for_email($t_custom_field_data['value'], $t_custom_field_data['type']); $t_message .= " \n"; } # end foreach custom field if (config_get('bug_resolved_status_threshold') <= $t_status) { $p_visible_bug_data['email_resolution'] = get_enum_element('resolution', $p_visible_bug_data['email_resolution']); $t_message .= email_format_attribute($p_visible_bug_data, 'email_resolution'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_fixed_in_version'); } $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_date_submitted'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_last_modified'); $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_summary'); $t_message .= lang_get('email_description') . ": \n" . $p_visible_bug_data['email_description'] . "\n"; if (!is_blank($p_visible_bug_data['email_steps_to_reproduce'])) { $t_message .= "\n" . lang_get('email_steps_to_reproduce') . ": \n" . $p_visible_bug_data['email_steps_to_reproduce'] . "\n"; } if (!is_blank($p_visible_bug_data['email_additional_information'])) { $t_message .= "\n" . lang_get('email_additional_information') . ": \n" . $p_visible_bug_data['email_additional_information'] . "\n"; } if (isset($p_visible_bug_data['relations'])) { if ($p_visible_bug_data['relations'] != '') { $t_message .= $t_email_separator1 . "\n" . str_pad(lang_get('bug_relationships'), 20) . str_pad(lang_get('id'), 8) . lang_get('summary') . "\n" . $t_email_separator2 . "\n" . $p_visible_bug_data['relations']; } } # Sponsorship if (isset($p_visible_bug_data['sponsorship_total']) && $p_visible_bug_data['sponsorship_total'] > 0) { $t_message .= $t_email_separator1 . " \n"; $t_message .= sprintf(lang_get('total_sponsorship_amount'), sponsorship_format_amount($p_visible_bug_data['sponsorship_total'])) . "\n" . "\n"; if (isset($p_visible_bug_data['sponsorships'])) { foreach ($p_visible_bug_data['sponsorships'] as $t_sponsorship) { $t_date_added = date(config_get('normal_date_format'), $t_sponsorship->date_submitted); $t_message .= $t_date_added . ': '; $t_message .= user_get_name($t_sponsorship->user_id); $t_message .= ' (' . sponsorship_format_amount($t_sponsorship->amount) . ')' . " \n"; } } } $t_message .= $t_email_separator1 . " \n\n"; # format bugnotes foreach ($p_visible_bug_data['bugnotes'] as $t_bugnote) { $t_last_modified = date($t_normal_date_format, $t_bugnote->last_modified); $t_formatted_bugnote_id = bugnote_format_id($t_bugnote->id); $t_bugnote_link = string_process_bugnote_link(config_get('bugnote_link_tag') . $t_bugnote->id, false, false, true); if ($t_bugnote->time_tracking > 0) { $t_time_tracking = ' ' . lang_get('time_tracking') . ' ' . db_minutes_to_hhmm($t_bugnote->time_tracking) . "\n"; } else { $t_time_tracking = ''; } if (user_exists($t_bugnote->reporter_id)) { $t_access_level = access_get_project_level($p_visible_bug_data['email_project_id'], $t_bugnote->reporter_id); $t_access_level_string = ' (' . get_enum_element('access_levels', $t_access_level) . ') - '; } else { $t_access_level_string = ''; } $t_string = ' (' . $t_formatted_bugnote_id . ') ' . user_get_name($t_bugnote->reporter_id) . $t_access_level_string . $t_last_modified . "\n" . $t_time_tracking . ' ' . $t_bugnote_link; $t_message .= $t_email_separator2 . " \n"; $t_message .= $t_string . " \n"; $t_message .= $t_email_separator2 . " \n"; $t_message .= $t_bugnote->note . " \n\n"; } # format history if (array_key_exists('history', $p_visible_bug_data)) { $t_message .= lang_get('bug_history') . " \n"; $t_message .= utf8_str_pad(lang_get('date_modified'), 17) . utf8_str_pad(lang_get('username'), 15) . utf8_str_pad(lang_get('field'), 25) . utf8_str_pad(lang_get('change'), 20) . " \n"; $t_message .= $t_email_separator1 . " \n"; foreach ($p_visible_bug_data['history'] as $t_raw_history_item) { $t_localized_item = history_localize_item($t_raw_history_item['field'], $t_raw_history_item['type'], $t_raw_history_item['old_value'], $t_raw_history_item['new_value'], false); $t_message .= utf8_str_pad(date($t_normal_date_format, $t_raw_history_item['date']), 17) . utf8_str_pad($t_raw_history_item['username'], 15) . utf8_str_pad($t_localized_item['note'], 25) . utf8_str_pad($t_localized_item['change'], 20) . "\n"; } $t_message .= $t_email_separator1 . " \n\n"; } return $t_message; }
function email_format_bug_message($p_visible_bug_data) { $t_normal_date_format = config_get('normal_date_format'); $t_complete_date_format = config_get('complete_date_format'); $t_email_separator1 = config_get('email_separator1'); $t_email_separator2 = config_get('email_separator2'); $t_email_padding_length = config_get('email_padding_length'); $t_status = $p_visible_bug_data['email_status']; $p_visible_bug_data['email_date_submitted'] = date($t_complete_date_format, $p_visible_bug_data['email_date_submitted']); $p_visible_bug_data['email_last_modified'] = date($t_complete_date_format, $p_visible_bug_data['email_last_modified']); $p_visible_bug_data['email_status'] = get_enum_element('status', $t_status); $p_visible_bug_data['email_severity'] = get_enum_element('severity', $p_visible_bug_data['email_severity']); $p_visible_bug_data['email_priority'] = get_enum_element('priority', $p_visible_bug_data['email_priority']); $p_visible_bug_data['email_reproducibility'] = get_enum_element('reproducibility', $p_visible_bug_data['email_reproducibility']); $t_message = $t_email_separator1 . " \n"; if (isset($p_visible_bug_data['email_bug_view_url'])) { $t_message .= $p_visible_bug_data['email_bug_view_url'] . " \n"; $t_message .= $t_email_separator1 . " \n"; } $t_message .= email_format_attribute($p_visible_bug_data, 'email_reporter'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_handler'); $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_project'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_bug'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_category'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_reproducibility'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_severity'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_priority'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_status'); # custom fields formatting foreach ($p_visible_bug_data['custom_fields'] as $t_custom_field_name => $t_custom_field_data) { $t_message .= str_pad(lang_get_defaulted($t_custom_field_name, null) . ': ', $t_email_padding_length, ' ', STR_PAD_RIGHT); $t_message .= string_custom_field_value_for_email($t_custom_field_data['value'], $t_custom_field_data['type']); $t_message .= " \n"; } # end foreach custom field if (config_get('bug_resolved_status_threshold') <= $t_status) { $p_visible_bug_data['email_resolution'] = get_enum_element('resolution', $p_visible_bug_data['email_resolution']); $t_message .= email_format_attribute($p_visible_bug_data, 'email_resolution'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_duplicate'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_fixed_in_version'); } $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_date_submitted'); $t_message .= email_format_attribute($p_visible_bug_data, 'email_last_modified'); $t_message .= $t_email_separator1 . " \n"; $t_message .= email_format_attribute($p_visible_bug_data, 'email_summary'); $t_message .= lang_get('email_description') . ": \n" . wordwrap($p_visible_bug_data['email_description']) . "\n"; # MASC RELATIONSHIP if (ON == config_get('enable_relationship')) { if (isset($p_visible_bug_data['relations'])) { $t_message .= $p_visible_bug_data['relations']; } } # MASC RELATIONSHIP # Sponsorship if (isset($p_visible_bug_data['sponsorship_total']) && $p_visible_bug_data['sponsorship_total'] > 0) { $t_message .= $t_email_separator1 . " \n"; $t_message .= sprintf(lang_get('total_sponsorship_amount'), sponsorship_format_amount($p_visible_bug_data['sponsorship_total'])) . "\n" . "\n"; if (isset($p_visible_bug_data['sponsorships'])) { foreach ($p_visible_bug_data['sponsorships'] as $t_sponsorship) { $t_date_added = date(config_get('normal_date_format'), $t_sponsorship->date_submitted); $t_message .= $t_date_added . ': '; $t_message .= user_get_name($t_sponsorship->user_id); $t_message .= ' (' . sponsorship_format_amount($t_sponsorship->amount) . ')' . " \n"; } } } $t_message .= $t_email_separator1 . " \n\n"; # format bugnotes foreach ($p_visible_bug_data['bugnotes'] as $t_bugnote) { $t_last_modified = date($t_normal_date_format, $t_bugnote->last_modified); $t_string = ' ' . user_get_name($t_bugnote->reporter_id) . ' - ' . $t_last_modified . ' '; $t_message .= $t_email_separator2 . " \n"; $t_message .= $t_string . " \n"; $t_message .= $t_email_separator2 . " \n"; $t_message .= wordwrap($t_bugnote->note) . " \n\n"; } # format history if (array_key_exists('history', $p_visible_bug_data)) { $t_message .= lang_get('bug_history') . " \n"; $t_message .= str_pad(lang_get('date_modified'), 16) . str_pad(lang_get('username'), 15) . str_pad(lang_get('field'), 25) . str_pad(lang_get('change'), 20) . " \n"; $t_message .= $t_email_separator1 . " \n"; foreach ($p_visible_bug_data['history'] as $t_raw_history_item) { $t_localized_item = history_localize_item($t_raw_history_item['field'], $t_raw_history_item['type'], $t_raw_history_item['old_value'], $t_raw_history_item['new_value']); $t_message .= str_pad(date($t_normal_date_format, $t_raw_history_item['date']), 16) . str_pad($t_raw_history_item['username'], 15) . str_pad($t_localized_item['note'], 25) . str_pad($t_localized_item['change'], 20) . "\n"; } $t_message .= $t_email_separator1 . " \n\n"; } return $t_message; }