function bfefooter()
 {
     if ("/view.php" == $_SERVER['PHP_SELF']) {
         $t_bugnote_add_text = str_replace(array("\n", "\r"), array('\\n', '\\r'), bugnote_get_text(gpc_get('bugnote_id', '')));
         if ($t_bugnote_add_text) {
             return '<!-- Beginn BFE-Footer -->' . "\n" . '<script type="text/javascript">' . "\n" . '	document.getElementsByName("bugnote_text")[0].value="' . $t_bugnote_add_text . '";' . "\n" . '</script>' . "\n" . '<!-- Ende BFE-Footer -->' . "\n";
         }
     }
 }
Пример #2
0
/**
 * Set the bugnote text
 * @param int $p_bugnote_id bugnote id
 * @param string $p_bugnote_text bugnote text
 * @return bool
 * @access public
 */
function bugnote_set_text($p_bugnote_id, $p_bugnote_text)
{
    $t_old_text = bugnote_get_text($p_bugnote_id);
    if ($t_old_text == $p_bugnote_text) {
        return true;
    }
    $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id');
    $t_bugnote_text_id = bugnote_get_field($p_bugnote_id, 'bugnote_text_id');
    $t_bugnote_text_table = db_get_table('mantis_bugnote_text_table');
    # insert an 'original' revision if needed
    if (bug_revision_count($t_bug_id, REV_BUGNOTE, $p_bugnote_id) < 1) {
        $t_user_id = bugnote_get_field($p_bugnote_id, 'reporter_id');
        $t_timestamp = bugnote_get_field($p_bugnote_id, 'last_modified');
        bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $t_old_text, $p_bugnote_id, $t_timestamp);
    }
    $query = "UPDATE {$t_bugnote_text_table}\n\t\t\tSET note=" . db_param() . " WHERE id=" . db_param();
    db_query_bound($query, array($p_bugnote_text, $t_bugnote_text_id));
    # updated the last_updated date
    bugnote_date_update($p_bugnote_id);
    bug_update_date($t_bug_id);
    # insert a new revision
    $t_user_id = auth_get_current_user_id();
    $t_revision_id = bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $p_bugnote_text, $p_bugnote_id);
    # log new bugnote
    history_log_event_special($t_bug_id, BUGNOTE_UPDATED, bugnote_format_id($p_bugnote_id), $t_revision_id);
    return true;
}
/**
 * Gen change bugnote message.
 */
function gen_change_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_edit') . "\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_change') . str_replace("\n", '', bugnote_get_text($bugnote_id)) . "\n" . plugin_lang_get('msg_initiator') . ' ' . get_auth_username() . "\n" . plugin_lang_get('separator') . "\n" . plugin_lang_get('msg_link_change_note') . ' ' . string_get_bugnote_view_url_with_fqdn($bug_id, $bugnote_id);
    return $send_msg;
}
    # 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;
}
# 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');
?>
Пример #5
0
 function bugnote_add_edit($event, $bug_id, $bugnote_id)
 {
     $bug = bug_get($bug_id);
     $url = string_get_bugnote_view_url_with_fqdn($bug_id, $bugnote_id);
     $project = project_get_name($bug->project_id);
     $summary = HipChatPlugin::clean_summary(bug_format_summary($bug_id, SUMMARY_FIELD));
     $reporter = '@' . user_get_name(auth_get_current_user_id());
     $note = bugnote_get_text($bugnote_id);
     $msg = sprintf(plugin_lang_get($event === 'EVENT_BUGNOTE_ADD' ? 'bugnote_created' : 'bugnote_updated'), $project, $reporter, $summary, $url, $note);
     $this->notify($msg, $this->get_room($project));
 }
Пример #6
0
 function bugnote_add_edit($event, $bug_id, $bugnote_id)
 {
     $this->skip = $this->skip || gpc_get_bool('slack_skip');
     $bug = bug_get($bug_id);
     $url = string_get_bugnote_view_url_with_fqdn($bug_id, $bugnote_id);
     $project = project_get_name($bug->project_id);
     $summary = $this->clean_summary($bug);
     $reporter = '@' . user_get_name(auth_get_current_user_id());
     $note = bugnote_get_text($bugnote_id);
     $msg = sprintf(plugin_lang_get($event === 'EVENT_BUGNOTE_ADD' ? 'bugnote_created' : 'bugnote_updated'), $project, $reporter, $url, $summary, $note);
     $this->notify($msg, $this->get_webhook($project), $this->get_channel($project));
 }
Пример #7
0
 function send_bugnote_notification($bug_id, $bugnote_id, $message_key)
 {
     $bug = bug_get($bug_id);
     $url = string_get_bugnote_view_url_with_fqdn($bug_id, $bugnote_id);
     $project = project_get_name($bug->project_id);
     $summary = HipChatPlugin::clean_summary(bug_format_summary($bug_id, SUMMARY_FIELD));
     $user_name = user_get_name(auth_get_current_user_id());
     $note = bugnote_get_text($bugnote_id);
     $msg = sprintf(plugin_lang_get($message_key), $project, $user_name, $summary, $url, $note);
     $this->notify($msg, $this->get_room($project));
 }
Пример #8
0
/**
 * Set the bugnote text
 * @param integer $p_bugnote_id   A bugnote identifier.
 * @param string  $p_bugnote_text The bugnote text to set.
 * @return boolean
 * @access public
 */
function bugnote_set_text($p_bugnote_id, $p_bugnote_text)
{
    $t_old_text = bugnote_get_text($p_bugnote_id);
    if ($t_old_text == $p_bugnote_text) {
        return true;
    }
    # MySQL 4-bytes UTF-8 chars workaround #21101
    $p_bugnote_text = db_mysql_fix_utf8($p_bugnote_text);
    $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id');
    $t_bugnote_text_id = bugnote_get_field($p_bugnote_id, 'bugnote_text_id');
    # insert an 'original' revision if needed
    if (bug_revision_count($t_bug_id, REV_BUGNOTE, $p_bugnote_id) < 1) {
        $t_user_id = bugnote_get_field($p_bugnote_id, 'reporter_id');
        $t_timestamp = bugnote_get_field($p_bugnote_id, 'last_modified');
        bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $t_old_text, $p_bugnote_id, $t_timestamp);
    }
    db_param_push();
    $t_query = 'UPDATE {bugnote_text} SET note=' . db_param() . ' WHERE id=' . db_param();
    db_query($t_query, array($p_bugnote_text, $t_bugnote_text_id));
    # updated the last_updated date
    bugnote_date_update($p_bugnote_id);
    bug_update_date($t_bug_id);
    # insert a new revision
    $t_user_id = auth_get_current_user_id();
    $t_revision_id = bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $p_bugnote_text, $p_bugnote_id);
    # log new bugnote
    history_log_event_special($t_bug_id, BUGNOTE_UPDATED, bugnote_format_id($p_bugnote_id), $t_revision_id);
    return true;
}