Exemple #1
0
/**
 * Print column content for column sponsorship total
 *
 * @param BugData $p_bug bug object
 * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php
 * @return null
 * @access public
 */
function print_column_sponsorship_total($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    echo "\t<td class=\"right column-sponsorship\">";
    if ($p_bug->sponsorship_total > 0) {
        $t_sponsorship_amount = sponsorship_format_amount($p_bug->sponsorship_total);
        echo string_no_break($t_sponsorship_amount);
    }
    echo "</td>\n";
}
function print_column_sponsorship_total($p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    $t_enable_sponsorship = config_get('enable_sponsorship');
    if ($t_enable_sponsorship == ON) {
        echo "\t<td class=\"right\">";
        if ($p_row['sponsorship_total'] > 0) {
            $t_sponsorship_amount = sponsorship_format_amount($p_row['sponsorship_total']);
            echo string_no_break($t_sponsorship_amount);
        }
        echo "</td>\n";
    }
}
/**
 * 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;
    }
}
/**
 * access row
 * @return void
 */
function access_row()
{
    global $g_access, $g_can_change_flags;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    $t_global_set = config_get('set_status_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_set = config_get('set_status_threshold');
    $t_submit_status = config_get('bug_submit_status');
    # Print the table rows
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo "\t\t" . '<tr><td class="width30">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>' . "\n";
        if ($t_status == $t_submit_status) {
            # 'NEW' status
            $t_level_project = $t_project_new;
            $t_can_change = $g_access >= config_get_access('report_bug_threshold');
            $t_color = set_color_override($t_file_new, $t_global_new, $t_project_new);
            set_overrides('report_bug_threshold', $t_can_change, $t_color);
        } else {
            # Other statuses
            # File level: fallback if set_status_threshold is not defined
            if (isset($t_file_set[$t_status])) {
                $t_level_file = $t_file_set[$t_status];
            } else {
                $t_level_file = config_get_global('update_bug_status_threshold');
            }
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : $t_level_file;
            $t_level_project = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : $t_level_global;
            $t_can_change = $g_access >= config_get_access('set_status_threshold');
            $t_color = set_color_override($t_level_file, $t_level_global, $t_level_project);
            set_overrides('set_status_threshold', $t_can_change, $t_color);
        }
        if ($t_can_change) {
            echo '<td class="center ' . $t_color . '"><select name="access_change_' . $t_status . '">' . "\n";
            print_enum_string_option_list('access_levels', $t_level_project);
            echo '</select> </td>' . "\n";
            $g_can_change_flags = true;
        } else {
            echo '<td class="center ' . $t_color . '">' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level_project) . '</td>' . "\n";
        }
        echo '</tr>' . "\n";
    }
}
require_api('authentication_api.php');
require_api('compress_api.php');
require_api('config_api.php');
require_api('graphviz_api.php');
require_api('workflow_api.php');
auth_ensure_user_authenticated();
if (!config_get('relationship_graph_enable')) {
    access_denied();
}
compress_enable();
$t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
$t_graph_fontname = config_get('relationship_graph_fontname');
$t_graph_fontsize = config_get('relationship_graph_fontsize');
$t_graph_fontpath = get_font_path();
$t_dot_tool = config_get('dot_tool');
$t_graph_attributes = array();
if (!empty($t_graph_fontpath)) {
    $t_graph_attributes['fontpath'] = $t_graph_fontpath;
}
$t_graph = new Graph('workflow', $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' => '#0000C0', 'dir' => 'forward'));
foreach ($t_status_arr as $t_from_status => $t_from_label) {
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    foreach ($t_enum_status as $t_to_status_id => $t_to_status_label) {
        if (workflow_transition_edge_exists($t_from_status, $t_to_status_id)) {
            $t_graph->add_edge(string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_from_status)), string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_to_status_id)), array());
        }
    }
}
$t_graph->output('png', true);
function access_row()
{
    global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
    $t_enum_status = get_enum_to_array(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, null, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
        }
    }
    $t_global_set = config_get('set_status_threshold', null, null, ALL_PROJECTS);
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS);
        }
    }
    $t_project_set = config_get('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold');
        }
    }
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break(get_enum_to_string(lang_get('status_enum_string'), $t_status)) . '</td>';
        if (NEW_ == $t_status) {
            $t_level = $t_project_new;
            $t_can_change = $t_access >= config_get_access('report_bug_threshold');
            $t_colour = '';
            if ($t_global_new != $t_file_new) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
            if ($t_project_new != $t_global_new) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
        } else {
            $t_level = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : false;
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : false;
            $t_level_file = isset($t_file_set[$t_status]) ? $t_file_set[$t_status] : false;
            $t_can_change = $t_access >= config_get_access('set_status_threshold');
            $t_colour = '';
            if ($t_level_global != $t_level_file) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
            if ($t_level != $t_level_global) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
        }
        if ($t_can_change) {
            echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
            print_enum_string_option_list('access_levels', $t_level);
            echo '</select> </td>';
            $t_can_change_flags = true;
        } else {
            echo '<td class="center"' . $t_colour . '>' . get_enum_to_string(config_get('access_levels_enum_string'), $t_level) . '</td>';
        }
        echo '</tr>' . "\n";
    }
}
if( !empty( $t_graph_fontpath ) ) {
	$t_graph_attributes['fontpath'] = $t_graph_fontpath;
}

$t_graph = new Graph( 'workflow', $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' => '#0000C0',
                                         'dir'   => 'forward' ) );

foreach ( $t_status_arr as $t_from_status => $t_from_label) {
	$t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
	foreach ( $t_enum_status as $t_to_status_id => $t_to_status_label ) {
		if ( workflow_transition_edge_exists( $t_from_status, $t_to_status_id ) ) {
			$t_graph->add_edge( string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_from_status ) ),
			                    string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_to_status_id ) ),
			                    array() );
		}
	}
}

$t_graph->output( 'png', true );
function relationship_get_details($p_bug_id, $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    $p_user_id = auth_get_current_user_id();
    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_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 src 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_prepare_display(bug_get($t_related_bug_id, true));
    $t_status = string_attribute(get_enum_element('status', $t_bug->status));
    $t_resolution = string_attribute(get_enum_element('resolution', $t_bug->resolution));
    $t_relationship_info_html = $t_td . string_no_break($t_relationship_descr) . '&nbsp;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . bug_format_id($t_related_bug_id) . '</a></td>';
        $t_relationship_info_html .= '<td><span class="issue-status" title="' . $t_resolution . '">' . $t_status . '</span></td>';
    } else {
        $t_relationship_info_html .= $t_td . bug_format_id($t_related_bug_id) . '</td>';
        $t_relationship_info_html .= $t_td . $t_status . '&nbsp;</td>';
    }
    $t_relationship_info_text = str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= 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 .= '&nbsp;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . $t_related_project_name . '&nbsp;</td>';
    }
    # add summary
    $t_relationship_info_html .= $t_td . $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'));
    }
    if (strlen($t_bug->summary) <= $t_summary_wrap_at) {
        $t_relationship_info_text .= $t_bug->summary;
    } else {
        $t_relationship_info_text .= substr($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}&rel_id={$p_relationship->id}\">" . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&nbsp;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        $t_relationship_info_html = '<tr bgcolor="' . get_status_color($t_bug->status) . '">' . $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;
    }
}