Ejemplo n.º 1
0
function displayResultsCore($query, $fields)
{
    $result = db_query_bound($query);
    $nbRows = 0;
    while ($row = db_fetch_array($result)) {
        $nbRows++;
        $t_bug = bug_get($row['id']);
        print "<tr> \n";
        print '<td><a href="' . string_get_bug_view_url($row['id']) . '">' . bug_format_id($row['id']) . '</a></td>';
        //print "<td> ".string_get_bug_view_url( ))." </td>\n";
        print "<td> " . string_display_line(get_enum_element('status', $t_bug->status)) . " </td>\n";
        print "<td> " . category_get_row($t_bug->category_id)['name'] . " </td>\n";
        print "<td> " . $t_bug->summary . " </td>\n";
        print "<td> " . user_get_field($t_bug->reporter_id, 'username') . " </td>\n";
        if ($t_bug->handler_id != null) {
            print "<td> " . user_get_field($t_bug->handler_id, 'username') . " </td>\n";
        }
        if (sizeof($fields) > 0) {
            for ($i = 0; $i < sizeof($fields); $i++) {
                print "<td> " . $row[$fields[$i]] . " </td>\n";
            }
        }
        print "</tr>\n";
    }
    return $nbRows;
}
Ejemplo n.º 2
0
function relgraph_bug_format_id( $p_bug_id ) {
	$t_pretty_bug_id = bug_format_id( $p_bug_id );
	if ( !preg_match( '/^(([a-zA-z_][0-9a-zA-Z_]*)|(\d+))$/', $t_pretty_bug_id ) ) {
		$t_pretty_bug_id = $p_bug_id;
	}
	return $t_pretty_bug_id;
}
Ejemplo n.º 3
0
function custom_function_default_format_issue_summary($p_issue_id, $p_context = 0)
{
    switch ($p_context) {
        case SUMMARY_CAPTION:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        case SUMMARY_FIELD:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        case SUMMARY_EMAIL:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        default:
            $t_string = string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
    }
    return $t_string;
}
Ejemplo n.º 4
0
/**
 * return an href anchor that links to a bug UPDATE page for the given bug
 * account for the user preference and site override
 * @param integer $p_bug_id  A bug identifier.
 * @param integer $p_user_id A valid user identifier.
 * @return string
 */
function string_get_bug_update_link($p_bug_id, $p_user_id = null)
{
    $t_summary = string_attribute(bug_get_field($p_bug_id, 'summary'));
    return '<a href="' . helper_mantis_url(string_get_bug_update_url($p_bug_id, $p_user_id)) . '" title="' . $t_summary . '">' . bug_format_id($p_bug_id) . '</a>';
}
Ejemplo n.º 5
0
/**
 * Add a file to the system using the configured storage method
 *
 * @param integer $p_bug_id the bug id
 * @param array $p_file the uploaded file info, as retrieved from gpc_get_file()
 */
function file_add($p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null)
{
    file_ensure_uploaded($p_file);
    $t_file_name = $p_file['name'];
    $t_tmp_file = $p_file['tmp_name'];
    if (!file_type_check($t_file_name)) {
        trigger_error(ERROR_FILE_NOT_ALLOWED, ERROR);
    }
    if (!file_is_name_unique($t_file_name, $p_bug_id)) {
        trigger_error(ERROR_FILE_DUPLICATE, ERROR);
    }
    if ('bug' == $p_table) {
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        $t_bug_id = bug_format_id($p_bug_id);
    } else {
        $t_project_id = helper_get_current_project();
        $t_bug_id = 0;
    }
    if ($p_user_id === null) {
        $c_user_id = auth_get_current_user_id();
    } else {
        $c_user_id = (int) $p_user_id;
    }
    # prepare variables for insertion
    $c_bug_id = db_prepare_int($p_bug_id);
    $c_project_id = db_prepare_int($t_project_id);
    $c_file_type = db_prepare_string($p_file['type']);
    $c_title = db_prepare_string($p_title);
    $c_desc = db_prepare_string($p_desc);
    if ($t_project_id == ALL_PROJECTS) {
        $t_file_path = config_get('absolute_path_default_upload_folder');
    } else {
        $t_file_path = project_get_field($t_project_id, 'file_path');
        if (is_blank($t_file_path)) {
            $t_file_path = config_get('absolute_path_default_upload_folder');
        }
    }
    $c_file_path = db_prepare_string($t_file_path);
    $c_new_file_name = db_prepare_string($t_file_name);
    $t_file_hash = 'bug' == $p_table ? $t_bug_id : config_get('document_files_prefix') . '-' . $t_project_id;
    $t_unique_name = file_generate_unique_name($t_file_hash . '-' . $t_file_name, $t_file_path);
    $t_disk_file_name = $t_file_path . $t_unique_name;
    $c_unique_name = db_prepare_string($t_unique_name);
    $t_file_size = filesize($t_tmp_file);
    if (0 == $t_file_size) {
        trigger_error(ERROR_FILE_NO_UPLOAD_FAILURE, ERROR);
    }
    $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
    if ($t_file_size > $t_max_file_size) {
        trigger_error(ERROR_FILE_TOO_BIG, ERROR);
    }
    $c_file_size = db_prepare_int($t_file_size);
    $t_method = config_get('file_upload_method');
    switch ($t_method) {
        case FTP:
        case DISK:
            file_ensure_valid_upload_path($t_file_path);
            if (!file_exists($t_disk_file_name)) {
                if (FTP == $t_method) {
                    $conn_id = file_ftp_connect();
                    file_ftp_put($conn_id, $t_disk_file_name, $t_tmp_file);
                    file_ftp_disconnect($conn_id);
                }
                if (!move_uploaded_file($t_tmp_file, $t_disk_file_name)) {
                    trigger_error(ERROR_FILE_MOVE_FAILED, ERROR);
                }
                chmod($t_disk_file_name, config_get('attachments_file_permissions'));
                $c_content = "''";
            } else {
                trigger_error(ERROR_FILE_DUPLICATE, ERROR);
            }
            break;
        case DATABASE:
            $c_content = db_prepare_binary_string(fread(fopen($t_tmp_file, 'rb'), $t_file_size));
            break;
        default:
            trigger_error(ERROR_GENERIC, ERROR);
    }
    $t_file_table = db_get_table('mantis_' . $p_table . '_file_table');
    $c_id = 'bug' == $p_table ? $c_bug_id : $c_project_id;
    $query = "INSERT INTO {$t_file_table}\n\t\t\t\t\t\t(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id)\n\t\t\t\t\t  VALUES\n\t\t\t\t\t\t({$c_id}, '{$c_title}', '{$c_desc}', '{$c_unique_name}', '{$c_new_file_name}', '{$c_file_path}', {$c_file_size}, '{$c_file_type}', '" . db_now() . "', {$c_content}, {$c_user_id})";
    db_query($query);
    if ('bug' == $p_table) {
        # updated the last_updated date
        $result = bug_update_date($p_bug_id);
        # log new bug
        history_log_event_special($p_bug_id, FILE_ADDED, $t_file_name);
    }
}
Ejemplo n.º 6
0
 $t_bug = bug_get($t_sponsor_row['bug']);
 $t_sponsor = sponsorship_get($t_sponsor_row['sponsor']);
 $t_buglist[] = $t_sponsor_row['bug'] . ':' . $t_sponsor_row['sponsor'];
 # describe bug
 $t_status = string_attribute(get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id));
 $t_resolution = string_attribute(get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id));
 $t_version_id = version_get_id($t_bug->fixed_in_version, $t_bug->project_id);
 if (false !== $t_version_id && VERSION_RELEASED == version_get_field($t_version_id, 'released')) {
     $t_released_label = '<a title="' . lang_get('released') . '">' . $t_bug->fixed_in_version . '</a>';
 } else {
     $t_released_label = $t_bug->fixed_in_version;
 }
 # choose color based on status
 $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
 echo '<tr class="' . $t_status_label . '">';
 echo '<td><a href="' . string_get_bug_view_url($t_sponsor_row['bug']) . '">' . bug_format_id($t_sponsor_row['bug']) . '</a></td>';
 echo '<td>' . string_display_line(project_get_field($t_bug->project_id, 'name')) . '&#160;</td>';
 echo '<td class="right">' . $t_released_label . '&#160;</td>';
 echo '<td><a title="' . $t_resolution . '"><span class="underline">' . $t_status . '</span>&#160;</a></td>';
 # summary
 echo '<td>' . string_display_line($t_bug->summary);
 if (VS_PRIVATE == $t_bug->view_state) {
     printf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
 }
 echo '</td>';
 # describe sponsorship amount
 echo '<td>';
 print_user($t_sponsor->user_id);
 echo '</td>';
 echo '<td class="right">' . sponsorship_format_amount($t_sponsor->amount) . '</td>';
 echo '<td><select name="sponsor_' . $t_row['bug'] . '_' . $t_sponsor->id . '">';
