/** * print ALL the RELATIONSHIPS OF A SPECIFIC BUG in text format (used by email_api.php * @param integer $p_bug_id A bug identifier. * @return string */ function relationship_get_summary_text($p_bug_id) { $t_summary = ''; $t_show_project = false; $t_relationship_all = relationship_get_all($p_bug_id, $t_show_project); $t_relationship_all_count = count($t_relationship_all); # prepare the relationships table for ($i = 0; $i < $t_relationship_all_count; $i++) { $t_summary .= relationship_get_details($p_bug_id, $t_relationship_all[$i], false); } return $t_summary; }
function relationship_get_summary_text($p_bug_id) { $t_email_separator1 = config_get('email_separator1'); $t_email_separator2 = config_get('email_separator2'); $t_summary = ""; $t_show_project = false; $t_relationship_all = relationship_get_all($p_bug_id, $t_show_project); $t_relationship_all_count = count($t_relationship_all); #prepare the relationships table for ($i = 0; $i < $t_relationship_all_count; $i++) { $t_summary .= relationship_get_details($p_bug_id, $t_relationship_all[$i], false); } if ($t_summary != "") { $t_summary = $t_email_separator1 . "\n" . str_pad(lang_get('bug_relationships'), 20) . str_pad(lang_get('id'), 8) . lang_get('summary') . "\n" . $t_email_separator2 . "\n" . $t_summary; } return $t_summary; }
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 .= '&rel_id=' . $p_relationship->id; $t_text .= '&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; } }
/** * checks relationships for a bug and assign relevant symbols * * @author Rainer Dierck * @param $bugId */ public static function GetBugSmybols($bugId, $p_newline = false) { $t_text = ''; $bugStatus = bug_get_field($bugId, 'status'); $allRelationships = relationship_get_all($bugId, $t_show_project); $allRelationshipsCount = count($allRelationships); $stopFlag = false; $forbiddenFlag = false; $warningFlag = false; $bugEta = bug_get_field($bugId, 'eta'); $useEta = $bugEta != ETA_NONE && config_get('enable_eta'); $stopAltText = ""; $forbiddenAltText = ""; $warningAltText = ""; $href = string_get_bug_view_url($bugId) . '#relationships_open'; for ($index = 0; $index < $allRelationshipsCount; $index++) { $relationShip = $allRelationships[$index]; if ($bugId == $relationShip->src_bug_id) { # root bug is in the src side, related bug in the dest side $destinationBugId = $relationShip->dest_bug_id; $relationshipDescription = relationship_get_description_src_side($relationShip->type); } else { # root bug is in the dest side, related bug in the src side $destinationBugId = $relationShip->src_bug_id; $relationshipDescription = relationship_get_description_dest_side($relationShip->type); } # get the information from the related bug and prepare the link $destinationBugStatus = bug_get_field($destinationBugId, 'status'); if ($bugStatus < CLOSED && $destinationBugStatus < CLOSED && $relationShip->type != BUG_REL_NONE) { if ($relationShip->type == BUG_DEPENDANT) { if ($bugId == $relationShip->src_bug_id) { // Stop or Forbidden if ($bugStatus == $destinationBugStatus) { // Stop if ($stopAltText != "") { $stopAltText .= ", "; } if (!$stopFlag) { $stopAltText .= trim(utf8_str_pad($relationshipDescription, 20)) . ' '; } $stopAltText .= string_display_line(bug_format_id($destinationBugId)); $stopFlag = true; } if ($bugStatus > $destinationBugStatus) { // Forbidden if ($forbiddenAltText != "") { $forbiddenAltText .= ", "; } if (!$forbiddenFlag) { $forbiddenAltText .= trim(utf8_str_pad($relationshipDescription, 20)) . ' '; } $forbiddenAltText .= string_display_line(bug_format_id($destinationBugId)); $forbiddenFlag = true; } } else { // Warning if ($bugStatus < $destinationBugStatus) { // Warning if ($warningAltText != "") { $warningAltText .= ", "; } if (!$warningFlag) { $warningAltText .= trim(utf8_str_pad($relationshipDescription, 20)) . ' '; } $warningAltText .= string_display_line(bug_format_id($destinationBugId)); $warningFlag = true; } } } } } //if ( $useEta ) //{ // RELATIONSHIPS_UTILS_PLUGIN_URL // $t_text .= '<img border="0" width="16" height="16" src="' . RELATIONSHIPS_UTILS_PLUGIN_URL . 'clock.png' . '" alt="clock" />'; //} if ($forbiddenFlag) { if ($p_newline && !is_blank($t_text)) { $t_text .= '<br/>' . "\n"; } $t_text .= '<a href="' . $href . '"><img border="0" width="16" height="16" src="' . RELATIONSHIPS_UTILS_PLUGIN_URL . 'sign_forbidden.png" alt="' . $forbiddenAltText . '" title="' . $forbiddenAltText . '" /></a>'; } if ($stopFlag) { if ($p_newline && !is_blank($t_text)) { $t_text .= '<br/>' . "\n"; } $t_text .= '<a href="' . $href . '"><img border="0" width="16" height="16" src="' . RELATIONSHIPS_UTILS_PLUGIN_URL . 'sign_stop.png" alt="' . $stopAltText . '" title="' . $stopAltText . '" /></a>'; } if ($warningFlag) { if ($p_newline && !is_blank($t_text)) { $t_text .= '<br/>' . "\n"; } $t_text .= '<a href="' . $href . '"><img border="0" width="16" height="16" src="' . RELATIONSHIPS_UTILS_PLUGIN_URL . 'sign_warning.png" alt="' . $warningAltText . '" title="' . $warningAltText . '" /></a>'; } return $t_text; }