</tr> <?php event_signal('EVENT_VIEW_BUGNOTE', array($f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state)); ?> <tr class="spacer"> <td colspan="2"></td> </tr> <?php } # end for loop event_signal('EVENT_VIEW_BUGNOTES_END', $f_bug_id); ?> </table> <?php if ($t_total_time > 0 && access_has_bug_level(config_get('time_tracking_view_threshold'), $f_bug_id)) { echo '<p class="time-tracking-total">', sprintf(lang_get('total_time_for_issue'), '<span class="time-tracked">' . db_minutes_to_hhmm($t_total_time) . '</span>'), '</p>'; } collapse_closed('bugnotes'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php collapse_icon('bugnotes'); ?> <?php echo lang_get('bug_notes_title'); ?> </td> </tr>
/** * Returns time tracking information from a bug note. * * @param integer $p_issue_id The id of the issue. * @param array $p_note A note as passed to the soap api methods. * * @return String the string time entry to be added to the bugnote, in 'HH:mm' format */ function mci_get_time_tracking_from_note($p_issue_id, array $p_note) { if (!access_has_bug_level(config_get('time_tracking_view_threshold'), $p_issue_id)) { return '00:00'; } if (!isset($p_note['time_tracking'])) { return '00:00'; } return db_minutes_to_hhmm($p_note['time_tracking']); }
?> </td> </tr> <?php } # end for loop ?> <tr class="row-category2"> <td class="small-caption bold"> <?php echo lang_get('total_time'); ?> </td> <td class="small-caption bold"> <?php echo db_minutes_to_hhmm($t_sum_in_minutes); ?> </td> </tr> </table> <?php } # end if collapse_closed('bugnotestats'); ?> <table class="width100" cellspacing="0"> <tr> <td class="form-title" colspan="4"> <?php
<?php } ?> </tr> <?php } ?> <tr class="row-category2"> <td class="small-caption bold"> <?php echo lang_get('total_time'); ?> </td> <td class="small-caption bold"> <?php echo db_minutes_to_hhmm($t_bugnote_stats['total']['minutes']); ?> </td> <?php if ($t_cost_col) { ?> <td class="small-caption bold right"> <?php echo string_attribute(number_format($t_bugnote_stats['total']['cost'], 2)); ?> </td> <?php } ?> </tr> </table>
} echo string_display_links($t_bugnote->note); ?> </td> </tr> <?php event_signal('EVENT_VIEW_BUGNOTE', array($f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state)); ?> <tr class="spacer"> <td colspan="2"></td> </tr> <?php } # end for loop if ($t_total_time > 0 && access_has_bug_level(config_get('time_tracking_view_threshold'), $f_bug_id)) { echo '<tr><td colspan="2">', sprintf(lang_get('total_time_for_issue'), db_minutes_to_hhmm($t_total_time)), '</td></tr>'; } event_signal('EVENT_VIEW_BUGNOTES_END', $f_bug_id); ?> </table> <?php collapse_closed('bugnotes'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php collapse_icon('bugnotes'); ?>
/** * Build a string that captures all the notes visible to the logged in user along with their * metadata. The string will contain information about each note including reporter, timestamp, * time tracking, view state. This will result in multi-line string with "\n" as the line * separator. * * @param integer $p_bug_id A bug identifier. * @param integer $p_user_bugnote_order Sort order. * @param integer $p_user_bugnote_limit Number of bugnotes to display to user. * @param integer $p_user_id An user identifier. * @return string The string containing all visible notes. * @access public */ function bugnote_get_all_visible_as_string($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit, $p_user_id = null) { $t_notes = bugnote_get_all_visible_bugnotes($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit, $p_user_id); $t_date_format = config_get('normal_date_format'); $t_show_time_tracking = access_has_bug_level(config_get('time_tracking_view_threshold'), $p_bug_id); $t_output = ''; foreach ($t_notes as $t_note) { $t_note_string = '@' . user_get_name($t_note->reporter_id); if ($t_note->view_state != VS_PUBLIC) { $t_note_string .= ' (' . lang_get('private') . ')'; } $t_note_string .= ' ' . date($t_date_format, $t_note->date_submitted); if ($t_show_time_tracking && $t_note->note_type == TIME_TRACKING) { $t_time_tracking_hhmm = db_minutes_to_hhmm($t_note->time_tracking); $t_note_string .= ' ' . lang_get('time_tracking_time_spent') . ' ' . $t_time_tracking_hhmm; } $t_note_string .= "\n" . $t_note->note . "\n"; if (!empty($t_output)) { $t_output .= "---\n"; } $t_output .= $t_note_string; } return $t_output; }
/** * 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; }
# Check if the current user is allowed to edit the bugnote $t_user_id = auth_get_current_user_id(); $t_reporter_id = bugnote_get_field($f_bugnote_id, 'reporter_id'); if ($t_user_id != $t_reporter_id || OFF == config_get('bugnote_allow_user_edit_delete')) { access_ensure_bugnote_level(config_get('update_bugnote_threshold'), $f_bugnote_id); } # Check if the bug is readonly if (bug_is_readonly($t_bug_id)) { error_parameters($t_bug_id); trigger_error(ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR); } $t_bugnote_text = string_textarea(bugnote_get_text($f_bugnote_id)); # No need to gather the extra information if not used if (config_get('time_tracking_enabled') && access_has_bug_level(config_get('time_tracking_edit_threshold'), $t_bug_id)) { $t_time_tracking = bugnote_get_field($f_bugnote_id, "time_tracking"); $t_time_tracking = db_minutes_to_hhmm($t_time_tracking); } # Determine which view page to redirect back to. $t_redirect_url = string_get_bug_view_url($t_bug_id); html_page_top(bug_format_summary($t_bug_id, SUMMARY_CAPTION)); ?> <br /> <div align="center"> <form method="post" action="bugnote_update.php"> <?php echo form_security_field('bugnote_update'); ?> <table class="width75" cellspacing="1"> <tr> <td class="form-title"> <input type="hidden" name="bugnote_id" value="<?php
/** * Converts an array of bugnotes to array of billing rows * * @param array $p_bugnotes Array of bugnotes * @return array Array of billing rows * @access private */ function billing_rows_to_array($p_bugnotes) { $t_billing_rows = array(); foreach ($p_bugnotes as $t_note) { $t_row = array(); $t_row['id'] = $t_note['id']; $t_row['minutes'] = $t_note['minutes']; $t_row['duration'] = db_minutes_to_hhmm($t_note['minutes']); $t_row['note'] = $t_note['note']; $t_row['reporter_id'] = $t_note['reporter_id']; $t_row['reporter_username'] = user_get_name($t_note['reporter_id']); $t_row['reporter_realname'] = user_get_realname($t_note['reporter_id']); $t_row['date_submitted'] = $t_note['date_submitted']; if (is_blank($t_row['reporter_realname'])) { $t_row['reporter_realname'] = $t_row['reporter_username']; } $t_row['bug_id'] = $t_note['bug_id']; $t_row['bug_summary'] = $t_note['bug_summary']; $t_row['cost'] = $t_note['cost']; $t_billing_rows[] = $t_row; } return $t_billing_rows; }
> <td class="small-caption"> <?php echo lang_get('total_time'); ?> (<?php echo bug_format_id($t_bug_key); ?> ) </td> <td class="small-caption"> <?php echo number_format($t_bug_value, 2, '.', ','); ?> (<?php echo db_minutes_to_hhmm($t_bug_value * 60); ?> ) </td> </tr> <?php } ?> </table> <?php } ?> </form>
/** * Show TimeTracking information when viewing bugs. * @param string Event name * @param int Bug ID */ function view_bug_time($p_event, $p_bug_id) { $table = plugin_table('data'); $t_user_id = auth_get_current_user_id(); # Pull all Time-Record entries for the current Bug if (access_has_bug_level(plugin_config_get('view_others_threshold'), $p_bug_id)) { $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} ORDER BY timestamp DESC"; } else { if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) { $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} and user = {$t_user_id} ORDER BY timestamp DESC"; } else { // User has no access return; } } $result_pull_timerecords = db_query($query_pull_timerecords); $num_timerecords = db_num_rows($result_pull_timerecords); # Get Sum for this bug $query_pull_hours = "SELECT SUM(hours) as hours FROM {$table} WHERE bug_id = {$p_bug_id}"; $result_pull_hours = db_query($query_pull_hours); $row_pull_hours = db_fetch_array($result_pull_hours); ?> <a name="timerecord" id="timerecord" /><br /> <?php collapse_open('timerecord'); ?> <table class="width100" cellspacing="1"> <tr> <td colspan="6" class="form-title"> <?php collapse_icon('timerecord'); echo plugin_lang_get('title'); ?> </td> </tr> <tr class="row-category"> <td><div align="center"><?php echo plugin_lang_get('user'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('expenditure_date'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('hours'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('information'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('entry_date'); ?> </div></td> <td> </td> </tr> <?php if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) { $current_date = explode("-", date("Y-m-d")); ?> <form name="time_tracking" method="post" action="<?php echo plugin_page('add_record'); ?> " > <?php echo form_security_field('plugin_TimeTracking_add_record'); ?> <input type="hidden" name="bug_id" value="<?php echo $p_bug_id; ?> "> <tr <?php echo helper_alternate_class(); ?> > <td><?php echo user_get_name(auth_get_current_user_id()); ?> </td> <td nowrap> <div align="center"> <select tabindex="5" name="day"><?php print_day_option_list($current_date[2]); ?> </select> <select tabindex="6" name="month"><?php print_month_option_list($current_date[1]); ?> </select> <select tabindex="7" name="year"><?php print_year_option_list($current_date[0]); ?> </select> </div> </td> <td><div align="right"><input type="text" name="time_value" value="00:00" size="5"></div></td> <td><div align="center"><input type="text" name="time_info"></div></td> <td> </td> <td><input name="<?php echo plugin_lang_get('submit'); ?> " type="submit" value="<?php echo plugin_lang_get('submit'); ?> "></td> </tr> </form> <?php } # END Access Control for ($i = 0; $i < $num_timerecords; $i++) { $row = db_fetch_array($result_pull_timerecords); ?> <tr <?php echo helper_alternate_class(); ?> > <td><?php echo user_get_name($row["user"]); ?> </td> <td><div align="center"><?php echo date(config_get("short_date_format"), strtotime($row["expenditure_date"])); ?> </div></td> <td><div align="right"><?php echo db_minutes_to_hhmm($row["hours"] * 60); ?> </div></td> <td><div align="center"><?php echo string_display_links($row["info"]); ?> </div></td> <td><div align="center"><?php echo date(config_get("complete_date_format"), strtotime($row["timestamp"])); ?> </div></td> <?php $user = auth_get_current_user_id(); if ($user == $row["user"] && access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id) || access_has_bug_level(plugin_config_get('admin_threshold'), $p_bug_id)) { ?> <td><a href="<?php echo plugin_page('delete_record'); ?> &bug_id=<?php echo $p_bug_id; ?> &delete_id=<?php echo $row["id"]; echo form_security_param('plugin_TimeTracking_delete_record'); ?> "><?php echo plugin_lang_get('delete'); ?> </a></td> <?php } else { ?> <td> </td> <?php } ?> </tr> <?php } # End for loop ?> <tr class="row-category"> <td><?php echo plugin_lang_get('sum'); ?> </td> <td> </td> <td><div align="right"><b><?php echo db_minutes_to_hhmm($row_pull_hours['hours'] * 60); ?> </b></div></td> <td> </td> <td> </td> <td> </td> </tr> </table> <?php collapse_closed('timerecord'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php collapse_icon('timerecord'); ?> <?php echo plugin_lang_get('title'); ?> </td> </tr> </table> <?php collapse_end('timerecord'); }
} echo implode(', ', $t_to) . '</strong></p>'; echo $t_note; break; case TIME_TRACKING: if ($t_show_time_tracking) { echo '<p><strong>', lang_get('time_tracking_time_spent') . ' ' . $t_time, '</strong></p>'; } echo $t_note; break; default: echo $t_note; break; } ?> </td> </tr> </table> </td> </tr> <?php } # end for loop } # end else ?> </table> <?php if ($t_total_time > 0 && $t_show_time_tracking) { echo '<p align="right">', sprintf(lang_get('total_time_for_issue'), '<strong>' . db_minutes_to_hhmm($t_total_time) . '</strong>'), '</p>'; }