Ejemplo n.º 7
0
/**
 * Gets the formatted bug id value.
 * @param BugData $p_bug The bug object.
 * @return string The bug id prefixed with 0s.
 */
function excel_format_id(BugData $p_bug)
{
    return excel_prepare_number(bug_format_id($p_bug->id));
}
Ejemplo n.º 8
0
function relgraph_generate_dep_graph($p_bug_id, $p_bug = null, $p_horizontal = false)
{
    # List of visited issues and their data.
    $v_bug_list = array();
    # Firstly, we visit all ascendant issues and all descendant issues
    # and collect all the necessary data in the $v_bug_list variable.
    # We do not visit other descendants of our parents, neither other
    # ascendants of our children, to avoid displaying too much unrelated
    # issues. We still collect the information about those relationships,
    # so, if these issues happen to be visited also, relationship links
    # will be preserved.
    # The first issue in the list is the one we are parting from.
    if (null === $p_bug) {
        $p_bug = bug_prepare_display(bug_get($p_bug_id, true));
    }
    $v_bug_list[$p_bug_id] = $p_bug;
    $v_bug_list[$p_bug_id]->is_descendant = true;
    $v_bug_list[$p_bug_id]->parents = array();
    $v_bug_list[$p_bug_id]->children = array();
    # Now we visit all ascendants of the root issue.
    $t_relationships = relationship_get_all_dest($p_bug_id);
    foreach ($t_relationships as $t_relationship) {
        if ($t_relationship->type != BUG_DEPENDANT) {
            continue;
        }
        $v_bug_list[$p_bug_id]->parents[] = $t_relationship->src_bug_id;
        relgraph_add_parent($v_bug_list, $t_relationship->src_bug_id);
    }
    $t_relationships = relationship_get_all_src($p_bug_id);
    foreach ($t_relationships as $t_relationship) {
        if ($t_relationship->type != BUG_DEPENDANT) {
            continue;
        }
        $v_bug_list[$p_bug_id]->children[] = $t_relationship->dest_bug_id;
        relgraph_add_child($v_bug_list, $t_relationship->dest_bug_id);
    }
    # We have already collected all the information we need to generate
    # the graph. Now it is the matter to create a Digraph object and
    # store the information there, along with graph formatting attributes.
    $t_id_string = bug_format_id($p_bug_id);
    $t_graph_fontname = config_get('relationship_graph_fontname');
    $t_graph_fontsize = config_get('relationship_graph_fontsize');
    $t_graph_fontpath = config_get('system_font_folder');
    $t_view_on_click = config_get('relationship_graph_view_on_click');
    $t_dot_tool = config_get('dot_tool');
    $t_graph_attributes = array();
    if (!empty($t_graph_fontpath)) {
        $t_graph_attributes['fontpath'] = $t_graph_fontpath;
    }
    if ($p_horizontal) {
        $t_graph_attributes['rankdir'] = 'LR';
        $t_graph_orientation = 'horizontal';
    } else {
        $t_graph_orientation = 'vertical';
    }
    $t_graph = new Digraph($t_id_string, $t_graph_attributes, $t_dot_tool);
    $t_graph->set_default_node_attr(array('fontname' => $t_graph_fontname, 'fontsize' => $t_graph_fontsize, 'shape' => 'record', 'style' => 'filled', 'height' => '0.2', 'width' => '0.4'));
    $t_graph->set_default_edge_attr(array('style' => 'solid', 'color' => '#C00000', 'dir' => 'back'));
    # Add all issue nodes and edges to the graph.
    foreach ($v_bug_list as $t_related_bug_id => $t_related_bug) {
        $t_id_string = bug_format_id($t_related_bug_id);
        if ($t_view_on_click) {
            $t_url = string_get_bug_view_url($t_related_bug_id);
        } else {
            $t_url = 'bug_relationship_graph.php?bug_id=' . $t_related_bug_id . '&amp;graph=dependency&orientation=' . $t_graph_orientation;
        }
        relgraph_add_bug_to_graph($t_graph, $t_id_string, $t_related_bug, $t_url, $t_related_bug_id == $p_bug_id);
        # Now add all relationship edges to the graph.
        foreach ($v_bug_list[$t_related_bug_id]->parents as $t_parent_id) {
            # Do not create edges for unvisited bugs.
            if (!isset($v_bug_list[$t_parent_id])) {
                continue;
            }
            $t_parent_node = bug_format_id($t_parent_id);
            $t_graph->add_edge($t_parent_node, $t_id_string);
        }
    }
    return $t_graph;
}
Ejemplo n.º 9
0
    ?>
<tr <?php 
    echo helper_alternate_class();
    ?>
