?> </td> <td class="right"><?php echo sponsorship_format_amount($t_total_owing); ?> </td> <td></td> </tr> <tr> <td colspan="5"></td> <td><?php echo lang_get('total_paid'); ?> </td> <td class="right"><?php echo sponsorship_format_amount($t_total_paid); ?> </td> <td></td> </tr> <!-- BUTTONS --> <tr> <td colspan="5"> </td> <!-- Update Button --> <td colspan="3"> <input type="hidden" name="buglist" value="<?php echo $t_hidden_bug_list; ?> " /> <input type="submit" class="button" value="<?php echo lang_get('update_sponsorship_button');
/** * Print column content for column sponsorship total * * @param BugData $p_bug bug object * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php * @return null * @access public */ function print_column_sponsorship_total($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE) { echo "\t<td class=\"right column-sponsorship\">"; if ($p_bug->sponsorship_total > 0) { $t_sponsorship_amount = sponsorship_format_amount($p_bug->sponsorship_total); echo string_no_break($t_sponsorship_amount); } echo "</td>\n"; }
?> </table> <?php collapse_closed('sponsorship'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title"> <?php collapse_icon('sponsorship'); echo lang_get('users_sponsoring_bug'); $t_details_url = lang_get('sponsorship_process_url'); if (!is_blank($t_details_url)) { echo ' [<a href="' . $t_details_url . '" target="_blank">' . lang_get('sponsorship_more_info') . '</a>]'; } if ($t_total_sponsorship > 0) { echo ' <span style="font-weight: normal;">('; echo sprintf(lang_get('total_sponsorship_amount'), sponsorship_format_amount($t_total_sponsorship)); echo ')</span>'; } ?> </td> </tr> </table> <?php collapse_end('sponsorship'); } # If sponsorship enabled
function print_column_sponsorship_total($p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE) { $t_enable_sponsorship = config_get('enable_sponsorship'); if ($t_enable_sponsorship == ON) { echo "\t<td class=\"right\">"; if ($p_row['sponsorship_total'] > 0) { $t_sponsorship_amount = sponsorship_format_amount($p_row['sponsorship_total']); echo string_no_break($t_sponsorship_amount); } echo "</td>\n"; } }
if (current_user_is_anonymous()) { access_denied(); } $f_bug_id = gpc_get_int('bug_id'); $f_amount = gpc_get_int('amount'); $t_bug = bug_get($f_bug_id, true); if ($t_bug->project_id != helper_get_current_project()) { # in case the current project is not the same project of the bug we are viewing... # ... override the current project. This to avoid problems with categories and handlers lists etc. $g_project_override = $t_bug->project_id; } if (config_get('enable_sponsorship') == OFF) { trigger_error(ERROR_SPONSORSHIP_NOT_ENABLED, ERROR); } access_ensure_bug_level(config_get('sponsor_threshold'), $f_bug_id); helper_ensure_confirmed(sprintf(lang_get('confirm_sponsorship'), $f_bug_id, sponsorship_format_amount($f_amount)), lang_get('sponsor_issue')); if ($f_amount == 0) { # if amount == 0, delete sponsorship by current user (if any) $t_sponsorship_id = sponsorship_get_id($f_bug_id); if ($t_sponsorship_id !== false) { sponsorship_delete($t_sponsorship_id); } } else { # add sponsorship $t_user = auth_get_current_user_id(); if (is_blank(user_get_email($t_user))) { trigger_error(ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL, ERROR); } else { $sponsorship = new SponsorshipData(); $sponsorship->bug_id = $f_bug_id; $sponsorship->user_id = $t_user;
/** * 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); }
?> <table class="width100" cellspacing="1"> <tr> <td class="form-title"> <?php collapse_icon( 'sponsorship' ); echo lang_get( 'users_sponsoring_bug' ); $t_details_url = lang_get( 'sponsorship_process_url' ); if ( !is_blank( $t_details_url ) ) { echo ' [<a href="' . $t_details_url . '" target="_blank">' . lang_get( 'sponsorship_more_info' ) . '</a>]'; } $t_total_sponsorship = bug_get_field( $f_bug_id, 'sponsorship_total' ); if ( $t_total_sponsorship > 0 ) { echo ' <span style="font-weight: normal;">('; echo sprintf( lang_get( 'total_sponsorship_amount' ), sponsorship_format_amount( $t_total_sponsorship ) ); echo ')</span>'; } ?> </td> </tr> </table> <?php collapse_end( 'sponsorship' ); } # If sponsorship enabled
/** * 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 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); }
function format_value($bug, $field_name) { $values = array('id' => function ($bug) { return sprintf('%s <%s>', $bug->id, string_get_bug_view_url_with_fqdn($bug->id)); }, 'project_id' => function ($bug) { return project_get_name($bug->project_id); }, 'reporter_id' => function ($bug) { return '@' . user_get_name($bug->reporter_id); }, 'handler_id' => function ($bug) { return empty($bug->handler_id) ? plugin_lang_get('no_user') : '@' . user_get_name($bug->handler_id); }, 'duplicate_id' => function ($bug) { return sprintf('%s <%s>', $bug->duplicate_id, string_get_bug_view_url_with_fqdn($bug->duplicate_id)); }, 'priority' => function ($bug) { return get_enum_element('priority', $bug->priority); }, 'severity' => function ($bug) { return get_enum_element('severity', $bug->severity); }, 'reproducibility' => function ($bug) { return get_enum_element('reproducibility', $bug->reproducibility); }, 'status' => function ($bug) { return get_enum_element('status', $bug->status); }, 'resolution' => function ($bug) { return get_enum_element('resolution', $bug->resolution); }, 'projection' => function ($bug) { return get_enum_element('projection', $bug->projection); }, 'category_id' => function ($bug) { return category_full_name($bug->category_id, false); }, 'eta' => function ($bug) { return get_enum_element('eta', $bug->eta); }, 'view_state' => function ($bug) { return $bug->view_state == VS_PRIVATE ? lang_get('private') : lang_get('public'); }, 'sponsorship_total' => function ($bug) { return sponsorship_format_amount($bug->sponsorship_total); }, 'os' => function ($bug) { return $bug->os; }, 'os_build' => function ($bug) { return $bug->os_build; }, 'platform' => function ($bug) { return $bug->platform; }, 'version' => function ($bug) { return $bug->version; }, 'fixed_in_version' => function ($bug) { return $bug->fixed_in_version; }, 'target_version' => function ($bug) { return $bug->target_version; }, 'build' => function ($bug) { return $bug->build; }, 'summary' => function ($bug) { return HipChatPlugin::clean_summary(bug_format_summary($bug->id, SUMMARY_FIELD)); }, 'last_updated' => function ($bug) { return date(config_get('short_date_format'), $bug->last_updated); }, 'date_submitted' => function ($bug) { return date(config_get('short_date_format'), $bug->date_submitted); }, 'due_date' => function ($bug) { return date(config_get('short_date_format'), $bug->due_date); }, 'description' => function ($bug) { return string_display_links($bug->description); }, 'steps_to_reproduce' => function ($bug) { return string_display_links($bug->steps_to_reproduce); }, 'additional_information' => function ($bug) { return string_display_links($bug->additional_information); }); // Discover custom fields. $t_related_custom_field_ids = custom_field_get_linked_ids($bug->project_id); foreach ($t_related_custom_field_ids as $t_id) { $t_def = custom_field_get_definition($t_id); $values['custom_' . $t_def['name']] = function ($bug) use($t_id) { return custom_field_get_value($t_id, $bug->id); }; } if (isset($values[$field_name])) { $func = $values[$field_name]; return $func($bug); } else { return sprintf(plugin_lang_get('unknown_field'), $field_name); } }
$t_bug = bug_get( $f_bug_id, true ); if( $t_bug->project_id != helper_get_current_project() ) { # in case the current project is not the same project of the bug we are viewing... # ... override the current project. This to avoid problems with categories and handlers lists etc. $g_project_override = $t_bug->project_id; } if ( config_get( 'enable_sponsorship' ) == OFF ) { trigger_error( ERROR_SPONSORSHIP_NOT_ENABLED, ERROR ); } access_ensure_bug_level( config_get( 'sponsor_threshold' ), $f_bug_id ); helper_ensure_confirmed( sprintf( lang_get( 'confirm_sponsorship' ), $f_bug_id, sponsorship_format_amount( $f_amount ) ), lang_get( 'sponsor_issue' ) ); if ( $f_amount == 0 ) { # if amount == 0, delete sponsorship by current user (if any) $t_sponsorship_id = sponsorship_get_id( $f_bug_id ); if ( $t_sponsorship_id !== false ) { sponsorship_delete( $t_sponsorship_id ); } } else { # add sponsorship $t_user = auth_get_current_user_id(); if ( is_blank( user_get_email( $t_user ) ) ) { trigger_error( ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL, ERROR ); } else { $sponsorship = new SponsorshipData;
} } $t_hidden_bug_list = implode( ',', $t_buglist ); ?> <!-- Totals --> <tr> <td colspan="5"></td> <td><?php echo lang_get( 'total_owing' ) ?></td> <td class="right"><?php echo sponsorship_format_amount( $t_total_owing ) ?></td> <td></td> </tr> <tr> <td colspan="5"></td> <td><?php echo lang_get( 'total_paid' ) ?></td> <td class="right"><?php echo sponsorship_format_amount( $t_total_paid ) ?></td> <td></td> </tr> <input type="hidden" name="buglist" value="<?php echo $t_hidden_bug_list ?>" /> <!-- BUTTONS --> <tr> <td colspan="5"> </td> <!-- Update Button --> <td colspan="2"> <input type="submit" class="button" value="<?php echo lang_get( 'update_sponsorship_button' ) ?>" /> </td> </tr> </table> </form> </div> <?php } # end sponsored issues ?>
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; }