$t_normal_date_format = config_get('normal_date_format'); $t_total_time = 0; $t_bugnote_user_edit_threshold = config_get('bugnote_user_edit_threshold'); $t_bugnote_user_delete_threshold = config_get('bugnote_user_delete_threshold'); $t_bugnote_user_change_view_state_threshold = config_get('bugnote_user_change_view_state_threshold'); $t_can_edit_all_bugnotes = access_has_bug_level(config_get('update_bugnote_threshold'), $f_bug_id); $t_can_delete_all_bugnotes = access_has_bug_level(config_get('delete_bugnote_threshold'), $f_bug_id); $t_can_change_view_state_all_bugnotes = $t_can_edit_all_bugnotes && access_has_bug_level(config_get('change_view_status_threshold'), $f_bug_id); for ($i = 0; $i < $num_notes; $i++) { $t_bugnote = $t_bugnotes[$i]; if ($t_bugnote->date_submitted != $t_bugnote->last_modified) { $t_bugnote_modified = true; } else { $t_bugnote_modified = false; } $t_bugnote_id_formatted = bugnote_format_id($t_bugnote->id); if (0 != $t_bugnote->time_tracking) { $t_time_tracking_hhmm = db_minutes_to_hhmm($t_bugnote->time_tracking); $t_bugnote->note_type = TIME_TRACKING; // for older entries that didn't set the type @@@PLR FIXME $t_total_time += $t_bugnote->time_tracking; } else { $t_time_tracking_hhmm = ''; } if (VS_PRIVATE == $t_bugnote->view_state) { $t_bugnote_css = 'bugnote-private'; } else { $t_bugnote_css = 'bugnote-public'; } if (TIME_TRACKING == $t_bugnote->note_type) { $t_bugnote_css .= ' bugnote-time-tracking';
/** * Remove one or more bug revisions from the bug history. * @param int $p_revision_id Revision ID, or array of revision IDs * @return null */ function bug_revision_drop( $p_revision_id ) { $t_bug_rev_table = db_get_table( 'bug_revision' ); if ( is_array( $p_revision_id ) ) { $t_revisions = array(); $t_first = true; $t_query = "DELETE FROM $t_bug_rev_table WHERE id IN ( "; # TODO: Fetch bug revisions in one query (and cache them) foreach( $p_revision_id as $t_rev_id ) { $t_query .= ( $t_first ? db_param() : ', ' . db_param() ); $t_revisions[$t_rev_id] = bug_revision_get( $t_rev_id ); } $t_query .= ' )'; db_query_bound( $t_query, $p_revision_id ); foreach( $p_revision_id as $t_rev_id ) { if ( $t_revisions[$t_rev_id]['type'] == REV_BUGNOTE ) { history_log_event_special( $t_revisions[$t_rev_id]['bug_id'], BUGNOTE_REVISION_DROPPED, bugnote_format_id( $t_rev_id ), $t_revisions[$t_rev_id]['bugnote_id'] ); } else { history_log_event_special( $t_revisions[$t_rev_id]['bug_id'], BUG_REVISION_DROPPED, bugnote_format_id( $t_rev_id ), $t_revisions[$t_rev_id]['type'] ); } } } else { $t_revision = bug_revision_get( $p_revision_id ); $t_query = "DELETE FROM $t_bug_rev_table WHERE id=" . db_param(); db_query_bound( $t_query, array( $p_revision_id ) ); if ( $t_revision['type'] == REV_BUGNOTE ) { history_log_event_special( $t_revision['bug_id'], BUGNOTE_REVISION_DROPPED, bugnote_format_id( $p_revision_id ), $t_revision['bugnote_id'] ); } else { history_log_event_special( $t_revision['bug_id'], BUG_REVISION_DROPPED, bugnote_format_id( $p_revision_id ), $t_revision['type'] ); } } }
$v3_note = db_result($result2, 0, 0); $v3_bugnote_text_id = db_result($result2, 0, 1); $v3_note = string_display_links($v3_note); ?> <tr> <td class="print-spacer" colspan="2"> <hr size="1" /> </td> </tr> <tr> <td class="nopad" valign="top" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id($v3_id); ?> ) </td> </tr> <tr> <td class="print"> <?php echo print_user($v3_reporter_id); ?> </td> </tr> <tr> <td class="print"> <?php
$t_note = db_result($t_result2, 0, 0); $t_bugnote_text_id = db_result($t_result2, 0, 1); $t_note = string_display_links($t_note); ?> <tr> <td class="print-spacer" colspan="2"> <hr /> </td> </tr> <tr> <td class="nopad" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id($t_row['id']); ?> ) </td> </tr> <tr> <td class="print"> <?php print_user($t_row['reporter_id']); ?>     </td> </tr> <tr> <td class="print"> <?php
/** * return an href anchor that links to a bug VIEW page for the given bug * account for the user preference and site override * @param integer $p_bug_id A bug identifier. * @param integer $p_bugnote_id A bugnote identifier. * @param integer $p_user_id A valid user identifier. * @param boolean $p_detail_info Whether to include more detailed information (e.g. title attribute / project) in the returned string. * @param boolean $p_fqdn Whether to return an absolute or relative link. * @return string */ function string_get_bugnote_view_link($p_bug_id, $p_bugnote_id, $p_user_id = null, $p_detail_info = true, $p_fqdn = false) { $t_bug_id = (int) $p_bug_id; if (bug_exists($t_bug_id) && bugnote_exists($p_bugnote_id)) { $t_link = '<a href="'; if ($p_fqdn) { $t_link .= config_get_global('path'); } else { $t_link .= config_get_global('short_path'); } $t_link .= string_get_bugnote_view_url($p_bug_id, $p_bugnote_id, $p_user_id) . '"'; if ($p_detail_info) { $t_reporter = string_attribute(user_get_name(bugnote_get_field($p_bugnote_id, 'reporter_id'))); $t_update_date = string_attribute(date(config_get('normal_date_format'), bugnote_get_field($p_bugnote_id, 'last_modified'))); $t_link .= ' title="' . bug_format_id($t_bug_id) . ': [' . $t_update_date . '] ' . $t_reporter . '"'; } $t_link .= '>' . bug_format_id($t_bug_id) . ':' . bugnote_format_id($p_bugnote_id) . '</a>'; } else { $t_link = bugnote_format_id($t_bug_id) . ':' . bugnote_format_id($p_bugnote_id); } return $t_link; }
/** * Set the view state of the bugnote * @param int $p_bugnote_id bugnote id * @param bool $p_private * @return bool * @access public */ function bugnote_set_view_state($p_bugnote_id, $p_private) { $c_bugnote_id = db_prepare_int($p_bugnote_id); $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id'); if ($p_private) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } $t_bugnote_table = db_get_table('mantis_bugnote_table'); $query = "UPDATE {$t_bugnote_table}\n\t\t \tSET view_state=" . db_param() . "\n\t\t \tWHERE id=" . db_param(); db_query_bound($query, array($t_view_state, $c_bugnote_id)); history_log_event_special($t_bug_id, BUGNOTE_STATE_CHANGED, $t_view_state, bugnote_format_id($p_bugnote_id)); return true; }
/** * Set the view state of the bugnote * @param integer $p_bugnote_id A bugnote identifier. * @param boolean $p_private Whether bugnote should be set to private status. * @return boolean * @access public */ function bugnote_set_view_state($p_bugnote_id, $p_private) { $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id'); if ($p_private) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } $t_query = 'UPDATE {bugnote} SET view_state=' . db_param() . ' WHERE id=' . db_param(); db_query($t_query, array($t_view_state, $p_bugnote_id)); history_log_event_special($t_bug_id, BUGNOTE_STATE_CHANGED, $t_view_state, bugnote_format_id($p_bugnote_id)); return true; }
/** * 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; }
$t_last_modified = date($t_date_format, $t_bugnote->last_modified); # grab the bugnote text and id and prefix with v3_ $t_note = string_display_links($t_bugnote->note); ?> <tr> <td class="print-spacer" colspan="2"> <hr /> </td> </tr> <tr> <td class="nopad" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id($t_bugnote->id); ?> ) </td> </tr> <tr> <td class="print"> <?php print_user($t_bugnote->reporter_id); ?>     </td> </tr> <tr> <td class="print"> <?php
/** * Gen delete bugnote message. */ function gen_del_bugnote_msg($user_id, $bug_id, $bugnote_id) { $send_msg = plugin_lang_get('msg_call') . ' ' . get_username($user_id) . '! ' . plugin_lang_get('msg_action_bugnote_del') . "\n" . plugin_lang_get('msg_bug_id') . ' ' . bug_format_id($bug_id, 'category_id') . "\n" . plugin_lang_get('msg_proj_id') . ' ' . project_get_name(bug_get_field($bug_id, 'project_id')) . "\n" . plugin_lang_get('msg_state') . ' ' . get_enum_element('status', bug_get_field($bug_id, 'status')) . "\n" . plugin_lang_get('msg_header') . ' ' . bug_get_field($bug_id, 'summary') . "\n" . plugin_lang_get('separator') . "\n" . plugin_lang_get('msg_note_id') . bugnote_format_id($bugnote_id) . "\n" . plugin_lang_get('msg_initiator') . ' ' . get_auth_username() . "\n" . plugin_lang_get('separator') . "\n" . plugin_lang_get('msg_link_bug') . ' ' . get_bug_link($bug_id); return $send_msg; }
$row = db_fetch_array($result); extract($row, EXTR_PREFIX_ALL, 'v3'); if (db_unixtimestamp($v3_date_submitted) != db_unixtimestamp($v3_last_modified)) { $t_bugnote_modified = true; } else { $t_bugnote_modified = false; } $v3_date_submitted = date(config_get('normal_date_format'), db_unixtimestamp($v3_date_submitted)); $v3_last_modified = date(config_get('normal_date_format'), db_unixtimestamp($v3_last_modified)); # grab the bugnote text and id and prefix with v3_ $query = "SELECT note\n\t\t\t\tFROM {$t_bugnote_text_table}\n\t\t\t\tWHERE id='{$v3_bugnote_text_id}'"; $result2 = db_query($query); $row = db_fetch_array($result2); $v3_note = $row['note']; $v3_note = string_display_links($v3_note); $t_bugnote_id_formatted = bugnote_format_id($v3_id); if (VS_PRIVATE == $v3_view_state) { $t_bugnote_css = 'bugnote-private'; $t_bugnote_note_css = 'bugnote-note-private'; } else { $t_bugnote_css = 'bugnote-public'; $t_bugnote_note_css = 'bugnote-note-public'; } ?> <tr class="bugnote" name="<?php echo $v3_id; ?> " id="<?php echo $v3_id; ?> ">
function bugnote_set_view_state($p_bugnote_id, $p_private) { $c_bugnote_id = db_prepare_int($p_bugnote_id); $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id'); if ($p_private) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } $t_bugnote_table = config_get('mantis_bugnote_table'); # update view_state $query = "UPDATE {$t_bugnote_table}\r\n\t\t \tSET view_state='{$t_view_state}'\r\n\t\t \tWHERE id='{$c_bugnote_id}'"; db_query($query); history_log_event_special($t_bug_id, BUGNOTE_STATE_CHANGED, bugnote_format_id($t_view_state), $p_bugnote_id); return true; }
$v3_note = db_result( $result2, 0, 0 ); $v3_bugnote_text_id = db_result( $result2, 0, 1 ); $v3_note = string_display_links( $v3_note ); ?> <tr> <td class="print-spacer" colspan="2"> <hr /> </td> </tr> <tr> <td class="nopad" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id( $v3_id ) ?>) </td> </tr> <tr> <td class="print"> <?php echo print_user( $v3_reporter_id ); ?>    </td> </tr> <tr> <td class="print"> <?php echo $v3_date_submitted ?>    <?php if ( $v3_date_submitted != $v3_last_modified ) { echo '<br />(' . lang_get( 'last_edited') . lang_get( 'word_separator' ) . $v3_last_modified . ')'; } ?>
} else { $t_time = ''; } ?> <tr> <td class="print-spacer" colspan="2"> <hr /> </td> </tr> <tr> <td class="nopad" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id($t_row->id); ?> ) </td> </tr> <tr> <td class="print"> <?php print_user($t_row->reporter_id); ?>     </td> </tr> <tr> <td class="print"> <?php
$t_last_modified = date( $t_date_format, $t_bugnote->last_modified ); # grab the bugnote text and id and prefix with v3_ $t_note = string_display_links( $t_bugnote->note ); ?> <tr> <td class="print-spacer" colspan="2"> <hr /> </td> </tr> <tr> <td class="nopad" width="20%"> <table class="hide" cellspacing="1"> <tr> <td class="print"> (<?php echo bugnote_format_id( $t_bugnote->id ) ?>) </td> </tr> <tr> <td class="print"> <?php print_user( $t_bugnote->reporter_id ) ?>    </td> </tr> <tr> <td class="print"> <?php echo $t_date_submitted ?>    <?php if ( $t_bugnote->date_submitted != $t_bugnote->last_modified ) { echo '<br />(' . lang_get( 'last_edited') . lang_get( 'word_separator' ) . $t_last_modified . ')'; } ?> </td> </tr>