>
	<td class="category">
		<?php 
    echo lang_get('relationship_with_parent');
    ?>
	</td>
	<td>
		<?php 
    relationship_list_box(-2, "rel_type", false, true);
    ?>
		<?php 
    print '<b>' . lang_get('bug') . ' ' . bug_format_id($f_master_bug_id) . '</b>';
    ?>
	</td>
</tr>
<?php 
}
?>

<!-- Report Stay (report more bugs) -->
<tr <?php 
echo helper_alternate_class();
?>
>
	<td class="category">
		<?php 
echo lang_get('report_stay');
Ejemplo n.º 10
0
    $t_custom_filter['sort'] = $c_sort_field;
} else {
    # null will be returned if the user doesn't have access right to access the filter.
    $t_custom_filter = filter_db_get_filter($f_filter_id, $t_user_id);
    if (null === $t_custom_filter) {
        access_denied();
    }
    $t_custom_filter = filter_deserialize($t_custom_filter);
}
$t_issues = filter_get_bug_rows($t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky);
# Loop through results
for ($i = 0; $i < count($t_issues); $i++) {
    $row = $t_issues[$i];
    $t_bug = bug_get($row['id'], true);
    $about = $link = $t_path . "view.php?id=" . $row['id'];
    $title = string_rss_links(bug_format_id($row['id']) . ': ' . $t_bug->summary);
    $description = string_rss_links($t_bug->description);
    # subject is category.
    $subject = string_rss_links($t_bug->category);
    # optional DC value
    $date = date('Y-m-d\\TH:i:sO', $t_bug->last_updated);
    # author of item
    $author = string_rss_links(user_get_name($t_bug->reporter_id));
    if (access_has_global_level(config_get('show_user_email_threshold'))) {
        $t_author_email = user_get_field($t_bug->reporter_id, 'email');
        if (is_blank($t_author_email)) {
            $t_author_email = $author . '@example.com';
        }
    } else {
        $t_author_email = $author . '@example.com';
    }
Ejemplo n.º 11
0
echo csv_escape_string(lang_get('summary')) . $t_separator;
if ($t_show_realname) {
    echo csv_escape_string(lang_get('realname')) . $t_separator;
} else {
    echo csv_escape_string(lang_get('username')) . $t_separator;
}
echo csv_escape_string(lang_get('timestamp')) . $t_separator;
echo csv_escape_string(lang_get('minutes')) . $t_separator;
echo csv_escape_string(lang_get('time_tracking_time_spent')) . $t_separator;
if ($t_show_cost) {
    echo csv_escape_string('cost') . $t_separator;
}
echo csv_escape_string('note');
echo "\n";
foreach ($t_billing_rows as $t_billing) {
    echo csv_escape_string(bug_format_id($t_billing['bug_id'])) . $t_separator;
    echo csv_escape_string($t_billing['project_name']) . $t_separator;
    echo csv_escape_string($t_billing['bug_summary']) . $t_separator;
    if ($t_show_realname) {
        echo csv_escape_string($t_billing['reporter_realname']) . $t_separator;
    } else {
        echo csv_escape_string($t_billing['reporter_username']) . $t_separator;
    }
    echo csv_escape_string(date($t_date_format, $t_billing['date_submitted'])) . $t_separator;
    echo csv_escape_string($t_billing['minutes']) . $t_separator;
    echo csv_escape_string($t_billing['duration']) . $t_separator;
    if ($t_show_cost) {
        echo csv_escape_string($t_billing['cost']) . $t_separator;
    }
    echo csv_escape_string($t_billing['note']);
    echo "\n";
/**
 * Gen update view status bug message.
 */
function gen_up_view_status_bug_msg($user_id, $bug_id, $bugnote_text)
{
    $send_msg = plugin_lang_get('msg_call') . ' ' . get_username($user_id) . '! ' . plugin_lang_get('msg_action_bug_up_view') . "\n" . plugin_lang_get('msg_bug_id') . ' ' . bug_format_id($bug_id, 'category_id') . "\n" . plugin_lang_get('msg_state') . ' ' . get_enum_element('status', bug_get_field($bug_id, 'status')) . "\n" . plugin_lang_get('msg_proj_id') . ' ' . project_get_name(bug_get_field($bug_id, 'project_id')) . "\n" . plugin_lang_get('msg_header') . ' ' . bug_get_field($bug_id, 'summary') . "\n" . plugin_lang_get('separator') . "\n" . plugin_lang_get('msg_action_bug_up_view_str') . ' ' . get_enum_element('view_state', gpc_get_int('view_status')) . "\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;
}
Ejemplo n.º 13
0
/**
 * Add a file
 * @param integer $p_id        File id.
 * @param string  $p_name      File name.
 * @param string  $p_content   File content to write.
 * @param string  $p_file_type File type.
 * @param string  $p_table     Database table name.
 * @param string  $p_title     Title.
 * @param string  $p_desc      Description.
 * @param string  $p_user_id   User id.
 * @return mixed
 */
function mci_file_add($p_id, $p_name, $p_content, $p_file_type, $p_table, $p_title = '', $p_desc = '', $p_user_id = null)
{
    if (!file_type_check($p_name)) {
        return SoapObjectsFactory::newSoapFault('Client', 'File type not allowed.');
    }
    if (!file_is_name_unique($p_name, $p_id)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Duplicate filename.');
    }
    $t_file_size = strlen($p_content);
    $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
    if ($t_file_size > $t_max_file_size) {
        return SoapObjectsFactory::newSoapFault('Client', 'File is too big.');
    }
    if ('bug' == $p_table) {
        $t_project_id = bug_get_field($p_id, 'project_id');
        $t_id = (int) $p_id;
        $t_issue_id = bug_format_id($p_id);
    } else {
        $t_project_id = $p_id;
        $t_id = $t_project_id;
        $t_issue_id = 0;
    }
    if ($p_user_id === null) {
        $p_user_id = auth_get_current_user_id();
    }
    if ($t_project_id == ALL_PROJECTS) {
        $t_file_path = config_get('absolute_path_default_upload_folder');
    } else {
        $t_file_path = project_get_field($t_project_id, 'file_path');
        if (is_blank($t_file_path)) {
            $t_file_path = config_get('absolute_path_default_upload_folder');
        }
    }
    $t_unique_name = file_generate_unique_name($t_file_path);
    $t_disk_file_name = $t_file_path . $t_unique_name;
    $t_method = config_get('file_upload_method');
    switch ($t_method) {
        case DISK:
            if (!file_exists($t_file_path) || !is_dir($t_file_path) || !is_writable($t_file_path) || !is_readable($t_file_path)) {
                return SoapObjectsFactory::newSoapFault('Server', 'Upload folder \'' . $t_file_path . '\' doesn\'t exist.');
            }
            file_ensure_valid_upload_path($t_file_path);
            if (!file_exists($t_disk_file_name)) {
                mci_file_write_local($t_disk_file_name, $p_content);
                chmod($t_disk_file_name, config_get('attachments_file_permissions'));
                $c_content = "''";
            }
            break;
        case DATABASE:
            $c_content = db_prepare_binary_string($p_content);
            $t_file_path = '';
            break;
    }
    $t_file_table = db_get_table($p_table . '_file');
    $t_id_col = $p_table . '_id';
    $t_param = array($t_id_col => $t_id, 'title' => $p_title, 'description' => $p_desc, 'diskfile' => $t_unique_name, 'filename' => $p_name, 'folder' => $t_file_path, 'filesize' => $t_file_size, 'file_type' => $p_file_type, 'date_added' => db_now(), 'user_id' => (int) $p_user_id);
    # Oracle has to update BLOBs separately
    if (!db_is_oracle()) {
        $t_param['content'] = $c_content;
    }
    $t_query_param = db_param();
    for ($i = 1; $i < count($t_param); $i++) {
        $t_query_param .= ', ' . db_param();
    }
    $t_query = 'INSERT INTO ' . $t_file_table . '
		( ' . implode(', ', array_keys($t_param)) . ' )
	VALUES
		( ' . $t_query_param . ' )';
    db_query($t_query, array_values($t_param));
    # get attachment id
    $t_attachment_id = db_insert_id($t_file_table);
    if (db_is_oracle()) {
        db_update_blob($t_file_table, 'content', $c_content, "diskfile='{$t_unique_name}'");
    }
    if ('bug' == $p_table) {
        # bump the last_updated date
        bug_update_date($t_issue_id);
        # add history entry
        history_log_event_special($t_issue_id, FILE_ADDED, $p_name);
    }
    return $t_attachment_id;
}
function GetRelationshipContent($p_bug_id, $p_html = false, $p_html_preview = false, $p_summary = false, $p_icons = false)
{
    $t_summary = '';
    $t_icons = '';
    $t_show_project = false;
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 10;
    $t_relationship_all = relationship_get_all($p_bug_id, $t_show_project);
    $t_relationship_all_count = count($t_relationship_all);
    if ($p_summary) {
        for ($i = 0; $i < $t_relationship_all_count; $i++) {
            $p_relationship = $t_relationship_all[$i];
            if ($p_bug_id == $p_relationship->src_bug_id) {
                # root bug is in the src side, related bug in the dest side
                $t_related_bug_id = $p_relationship->dest_bug_id;
                $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
            } else {
                # root bug is in the dest side, related bug in the src side
                $t_related_bug_id = $p_relationship->src_bug_id;
                $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
            }
            # get the information from the related bug and prepare the link
            $t_bug = bug_get($t_related_bug_id, false);
            $t_text = trim(utf8_str_pad($t_relationship_descr, 20)) . ' ';
            if ($p_html_preview == true) {
                $t_text .= '<a href="' . string_get_bug_view_url($t_related_bug_id) . '"';
                $t_text .= ' class="rcv_tooltip"';
                //$t_text .= ' title="' . utf8_str_pad (bug_format_id ($t_related_bug_id), 8) . "\n" . string_attribute ($t_bug->summary) . '"';
                $t_text .= '>';
            }
            $t_text .= string_display_line(bug_format_id($t_related_bug_id));
            if ($p_html_preview == true) {
                $t_text .= '<span class="rcv_tooltip_box">';
                $t_text .= '<span class="rcv_tooltip_title">' . bug_format_id($t_related_bug_id) . '</span>';
                $t_text .= '<span class="rcv_tooltip_content">' . utf8_substr(string_email_links($t_bug->summary), 0, MAX_TOOLTIP_CONTENT_LENGTH);
                $t_text .= MAX_TOOLTIP_CONTENT_LENGTH < strlen($t_bug->summary) ? '...' : '';
                $t_text .= '</span>';
                $t_text .= '</span>';
                $t_text .= '</a>';
            }
            if (plugin_config_get('ShowRelationshipsControl') && !bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && true == $p_html_preview) {
                // bug not read only
                if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
                    // user has access level
                    // add a delete link
                    $t_text .= ' [';
                    $t_text .= '<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id;
                    $t_text .= '&amp;rel_id=' . $p_relationship->id;
                    $t_text .= '&amp;redirect_url=view_all_bug_page.php';
                    $t_text .= htmlspecialchars(form_security_param('bug_relationship_delete'));
                    $t_text .= '">' . lang_get('delete_link') . '</a>';
                    $t_text .= ']';
                }
            }
            // $t_text = relationship_get_details ($p_bug_id, $t_relationship_all[$i], true, false, $t_show_project);
            if (false == $p_html) {
                // p_html == No
                if ($i != 0) {
                    if ($p_html_preview == true) {
                        $t_summary .= ",<br/>";
                    } else {
                        $t_summary .= ", ";
                    }
                }
                $t_summary .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_summary .= '<tr bgcolor="' . get_status_color($t_bug->status, auth_get_current_user_id(), $t_bug->project_id) . '">';
                    $t_summary .= '<td>' . $t_text . '</td>';
                    $t_summary .= '</tr>' . "\n";
                } else {
                    if ($i != 0) {
                        $t_summary .= ", ";
                    }
                    $t_summary .= $t_text;
                }
            }
        }
    }
    if (plugin_config_get('ShowRelationshipIcons') && !current_user_is_anonymous() && true == $p_html_preview) {
        $t_text = RelationshipsUtils::GetBugSmybols($p_bug_id, !is_blank($t_summary));
        if (!is_blank($t_text)) {
            if (false == $p_html) {
                // p_html == No
                $t_icons .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_icons .= '<tr><td>' . $t_text . '</td></tr>' . "\n";
                } else {
                    $t_icons .= $t_text;
                }
            }
        }
    }
    if ($p_html_preview == true) {
        $t_icons_table = '';
        $t_summary_table = '';
        if (!is_blank($t_icons)) {
            $t_icons_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_icons . '</table>';
        }
        if (!is_blank($t_summary)) {
            $t_summary_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_summary . '</table>';
        }
        if (!is_blank($t_icons_table) && !is_blank($t_summary_table)) {
            return '<table border="0" width="100%" cellpadding="0" cellspacing="0">' . '<tr><td valign="top" style="padding:0px;">' . $t_summary_table . '</td><td valign="top" style="padding:0px;">' . $t_icons_table . '</td></tr>' . '</table>';
        } else {
            return $t_summary_table . $t_icons_table;
        }
    } else {
        $t_result = $t_icons;
        if (!is_blank($t_icons) && !is_blank($t_summary)) {
            $t_result .= '<br/>';
        }
        $t_result .= $t_summary;
        return $t_result;
    }
}
Ejemplo n.º 15
0
/**
 * formats the subject correctly
 * we include the project name, bug id, and summary.
 *
 * @param integer $p_bug_id A bug identifier.
 * @return string
 */
function email_build_subject($p_bug_id)
{
    # grab the project name
    $p_project_name = project_get_field(bug_get_field($p_bug_id, 'project_id'), 'name');
    # grab the subject (summary)
    $p_subject = bug_get_field($p_bug_id, 'summary');
    # pad the bug id with zeros
    $t_bug_id = bug_format_id($p_bug_id);
    # build standard subject string
    $t_email_subject = '[' . $p_project_name . ' ' . $t_bug_id . ']: ' . $p_subject;
    # update subject as defined by plugins
    $t_email_subject = event_signal('EVENT_DISPLAY_EMAIL_BUILD_SUBJECT', $t_email_subject, array('bug_id' => $p_bug_id));
    return $t_email_subject;
}
Ejemplo n.º 16
0
    ?>
</td>
<?php 
}
?>

<?php 
$t_first = true;
foreach ($t_bug_rows as $t_bug_id => $t_bug_row) {
    echo $t_first ? '' : '<tr ' . helper_alternate_class() . '>';
    ?>
<td colspan="<?php 
    echo $t_columns - ($t_can_update ? 2 : 1);
    ?>
"><?php 
    echo '<a href="view.php?id=', $t_bug_id, '">', bug_format_id($t_bug_id), '</a>: ', string_display_line($t_bug_row['summary']);
    ?>
</td>
<?php 
    if ($t_can_update) {
        ?>
<td class="center"><span class="small-links"><?php 
        print_bracket_link(plugin_page('detach') . '&id=' . $t_changeset->id . '&bug_id=' . $t_bug_id . form_security_param('plugin_Source_detach'), plugin_lang_get('detach'));
        ?>
</span>
<?php 
    }
    ?>
</tr>

<?php 
Ejemplo n.º 17
0
/**
 * Add a file to the system using the configured storage method
 *
 * @param integer $p_bug_id          The bug id (should be 0 when adding project doc).
 * @param array   $p_file            The uploaded file info, as retrieved from gpc_get_file().
 * @param string  $p_table           Either 'bug' or 'project' depending on attachment type.
 * @param string  $p_title           File title.
 * @param string  $p_desc            File description.
 * @param integer $p_user_id         User id (defaults to current user).
 * @param integer $p_date_added      Date added.
 * @param boolean $p_skip_bug_update Skip bug last modification update (useful when importing bug attachments).
 * @return void
 */
function file_add($p_bug_id, array $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null, $p_date_added = 0, $p_skip_bug_update = false)
{
    file_ensure_uploaded($p_file);
    $t_file_name = $p_file['name'];
    $t_tmp_file = $p_file['tmp_name'];
    if (!file_type_check($t_file_name)) {
        trigger_error(ERROR_FILE_NOT_ALLOWED, ERROR);
    }
    if (!file_is_name_unique($t_file_name, $p_bug_id)) {
        trigger_error(ERROR_FILE_DUPLICATE, ERROR);
    }
    $t_file_size = filesize($t_tmp_file);
    if (0 == $t_file_size) {
        trigger_error(ERROR_FILE_NO_UPLOAD_FAILURE, ERROR);
    }
    $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
    if ($t_file_size > $t_max_file_size) {
        trigger_error(ERROR_FILE_TOO_BIG, ERROR);
    }
    if ('bug' == $p_table) {
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        $t_id = (int) $p_bug_id;
        $t_bug_id = bug_format_id($p_bug_id);
    } else {
        $t_project_id = helper_get_current_project();
        $t_id = $t_project_id;
        $t_bug_id = 0;
    }
    if ($p_user_id === null) {
        $p_user_id = auth_get_current_user_id();
    }
    if ($p_date_added <= 0) {
        $p_date_added = db_now();
    }
    if ($t_project_id == ALL_PROJECTS) {
        $t_file_path = config_get('absolute_path_default_upload_folder');
    } else {
        $t_file_path = project_get_field($t_project_id, 'file_path');
        if (is_blank($t_file_path)) {
            $t_file_path = config_get('absolute_path_default_upload_folder');
        }
    }
    $t_unique_name = file_generate_unique_name($t_file_path);
    $t_method = config_get('file_upload_method');
    switch ($t_method) {
        case DISK:
            file_ensure_valid_upload_path($t_file_path);
            $t_disk_file_name = $t_file_path . $t_unique_name;
            if (!file_exists($t_disk_file_name)) {
                if (!move_uploaded_file($t_tmp_file, $t_disk_file_name)) {
                    trigger_error(ERROR_FILE_MOVE_FAILED, ERROR);
                }
                chmod($t_disk_file_name, config_get('attachments_file_permissions'));
                $c_content = '';
            } else {
                trigger_error(ERROR_FILE_DUPLICATE, ERROR);
            }
            break;
        case DATABASE:
            $c_content = db_prepare_binary_string(fread(fopen($t_tmp_file, 'rb'), $t_file_size));
            $t_file_path = '';
            break;
        default:
            trigger_error(ERROR_GENERIC, ERROR);
    }
    $t_file_table = db_get_table($p_table . '_file');
    $t_id_col = $p_table . '_id';
    $t_query = 'INSERT INTO ' . $t_file_table . ' ( ' . $t_id_col . ', title, description, diskfile, filename, folder,
		filesize, file_type, date_added, user_id )
	VALUES
		( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
    db_query($t_query, array($t_id, $p_title, $p_desc, $t_unique_name, $t_file_name, $t_file_path, $t_file_size, $p_file['type'], $p_date_added, (int) $p_user_id));
    $t_attachment_id = db_insert_id($t_file_table);
    if (db_is_oracle()) {
        db_update_blob($t_file_table, 'content', $c_content, 'diskfile=\'$t_unique_name\'');
    } else {
        $t_query = 'UPDATE ' . $t_file_table . ' SET content=' . db_param() . ' WHERE id = ' . db_param();
        db_query($t_query, array($c_content, $t_attachment_id));
    }
    if ('bug' == $p_table) {
        # update the last_updated date
        if (!$p_skip_bug_update) {
            bug_update_date($p_bug_id);
        }
        # log file added to bug history
        history_log_event_special($p_bug_id, FILE_ADDED, $t_file_name);
    }
}
Ejemplo n.º 18
0
    $t_custom_filter['sort'] = $c_sort_field;
} else {
    # null will be returned if the user doesn't have access right to access the filter.
    $t_custom_filter = filter_db_get_filter($f_filter_id, $t_user_id);
    if (null === $t_custom_filter) {
        access_denied();
    }
    $t_custom_filter = filter_deserialize($t_custom_filter);
}
$t_issues = filter_get_bug_rows($t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky);
$t_issues_count = count($t_issues);
# Loop through results
for ($i = 0; $i < $t_issues_count; $i++) {
    $t_bug = $t_issues[$i];
    $about = $link = $t_path . "view.php?id=" . $t_bug->id;
    $title = bug_format_id($t_bug->id) . ': ' . $t_bug->summary;
    if ($t_bug->view_state == VS_PRIVATE) {
        $title .= ' [' . lang_get('private') . ']';
    }
    $description = string_rss_links($t_bug->description);
    # subject is category.
    $subject = category_full_name($t_bug->category_id, false);
    # optional DC value
    $date = $t_bug->last_updated;
    # author of item
    $author = '';
    if (access_has_global_level(config_get('show_user_email_threshold'))) {
        $t_author_name = user_get_name($t_bug->reporter_id);
        $t_author_email = user_get_field($t_bug->reporter_id, 'email');
        if (!is_blank($t_author_email)) {
            if (!is_blank($t_author_name)) {
Ejemplo n.º 19
0
/**
 * 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);
}
Ejemplo n.º 20
0
/**
 * return the duplicate bug id
 * @param object $p_bug the bug
 * @return string formatted bug id
 * @access public
 */
function csv_format_duplicate_id($p_bug)
{
    return bug_format_id($p_bug->duplicate_id);
}
Ejemplo n.º 21
0
$t_show_eta = in_array('eta', $t_fields);
$t_show_versions = version_should_show_product_version($t_bug->project_id);
$t_show_product_version = $t_show_versions && in_array('product_version', $t_fields);
$t_show_product_build = $t_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build');
$t_show_fixed_in_version = $t_show_versions && in_array('fixed_in_version', $t_fields);
$t_show_target_version = $t_show_versions && in_array('target_version', $t_fields) && access_has_bug_level(config_get('roadmap_view_threshold'), $f_bug_id);
$t_show_summary = in_array('summary', $t_fields);
$t_show_description = in_array('description', $t_fields);
$t_show_steps_to_reproduce = in_array('steps_to_reproduce', $t_fields);
$t_show_additional_information = in_array('additional_info', $t_fields);
$t_show_tags = in_array('tags', $t_fields);
$t_show_attachments = in_array('attachments', $t_fields);
$t_show_history = access_has_bug_level(config_get('view_history_threshold'), $f_bug_id);
$t_window_title = string_display_line(config_get('window_title'));
$t_project_name = $t_show_project ? string_display_line(project_get_name($t_bug->project_id)) : '';
$t_formatted_bug_id = $t_show_id ? bug_format_id($f_bug_id) : '';
$t_category_name = $t_show_category ? string_display_line(category_full_name($t_bug->category_id)) : '';
$t_severity = string_display_line(get_enum_element('severity', $t_bug->severity));
$t_reproducibility = string_display_line(get_enum_element('reproducibility', $t_bug->reproducibility));
$t_date_submitted = $t_show_date_submitted ? string_display_line(date(config_get('normal_date_format'), $t_bug->date_submitted)) : '';
$t_last_updated = $t_show_last_updated ? string_display_line(date(config_get('normal_date_format'), $t_bug->last_updated)) : '';
$t_platform = string_display_line($t_bug->platform);
$t_os = string_display_line($t_bug->os);
$t_os_version = string_display_line($t_bug->os_build);
$t_is = string_display_line($t_bug->os);
$t_status = string_display_line(get_enum_element('status', $t_bug->status));
$t_priority = string_display_line(get_enum_element('priority', $t_bug->priority));
$t_resolution = string_display_line(get_enum_element('resolution', $t_bug->resolution));
$t_product_build = string_display_line($t_bug->build);
$t_projection = string_display_line(get_enum_element('projection', $t_bug->projection));
$t_eta = string_display_line(get_enum_element('eta', $t_bug->eta));
Ejemplo n.º 22
0
/**
 * formats the subject correctly
 * we include the project name, bug id, and summary.
 *
 * @param int $p_bug_id
 * @return null
 */
function email_build_subject($p_bug_id)
{
    # grab the project name
    $p_project_name = project_get_field(bug_get_field($p_bug_id, 'project_id'), 'name');
    # grab the subject (summary)
    $p_subject = bug_get_field($p_bug_id, 'summary');
    # padd the bug id with zeros
    $p_bug_id = bug_format_id($p_bug_id);
    return '[' . $p_project_name . ' ' . $p_bug_id . ']: ' . $p_subject;
}
Ejemplo n.º 23
0
		<?php 
echo lang_get('last_update');
?>
	</td>
</tr>


<tr <?php 
echo helper_alternate_class();
?>
>

	<!-- Bug ID -->
	<td>
		<?php 
echo bug_format_id($f_bug_id);
?>
	</td>

	<!-- Category -->
	<td>
		<?php 
$t_project_name = string_display(project_get_field($t_bug->project_id, 'name'));
echo "[{$t_project_name}] {$t_bug->category}";
?>
	</td>

	<!-- Severity -->
	<td>
		<?php 
echo get_enum_element('severity', $t_bug->severity);
Ejemplo n.º 24
0
/**
 * Gets the formatted bug id value.
 * @param object $p_bug the bug
 * @returns The bug id prefixed with 0s.
 */
function excel_format_id($p_bug)
{
    return excel_prepare_string(bug_format_id($p_bug->id));
}
Ejemplo n.º 25
0
function mci_file_add($p_id, $p_name, $p_content, $p_file_type, $p_table, $p_title = '', $p_desc = '', $p_user_id = null)
{
    if (!file_type_check($p_name)) {
        return new soap_fault('Client', '', 'File type not allowed.');
    }
    if (!file_is_name_unique($p_name, $p_id)) {
        return new soap_fault('Client', '', 'Duplicate filename.');
    }
    $t_file_size = strlen($p_content);
    $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
    if ($t_file_size > $t_max_file_size) {
        return new soap_fault('Client', '', 'File is too big.');
    }
    if ('bug' == $p_table) {
        $t_project_id = bug_get_field($p_id, 'project_id');
        $t_issue_id = bug_format_id($p_id);
    } else {
        $t_project_id = $p_id;
        $t_issue_id = 0;
    }
    # prepare variables for insertion
    $c_issue_id = db_prepare_int($t_issue_id);
    $c_project_id = db_prepare_int($t_project_id);
    $c_file_type = db_prepare_string($p_file_type);
    $c_title = db_prepare_string($p_title);
    $c_desc = db_prepare_string($p_desc);
    if ($p_user_id === null) {
        $c_user_id = auth_get_current_user_id();
    } else {
        $c_user_id = (int) $p_user_id;
    }
    if ($t_project_id == ALL_PROJECTS) {
        $t_file_path = config_get('absolute_path_default_upload_folder');
    } else {
        $t_file_path = project_get_field($t_project_id, 'file_path');
        if ($t_file_path == '') {
            $t_file_path = config_get('absolute_path_default_upload_folder');
        }
    }
    $c_file_path = db_prepare_string($t_file_path);
    $c_new_file_name = db_prepare_string($p_name);
    $t_file_hash = $t_issue_id;
    $t_disk_file_name = $t_file_path . file_generate_unique_name($t_file_hash . '-' . $p_name, $t_file_path);
    $c_disk_file_name = db_prepare_string($t_disk_file_name);
    $t_file_size = strlen($p_content);
    $c_file_size = db_prepare_int($t_file_size);
    $t_method = config_get('file_upload_method');
    switch ($t_method) {
        case FTP:
        case DISK:
            if (!file_exists($t_file_path) || !is_dir($t_file_path) || !is_writable($t_file_path) || !is_readable($t_file_path)) {
                return new soap_fault('Server', '', "Upload folder '{$t_file_path}' doesn't exist.");
            }
            file_ensure_valid_upload_path($t_file_path);
            if (!file_exists($t_disk_file_name)) {
                mci_file_write_local($t_disk_file_name, $p_content);
                if (FTP == $t_method) {
                    $conn_id = file_ftp_connect();
                    file_ftp_put($conn_id, $t_disk_file_name, $t_disk_file_name);
                    file_ftp_disconnect($conn_id);
                    file_delete_local($t_disk_file_name);
                } else {
                    chmod($t_disk_file_name, config_get('attachments_file_permissions'));
                }
                $c_content = "''";
            }
            break;
        case DATABASE:
            $c_content = db_prepare_binary_string($p_content);
            break;
    }
    $t_file_table = db_get_table($p_table . '_file');
    $c_id = 'bug' == $p_table ? $c_issue_id : $c_project_id;
    $query = "INSERT INTO {$t_file_table}\n\t\t\t(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id)\n\t\tVALUES\n\t\t\t({$c_id}, '{$c_title}', '{$c_desc}', '{$c_disk_file_name}', '{$c_new_file_name}', '{$c_file_path}', {$c_file_size}, '{$c_file_type}', '" . db_now() . "', {$c_content}, {$c_user_id})";
    db_query($query);
    # get attachment id
    $t_attachment_id = db_insert_id($t_file_table);
    if ('bug' == $p_table) {
        # updated the last_updated date
        $result = bug_update_date($c_issue_id);
        # log new bug
        history_log_event_special($c_issue_id, FILE_ADDED, $c_new_file_name);
    }
    return $t_attachment_id;
}
Ejemplo n.º 26
0
/**
 * Send bug info to given user
 * return true on success
 * @param array $p_visible_bug_data
 * @param string $p_message_id
 * @param int $p_project_id
 * @param int $p_user_id
 * @param array $p_header_optional_params
 * @return bool
 */
function email_bug_info_to_one_user($p_visible_bug_data, $p_message_id, $p_project_id, $p_user_id, $p_header_optional_params = null)
{
    $t_user_email = user_get_email($p_user_id);
    # check whether email should be sent
    # @@@ can be email field empty? if yes - then it should be handled here
    if (ON !== config_get('enable_email_notification') || is_blank($t_user_email)) {
        return true;
    }
    # build subject
    $t_subject = '[' . $p_visible_bug_data['email_project'] . ' ' . bug_format_id($p_visible_bug_data['email_bug']) . ']: ' . $p_visible_bug_data['email_summary'];
    # build message
    $t_message = lang_get_defaulted($p_message_id, null);
    if (is_array($p_header_optional_params)) {
        $t_message = vsprintf($t_message, $p_header_optional_params);
    }
    if ($t_message !== null && !is_blank($t_message)) {
        $t_message .= " \n";
    }
    $t_message .= email_format_bug_message($p_visible_bug_data);
    # build headers
    $t_bug_id = $p_visible_bug_data['email_bug'];
    $t_message_md5 = md5($t_bug_id . $p_visible_bug_data['email_date_submitted']);
    $t_mail_headers = array('keywords' => $p_visible_bug_data['set_category']);
    if ($p_message_id == 'email_notification_title_for_action_bug_submitted') {
        $t_mail_headers['Message-ID'] = $t_message_md5;
    } else {
        $t_mail_headers['In-Reply-To'] = $t_message_md5;
    }
    # send mail
    $t_ok = email_store($t_user_email, $t_subject, $t_message, $t_mail_headers);
    return $t_ok;
}
Ejemplo n.º 27
0
/**
 * return formatted string with all the details on the requested relationship
 * @param integer             $p_bug_id       A bug identifier.
 * @param BugRelationshipData $p_relationship A bug relationship object.
 * @param boolean             $p_html         Whether to return html or text output.
 * @param boolean             $p_html_preview Whether to include style/hyperlinks - if preview is false, we prettify the output.
 * @param boolean             $p_show_project Show Project details.
 * @return string
 */
function relationship_get_details($p_bug_id, BugRelationshipData $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    if ($p_bug_id == $p_relationship->src_bug_id) {
        # root bug is in the source side, related bug in the destination side
        $t_related_bug_id = $p_relationship->dest_bug_id;
        $t_related_project_name = project_get_name($p_relationship->dest_project_id);
        $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
    } else {
        # root bug is in the dest side, related bug in the source side
        $t_related_bug_id = $p_relationship->src_bug_id;
        $t_related_project_name = project_get_name($p_relationship->src_project_id);
        $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
    }
    # related bug not existing...
    if (!bug_exists($t_related_bug_id)) {
        return '';
    }
    # user can access to the related bug at least as a viewer
    if (!access_has_bug_level(VIEWER, $t_related_bug_id)) {
        return '';
    }
    if ($p_html_preview == false) {
        $t_td = '<td>';
    } else {
        $t_td = '<td class="print">';
    }
    # get the information from the related bug and prepare the link
    $t_bug = bug_get($t_related_bug_id, false);
    $t_status_string = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    $t_resolution_string = get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id);
    $t_relationship_info_html = $t_td . string_no_break($t_relationship_descr) . '&#160;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . string_display_line(bug_format_id($t_related_bug_id)) . '</a></td>';
        $t_relationship_info_html .= '<td><span class="issue-status" title="' . string_attribute($t_resolution_string) . '">' . string_display_line($t_status_string) . '</span></td>';
    } else {
        $t_relationship_info_html .= $t_td . string_display_line(bug_format_id($t_related_bug_id)) . '</td>';
        $t_relationship_info_html .= $t_td . string_display_line($t_status_string) . '&#160;</td>';
    }
    $t_relationship_info_text = utf8_str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= utf8_str_pad(bug_format_id($t_related_bug_id), 8);
    # get the handler name of the related bug
    $t_relationship_info_html .= $t_td;
    if ($t_bug->handler_id > 0) {
        $t_relationship_info_html .= string_no_break(prepare_user_name($t_bug->handler_id));
    }
    $t_relationship_info_html .= '&#160;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . string_display_line($t_related_project_name) . '&#160;</td>';
    }
    # add summary
    if ($p_html == true) {
        $t_relationship_info_html .= $t_td . string_display_line_links($t_bug->summary);
        if (VS_PRIVATE == $t_bug->view_state) {
            $t_relationship_info_html .= sprintf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
        }
    } else {
        if (utf8_strlen($t_bug->summary) <= $t_summary_wrap_at) {
            $t_relationship_info_text .= string_email_links($t_bug->summary);
        } else {
            $t_relationship_info_text .= utf8_substr(string_email_links($t_bug->summary), 0, $t_summary_wrap_at - 3) . '...';
        }
    }
    # add delete link if bug not read only and user has access level
    if (!bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && $p_html_preview == false) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            $t_relationship_info_html .= ' [<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id . '&amp;rel_id=' . $p_relationship->id . htmlspecialchars(form_security_param('bug_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&#160;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        # choose color based on status
        $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
        $t_relationship_info_html = '<tr class="' . $t_status_label . '">' . $t_relationship_info_html . '</tr>' . "\n";
    } else {
        $t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
    }
    if ($p_html == true) {
        return $t_relationship_info_html;
    } else {
        return $t_relationship_info_text;
    }
}
Ejemplo n.º 28
0
/**
 * allows bug deletion :
 * delete the bug, bugtext, bugnote, and bugtexts selected
 * @param array p_bug_id integer representing bug id
 * @return bool (always true)
 * @access public
 */
function bug_delete($p_bug_id)
{
    $c_bug_id = (int) $p_bug_id;
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_bug_text_table = db_get_table('mantis_bug_text_table');
    # call pre-deletion custom function
    helper_call_custom_function('issue_delete_validate', array($p_bug_id));
    # log deletion of bug
    history_log_event_special($p_bug_id, BUG_DELETED, bug_format_id($p_bug_id));
    email_bug_deleted($p_bug_id);
    # call post-deletion custom function.  We call this here to allow the custom function to access the details of the bug before
    # they are deleted from the database given it's id.  The other option would be to move this to the end of the function and
    # provide it with bug data rather than an id, but this will break backward compatibility.
    helper_call_custom_function('issue_delete_notify', array($p_bug_id));
    # Unmonitor bug for all users
    bug_unmonitor($p_bug_id, null);
    # Delete custom fields
    custom_field_delete_all_values($p_bug_id);
    # Delete bugnotes
    bugnote_delete_all($p_bug_id);
    # Delete all sponsorships
    sponsorship_delete_all($p_bug_id);
    # MASC RELATIONSHIP
    # we delete relationships even if the feature is currently off.
    relationship_delete_all($p_bug_id);
    # MASC RELATIONSHIP
    # Delete files
    file_delete_attachments($p_bug_id);
    # Detach tags
    tag_bug_detach_all($p_bug_id, false);
    # Delete the bug history
    history_delete($p_bug_id);
    # Delete bug info revisions
    bug_revision_delete($p_bug_id);
    # Delete the bugnote text
    $t_bug_text_id = bug_get_field($p_bug_id, 'bug_text_id');
    $query = "DELETE FROM {$t_bug_text_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($t_bug_text_id));
    # Delete the bug entry
    $query = "DELETE FROM {$t_bug_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($c_bug_id));
    bug_clear_cache($p_bug_id);
    bug_text_clear_cache($p_bug_id);
    # db_query errors on failure so:
    return true;
}
Ejemplo n.º 29
0
}
# Relationship (in case of cloned bug creation...)
if ($f_master_bug_id > 0) {
    ?>
	<tr>
		<th class="category">
			<?php 
    echo lang_get('relationship_with_parent');
    ?>
		</th>
		<td>
			<?php 
    relationship_list_box(config_get('default_bug_relationship_clone'), 'rel_type', false, true);
    ?>
			<?php 
    echo '<strong>' . lang_get('bug') . ' ' . bug_format_id($f_master_bug_id) . '</strong>';
    ?>
		</td>
	</tr>

	<tr>
		<td class="category">
			<?php 
    echo lang_get('copy_from_parent');
    ?>
		</td>
		<td>
			<label><input <?php 
    echo helper_get_tab_index();
    ?>
 type="checkbox" id="copy_notes_from_parent" name="copy_notes_from_parent" <?php 
Ejemplo n.º 30
0
$tpl_form_title = lang_get('bug_view_title');
$tpl_wiki_link = config_get_global('wiki_enable') == ON ? 'wiki.php?id=' . $f_bug_id : '';
if (access_has_bug_level(config_get('view_history_threshold'), $f_bug_id)) {
    $tpl_history_link = "view.php?id={$f_bug_id}&history=1#history";
} else {
    $tpl_history_link = '';
}
$tpl_show_reminder_link = !current_user_is_anonymous() && !bug_is_readonly($f_bug_id) && access_has_bug_level(config_get('bug_reminder_threshold'), $f_bug_id);
$tpl_bug_reminder_link = 'bug_reminder_page.php?bug_id=' . $f_bug_id;
$tpl_print_link = 'print_bug_page.php?bug_id=' . $f_bug_id;
$tpl_top_buttons_enabled = !$tpl_force_readonly && ($t_action_button_position == POSITION_TOP || $t_action_button_position == POSITION_BOTH);
$tpl_bottom_buttons_enabled = !$tpl_force_readonly && ($t_action_button_position == POSITION_BOTTOM || $t_action_button_position == POSITION_BOTH);
$tpl_show_project = in_array('project', $t_fields);
$tpl_project_name = $tpl_show_project ? string_display_line(project_get_name($tpl_bug->project_id)) : '';
$tpl_show_id = in_array('id', $t_fields);
$tpl_formatted_bug_id = $tpl_show_id ? string_display_line(bug_format_id($f_bug_id)) : '';
$tpl_show_date_submitted = in_array('date_submitted', $t_fields);
$tpl_date_submitted = $tpl_show_date_submitted ? date(config_get('normal_date_format'), $tpl_bug->date_submitted) : '';
$tpl_show_last_updated = in_array('last_updated', $t_fields);
$tpl_last_updated = $tpl_show_last_updated ? date(config_get('normal_date_format'), $tpl_bug->last_updated) : '';
$tpl_show_tags = in_array('tags', $t_fields) && access_has_global_level(config_get('tag_view_threshold'));
$tpl_bug_overdue = bug_is_overdue($f_bug_id);
$tpl_show_view_state = in_array('view_state', $t_fields);
$tpl_bug_view_state_enum = $tpl_show_view_state ? string_display_line(get_enum_element('view_state', $tpl_bug->view_state)) : '';
$tpl_show_due_date = in_array('due_date', $t_fields) && access_has_bug_level(config_get('due_date_view_threshold'), $f_bug_id);
if ($tpl_show_due_date) {
    if (!date_is_null($tpl_bug->due_date)) {
        $tpl_bug_due_date = date(config_get('normal_date_format'), $tpl_bug->due_date);
    } else {
        $tpl_bug_due_date = '';
    }