00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: show.php 5441 2006-02-19 13:53:40Z toddy $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00009 #
00010 # Copyright 2003-2006 (c) Mathieu Roy <yeupou--gnu.org>
00011 #
00012 #
00013 # The Savane project is free software; you can redistribute it and/or
00014 # modify it under the terms of the GNU General Public License
00015 # as published by the Free Software Foundation; either version 2
00016 # of the License, or (at your option) any later version.
00017 #
00018 # The Savane project is distributed in the hope that it will be useful,
00019 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021 # GNU General Public License for more details.
00022 #
00023 # You should have received a copy of the GNU General Public License
00024 # along with the Savane project; if not, write to the Free Software
00025 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00026
00027 function show_item_list ($result_arr,
00028 $offset,
00029 $total_rows,
00030 $field_arr, #4
00031 $title_arr,
00032 $width_arr,
00033 $url,
00034 $nolink=false)
00035 {
00036 global $group_id,$PHP_SELF,$chunksz,$morder;
00037
00038 # Build the list of links to use for column headings
00039 # Used to trigger sort on that column
00040 if ($url)
00041 {
00042 $links_arr = array();
00043 while (list(,$field) = each($field_arr))
00044 {
00045 $links_arr[] = $url.'&order='.$field.'#results';
00046 }
00047 }
00048
00049
00050
00051
00052
00053 $nav_bar ='<h3 class="nextprev">';
00054
00055 # If all bugs on screen so no prev/begin pointer at all
00056 if ($total_rows > $chunksz)
00057 {
00058 if ($offset > 0)
00059 {
00060 $nav_bar .=
00061 '<span class="xsmall"><a href="'.$url.'&offset=0#results"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/first.png" border="0" alt="'._("Begin").'" />'._("Begin").'</a>'.
00062 ' '.
00063 '<a href="'.$url.'&offset='.($offset-$chunksz).
00064 '#results"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/previous.png" border="0" alt="'._("Previous Results").'" />'._("Previous Results").'</a></span>';
00065 }
00066 else
00067 {
00068 $nav_bar .=
00069 '<span class="xsmall"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/firstgrey.png" border="0" alt="'._("Begin").'" /><em>'._("Begin").'</em>'.
00070 ' '.
00071 '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/previousgrey.png" border="0" alt="'._("Previous Results").'" /><em>'._("Previous Results").'</em></span>';
00072 }
00073 }
00074
00075
00076 $offset_last = min($offset+$chunksz-1, $total_rows-1);
00077
00078 #fb("$offset_last offset_last");
00079
00080 $nav_bar .= " ".sprintf(ngettext("%d matching item", "%d matching items", $total_rows), $total_rows);
00081 $nav_bar .= " - ".sprintf(_("Items %s to %s"), ($offset+1), ($offset_last+1))." ";
00082
00083
00084 # If all items are on screen, no next/end pointer at all
00085 # FIXME: it should not count private items
00086 if ($total_rows > $chunksz)
00087 {
00088 if ( ($offset+$chunksz) < $total_rows )
00089 {
00090
00091 $offset_end = ($total_rows - ($total_rows % $chunksz));
00092 if ($offset_end == $total_rows)
00093 { $offset_end -= $chunksz; }
00094
00095 #fb("$offset_end offset_end");
00096
00097 $nav_bar .=
00098 '<span class="xsmall"><a href="'.$url.'&offset='.($offset+$chunksz).
00099 '#results">'._("Next Results").'<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/next.png" border="0" alt="'._("Next Results").'" /></a>'.
00100 ' '.
00101 '<a href="'.$url.'&offset='.($offset_end).
00102 '#results">'._("End").'<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/last.png" border="0" alt="'._("End").'" /></a></span>';
00103 }
00104 else
00105 {
00106 $nav_bar .= '<span class="xsmall"><em>'._("Next Results").'</em><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/nextgrey.png" border="0" alt="'._("Next Results").'" />'.
00107 ' '.
00108 '<em>'._("End").'</em><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/lastgrey.png" border="0" alt="'._("End").'" /></span>';
00109 }
00110 }
00111 $nav_bar .= '</h3>';
00112
00113 # Print prev/next links
00114 print $nav_bar.'<a name="results"></a><br />';
00115
00116 print html_build_list_table_top ($title_arr,$links_arr);
00117
00118 #see if the bugs are too old - so we can highlight them
00119 $nb_of_fields = count($field_arr);
00120
00121 while (list(,$thisitem) = each($result_arr))
00122 {
00123 $thisitem_id = $thisitem['bug_id'];
00124
00125 print '<tr class="'.utils_get_priority_color($result_arr[$thisitem_id]["priority"], $result_arr[$thisitem_id]["status_id"]).'">'."\n";
00126
00127 for ($j=0; $j<$nb_of_fields; $j++)
00128 {
00129 # If we are in digest mode, add the digest checkbox
00130 if ($field_arr[$j] == "digest")
00131 {
00132 # Dirty workaround to have boxes selected by default in the
00133 # form_input
00134 print '<td class="center">'.form_input("checkbox", "items_for_digest[]", "$thisitem_id\" checked=\"checked").'</td>';
00135 continue;
00136 }
00137
00138 $value = $result_arr[$thisitem_id][$field_arr[$j]];
00139 if ($width_arr[$j])
00140 {
00141 $width = 'width="'.$width_arr[$j].'%"';
00142 }
00143 else
00144 {
00145 $width = '';
00146 }
00147
00148 if (trackers_data_is_date_field($field_arr[$j]) )
00149 {
00150 if ($value)
00151 {
00152 if ($field_arr[$j] == 'planned_close_date' and $value < time())
00153 { $highlight_date = ' class="highlight"'; }
00154 else
00155 { $highlight_date = ''; }
00156 print "<td $width$highlight_date>";
00157 print format_date('short',$value);
00158 print "</td>\n";
00159 }
00160 else
00161 { print "<td align=\"middle\" $width>-</td>\n"; }
00162
00163 }
00164 else if ($field_arr[$j] == 'bug_id')
00165 {
00166
00167 if ($nolink)
00168 { print "<td $width>#$value</td>\n"; }
00169 else
00170 {
00171 print "<td $width>";
00172
00173 print '<a href="?func=detailitem&item_id='.$value.'">';
00174
00175 print ' #'.$value .'</a></td>'."\n";
00176
00177 }
00178
00179 }
00180 else if (trackers_data_is_username_field($field_arr[$j]))
00181 {
00182
00183 if ($nolink)
00184 { print "<td $width>$value</td>\n"; }
00185 else
00186 { print "<td $width>".utils_user_link($value)."</td>\n"; }
00187
00188 }
00189 else if (trackers_data_is_select_box($field_arr[$j]))
00190 {
00191 print "<td $width>". trackers_data_get_cached_field_value($field_arr[$j], $group_id, $value) .'</td>'."\n";
00192
00193 }
00194 else
00195 {
00196 if ($nolink)
00197 { print "<td $width>". $value .' </td>'."\n"; }
00198 else
00199 {
00200 print "<td $width>".'<a href="?func=detailitem&item_id='.
00201 $thisitem_id.'">'.
00202 $value .'</a></td>'."\n";
00203 }
00204 }
00205
00206 }
00207 print "</tr>\n";
00208 }
00209
00210 print '</table>';
00211
00212 # Print prev/next links
00213 print "<br />".$nav_bar;
00214
00215 }
00216
00220 function show_item_list_sober ($result_arr,
00221 $total_rows,
00222 $url)
00223 {
00224 global $group_id, $sys_group_id, $sys_name;
00225
00226 $possible_contexts = cookbook_context_possiblevalues();
00227 $possible_audiences = cookbook_audience_possiblevalues();
00228
00229 # If we are on a project cookbook, take into account impossible values:
00230 # recipes of features unused by the project
00231 $impossible_contexts = array();
00232 if ($group_id != $sys_group_id)
00233 {
00234 $impossible_contexts = cookbook_context_project_impossiblevalues();
00235 }
00236
00237
00238 # Add the unset case, when the item is actually not bound to any context
00239 # or action
00240 # Build sql specific part for these
00241 unset($sql_unboundcontext, $sql_unboundaudience);
00242 $thisarray = array_merge($possible_contexts, $impossible_contexts);
00243 while (list($context,) = each($thisarray))
00244 {
00245 $sql_unboundcontext .= "AND context_$context='0' ";
00246 }
00247 while (list($audience,) = each($possible_audiences))
00248 { $sql_unboundaudience .= "AND audience_$audience='0' "; }
00249
00250 # Built for scratch two groups of audiences possible for this page:
00251 # group members and non-group members
00252 $possible_audiences = array();
00253 $possible_audiences['nonmembers'] = _("Non Project Members");
00254 $possible_audiences['members'] = _("Project Members");
00255
00256 # Add unset cases to the arrays
00257 $possible_contexts['unbound'] = _("Other");
00258 $possible_audiences['unbound'] = _("Undefined");
00259
00260 # Build sql specific part to group audiences between:
00261 # project members / non project members
00262 $sql_nonmembers = "AND (audience_anonymous='1' OR audience_loggedin='1')";
00263 $sql_members = "AND (audience_members='1' OR audience_technicians='1' OR audience_managers='1')";
00264
00265 unset($sql_privateitem);
00266
00267 # Go through the list of possible context and then possible actions
00268 # print relevant items
00269 print '<ul>';
00270 reset($possible_contexts);
00271 while (list($context,$context_label) = each($possible_contexts))
00272 {
00273 unset($context_content);
00274 reset($possible_audiences);
00275 while (list($audience,$audience_label) = each($possible_audiences))
00276 {
00277 # Get recipes contextual data
00278 # (no limit argument, expecting people not to use terrible scales)
00279
00280 if ($audience == 'nonmembers')
00281 {
00282 $sql_audience = $sql_nonmembers;
00283 }
00284 else
00285 {
00286 $sql_audience = $sql_members;
00287 }
00288
00289 # Special deal for the item unbound
00290 if ($audience != 'unbound' && $context != 'unbound')
00291 {
00292 # Normal case, binds for both context and audience
00293 $sql_context = "SELECT * FROM cookbook_context2recipe WHERE (group_id='$group_id' OR group_id='$sys_group_id') AND context_$context='1' $sql_audience";
00294 }
00295 else if ($audience == 'unbound' && $context != 'unbound')
00296 {
00297 # Bind only for the context
00298 $sql_context = "SELECT * FROM cookbook_context2recipe WHERE (group_id='$group_id' OR group_id='$sys_group_id') AND context_$context='1' $sql_unboundaudience";
00299 }
00300 else if ($context == 'unbound' && $audience != 'unbound')
00301 {
00302 # Bind only for the audience
00303 $sql_context = "SELECT * FROM cookbook_context2recipe WHERE (group_id='$group_id' OR group_id='$sys_group_id') $sql_audience $sql_unboundcontext";
00304 }
00305 else if ($context == 'unbound' && $audience == 'unbound')
00306 {
00307 # Not binded at all
00308 $sql_context = "SELECT * FROM cookbook_context2recipe WHERE (group_id='$group_id' OR group_id='$sys_group_id') $sql_unboundcontext $sql_unboundaudience";
00309 }
00310
00311 $result_context = db_query($sql_context);
00312 $result_rows = db_numrows($result_context);
00313
00314 if ($result_rows)
00315 {
00316 # We want to show items sorted by alphabetical order.
00317 # We will first put the result in a an array
00318 # we will sort the array and use it to print out results.
00319 # We store the summary in lower case, to avoid having a case
00320 # sensitive sort.
00321 $thisaudience_results = array();
00322 for ($i = 0; $i < $result_rows; $i++)
00323 {
00324 $thisitem_id = db_result($result_context, $i, 'recipe_id');
00325 $thisaudience_results[$thisitem_id] =
00326 strtolower($result_arr[$thisitem_id]["summary"]);
00327 }
00328 asort($thisaudience_results);
00329 unset($audience_content);
00330 while (list($thisitem_id,$summary) = each($thisaudience_results))
00331 {
00332 # Ignore if not approved
00333 if ($result_arr[$thisitem_id]["resolution_id"] != '1')
00334 { continue; }
00335
00336 # Detect if it is a site wide doc item. Ignore that if we
00337 # are on the site admin group
00338 unset($is_site_doc, $url_extra_arg);
00339 if ($group_id != $sys_group_id)
00340 {
00341 if ($result_arr[$thisitem_id]["group_id"] == $sys_group_id)
00342 {
00343 $is_site_doc = true;
00344 $url_extra_arg = '&comingfrom='.$group_id;
00345 }
00346 }
00347
00348
00349 $audience_content .= '<li>';
00350 # Show specific background color only for maximum priority
00351 $priority = $result_arr[$thisitem_id]["priority"];
00352 if ($priority > 4)
00353 {
00354 $audience_content .= '<span class="'.utils_get_priority_color($result_arr[$thisitem_id]["priority"]).'">';
00355 }
00356
00357 # In this link, we need to mention from where we come from
00358 # so it is possible to know if we are actually inside a
00359 # group cookbook if ever we look at a site wide documentation
00360 $audience_content .= utils_link($GLOBALS['sys_home'].'cookbook/?func=detailitem'.$url_extra_arg.'&item_id='.$thisitem_id, $result_arr[$thisitem_id]["summary"]);
00361 if ($priority > 4)
00362 {
00363 $audience_content .= '</span>';
00364 }
00365
00366 # If it comes from the site docs, mention it
00367 if ($is_site_doc)
00368 {
00369 $audience_content .= ' <span class="smaller">('.sprintf(_("From %s User Docs"), $sys_name).')</span>';
00370 }
00371
00372 $audience_content .= '</li>';
00373 }
00374
00375 # If there was valid results, save the subcontext
00376 if (!$audience_content)
00377 { continue; }
00378
00379 $context_content .= '<li><span class="smaller">'.sprintf(_("%s:"), $audience_label).'</span>';
00380 $context_content .= '<ul>';
00381 $context_content .= $audience_content;
00382 $context_content .= '</ul>';
00383 $context_content .= '</li>';
00384 }
00385 }
00386 # If there was valid results, print the context
00387 if (!$context_content)
00388 { continue; }
00389
00390 print '<li>'.html_anchor(sprintf(_("%s:"), $context_label), $context);
00391 print '<ul>';
00392 print $context_content;
00393 print '</ul><br />';
00394 print '</li>';
00395
00396 }
00397 print '</ul>';
00398
00399
00400
00401
00402
00403 return true;
00404 while (list(,$thisitem) = each($result_arr))
00405 {
00406 $thisitem_id = $thisitem['bug_id'];
00407
00408 print '<tr class="'.utils_get_priority_color($result_arr[$thisitem_id]["priority"], $result_arr[$thisitem_id]["status_id"]).'">'."\n";
00409
00410 for ($j=0; $j<$nb_of_fields; $j++)
00411
00412
00413 {
00414 # If we are in digest mode, add the digest checkbox
00415 if ($field_arr[$j] == "digest")
00416 {
00417 print '<td class="center">'.form_input("checkbox", "items_for_digest[]", $thisitem_id).'</td>';
00418 continue;
00419 }
00420
00421 $value = $result_arr[$thisitem_id][$field_arr[$j]];
00422 if ($width_arr[$j])
00423 {
00424 $width = 'width="'.$width_arr[$j].'%"';
00425 }
00426 else
00427 {
00428 $width = '';
00429 }
00430
00431 if (trackers_data_is_date_field($field_arr[$j]) )
00432 {
00433 if ($value)
00434 {
00435 if ($field_arr[$j] == 'planned_close_date' and $value < time())
00436 { $highlight_date = ' class="highlight"'; }
00437 else
00438 { $highlight_date = ''; }
00439 print "<td $width$highlight_date>";
00440 print format_date('short',$value);
00441 print "</td>\n";
00442 }
00443 else
00444 { print "<td align=\"middle\" $width>-</td>\n"; }
00445
00446 }
00447 else if ($field_arr[$j] == 'bug_id')
00448 {
00449
00450 if ($nolink)
00451 { print "<td $width>#$value</td>\n"; }
00452 else
00453 {
00454 print "<td $width>";
00455
00456 print '<a href="?func=detailitem&item_id='.$value.'">';
00457
00458 print ' #'.$value .'</a></td>'."\n";
00459
00460 }
00461
00462 }
00463 else if (trackers_data_is_username_field($field_arr[$j]))
00464 {
00465
00466 if ($nolink)
00467 { print "<td $width>$value</td>\n"; }
00468 else
00469 { print "<td $width>".utils_user_link($value)."</td>\n"; }
00470
00471 }
00472 else if (trackers_data_is_select_box($field_arr[$j]))
00473 {
00474 print "<td $width>". trackers_data_get_cached_field_value($field_arr[$j], $group_id, $value) .'</td>'."\n";
00475
00476 }
00477 else
00478 {
00479 if ($nolink)
00480 { print "<td $width>". $value .' </td>'."\n"; }
00481 else
00482 {
00483 print "<td $width>".'<a href="?func=detailitem&item_id='.
00484 $thisitem_id.'">'.
00485 $value .'</a></td>'."\n";
00486 }
00487 }
00488
00489 }
00490 print "</tr>\n";
00491 }
00492
00493 print '</table>';
00494
00495 # Print prev/next links
00496 print "<br />".$nav_bar;
00497
00498 }
00499
00500
00501 # Show the changes of the tracker data we have for this item,
00502 # excluding details
00503 function show_item_history ($item_id,$group_id, $no_limit=false)
00504 {
00505 global $sys_datefmt;
00506 $result=trackers_data_get_history($item_id);
00507 $rows=db_numrows($result);
00508
00509 # If no limit is not set, print only 10 latest news items
00510 # yeupou--gnu.org 2004-09-17: currently we provide no way to get the
00511 # full history. We'll see if users request it.
00512 if ($no_limit)
00513 {
00514 $title = _("History");
00515 }
00516 else
00517 {
00518 if ($rows > 15)
00519 { $rows = 15; }
00520 $title = sprintf(ngettext("%s latest change", "%s latest changes", $rows), $rows);
00521 }
00522
00523
00524 print "\n".'<h3>'.html_anchor($title, "history").'</h3>';
00525
00526 if ($rows > 0)
00527 {
00528
00529 $title_arr=array();
00530 $title_arr[]=_("Date");
00531 $title_arr[]=_("Changed By");
00532 $title_arr[]=_("Updated Field");
00533 $title_arr[]=_("Previous Value");
00534 $title_arr[]="=>";
00535 $title_arr[]=_("Replaced By");
00536
00537 print html_build_list_table_top ($title_arr);
00538
00539 $j=0;
00540 for ($i=0; $i < $rows; $i++)
00541 {
00542 $field = db_result($result, $i, 'field_name');
00543
00544 # If the stored label is "realdetails", it means it is the details
00545 # field (realdetails is used because someone had the nasty idea to
00546 # use "details" to mean "comment")
00547 if ($field == "realdetails")
00548 { $field = "details"; }
00549
00550 $field_label = trackers_data_get_label($field);
00551
00552 # if field_label is empty, no label was found, return as it is stored
00553 if (!$field_label)
00554 { $field_label = $field; }
00555
00556 $value_id = db_result($result, $i, 'old_value');
00557 $new_value_id = db_result($result, $i, 'new_value');
00558
00559 $date = db_result($result, $i, 'date');
00560 $user = db_result($result, $i, 'user_name');
00561
00562 # If the previous date and user are equal, do not print user
00563 # and date
00564 if ($date == $previous_date && $user == $previous_user)
00565 {
00566 print "\n".'<tr class="'. utils_get_alt_row_color($j).'"><td> </td><td> </td>';
00567
00568 }
00569 else
00570 {
00571
00572 $j++;
00573 print "\n".'<tr class="'. utils_get_alt_row_color($j).'">';
00574
00575 # Date
00576 print '<td align="center" class="smaller">'.format_date($sys_datefmt,$date).'</td>';
00577
00578 # Person
00579 print '<td align="center" class="smaller">'.utils_user_link($user).'</td>';
00580 }
00581
00582 $previous_date = $date;
00583 $previous_user = $user;
00584
00585 # Updated Field
00586 print '<td class="smaller" align="center">'.$field_label.'</td>';
00587
00588 # Previous value
00589 print '<td class="smaller" align="right">';
00590 if (trackers_data_is_select_box($field))
00591 {
00592 # Its a select box look for value in clear
00593 # (If we hit case of transition automatique update, show it in
00594 # specific way)
00595 if ($value_id == "transition-other-field-update")
00596 {
00597 print "-"._("Automatic update due to transitions settings")."-";
00598 }
00599 else
00600 {
00601 print trackers_data_get_value($field, $group_id, $value_id);
00602 }
00603 }
00604 else if (trackers_data_is_date_field($field))
00605 {
00606 # For date fields do some special processing
00607 print format_date($sys_datefmt,$value_id);
00608 }
00609 else
00610 {
00611 # It's a text zone then display directly
00612 print $value_id;
00613 }
00614
00615 print '</td><td class="smaller" align="center"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/next.png" border="0" alt="=>" /></td><td class="smaller" align="left">';
00616 # New value
00617 if (trackers_data_is_select_box($field))
00618 {
00619 # It's a select box look for value in clear
00620 print trackers_data_get_value($field, $group_id, $new_value_id);
00621 }
00622 else if (trackers_data_is_date_field($field))
00623 {
00624 # For date fields do some special processing
00625 print format_date($sys_datefmt,$new_value_id);
00626 }
00627 else
00628 {
00629 # It's a text zone then display directly
00630 print $new_value_id;
00631 }
00632 print '</td>';
00633
00634 print '</tr>';
00635
00636 }
00637 print '</table>';
00638
00639 }
00640 else
00641 {
00642 print "\n".'<span class="warn">'._("No Changes Have Been Made to This Item").'</span>';
00643 }
00644 }
00645
00646
00647 function show_item_details ($item_id, $group_id, $ascii=false, $item_assigned_to=false,$quoted=false)
00648 {
00649 print format_item_details($item_id,$group_id,$ascii,$item_assigned_to,$quoted);
00650 }
00651
00652
00653
00654 function show_item_attached_files ($item_id,$group_id, $ascii=false, $sober=false)
00655 {
00656 print format_item_attached_files ($item_id,$group_id, $ascii, $sober);
00657 }
00658
00659
00660 function show_item_cc_list ($item_id,$group_id, $ascii=false)
00661 {
00662 print format_item_cc_list ($item_id,$group_id, $ascii);
00663 }
00664
00665
00666 # Look for items that $item_id depends on in all artifact
00667 function show_item_dependency ($item_id)
00668 {
00669 return show_dependent_item($item_id, $dependson=1);
00670 }
00671
00672
00673 # Look for items that depends on $item_id in all artifacts (default)
00674 # or look for items that $item_id depends on in all artifact.
00675 function show_dependent_item ($item_id, $dependson=0)
00676 {
00677 global $group_id;
00678
00679 $artifacts = array("support", "bugs", "task", "patch");
00680 $result = array();
00681 $rows = array();
00682 $is_manager = member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'1');
00683
00684 if (!$dependson)
00685 { $title = _("Items that depend on this one"); }
00686 else
00687 { $title = _("Depends on the following items"); }
00688
00689 # Slurps the database.
00690 while (list($num, $art) = each($artifacts))
00691 {
00692 if (!$dependson)
00693 {
00694 $sql = "SELECT ".$art.".bug_id,".$art.".summary,".$art.".status_id,".$art.".resolution_id,".$art.".group_id,".$art.".priority,".$art.".privacy,".$art.".submitted_by ".
00695 " FROM ".$art.",".$art."_dependencies ".
00696 " WHERE ".$art.".bug_id=".$art."_dependencies.item_id ".
00697 " AND ".$art."_dependencies.is_dependent_on_item_id='$item_id'".
00698 " AND ".$art."_dependencies.is_dependent_on_item_id_artifact='".ARTIFACT."' ORDER by ".$art.".bug_id";
00699 }
00700 else
00701 {
00702 $sql = "SELECT ".$art.".bug_id,".$art.".summary,".$art.".status_id,".$art.".resolution_id,".$art.".group_id,".$art.".priority,".$art.".privacy,".$art.".submitted_by".
00703 " FROM ".$art.",".ARTIFACT."_dependencies ".
00704 " WHERE ".$art.".bug_id=".ARTIFACT."_dependencies.is_dependent_on_item_id ".
00705 " AND ".ARTIFACT."_dependencies.item_id='$item_id'".
00706 " AND ".ARTIFACT."_dependencies.is_dependent_on_item_id_artifact='".$art."' ORDER by ".$art.".bug_id ";
00707
00708 }
00709
00710 $result[$art] = db_query($sql);
00711 $rows[$art] = db_numrows($result[$art]);
00712 }
00713
00714 # Give back the HTML output, if we have some data.
00715 if ($rows["support"] > 0 ||
00716 $rows["bugs"] > 0 ||
00717 $rows["task"] > 0 ||
00718 $rows["patch"] > 0)
00719 {
00720
00721 global $HTML;
00722 print $HTML->box_top($title,'',1);
00723
00724 reset($artifacts);
00725 while (list($num, $art) = each($artifacts))
00726 {
00727 for ($i=0; $i < $rows[$art]; $i++)
00728 {
00729
00730 $link_to_item = $GLOBALS['sys_home'].$art.'/?func=detailitem&item_id='. db_result($result[$art], $i, 'bug_id');
00731
00732 $dstatus = db_result(db_query("SELECT value FROM ".$art."_field_value WHERE bug_field_id='108' AND (group_id='".db_result($result[$art], $i, 'group_id')."' OR group_id='100') AND value_id='".db_result($result[$art], $i, 'resolution_id')."' ORDER BY bug_fv_id DESC LIMIT 1"), 0, 'value');
00733
00734
00735 print '
00736 <li class="'.get_priority_color(db_result($result[$art], $i, 'priority'), db_result($result[$art], $i, 'status_id')).'">';
00737
00738 # Ability to remove a dependency is only given to technician
00739 # level members of a project.
00740 if ($dependson && $is_manager)
00741 {
00742 print '<span class="trash"><a href="'.$PHP_SELF.'?func=delete_dependancy&item_id='.$item_id.'&item_depends_on='.db_result($result[$art], $i, 'bug_id').
00743 '&item_depends_on_artifact='.$art.'">'.
00744 '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/trash.png" alt="'._("Delete this dependancy?").'" class="icon" /></a></span>';
00745 }
00746
00747 # Link to the item
00748 print '
00749 <a href="'.$link_to_item.'" class="block">';
00750
00751 # Show the item type with an icon
00752 print '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/'.utils_get_tracker_icon($art).'.png" class="icon" alt="'.$art.'" /> ';
00753
00754
00755 # Print summary only if the item is not private
00756 if (db_result($result, $i, 'privacy') == "2" &&
00757 !member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2') &&
00758 db_result($result[$art],$i,'submitted_by') != user_getid())
00759 { print _("---- Private ----"); }
00760 else
00761 { print db_result($result[$art], $i, 'summary'); }
00762
00763 # Print group info if the item is from another group
00764 unset($fromgroup);
00765 if (db_result($result[$art], $i, 'group_id') != $group_id)
00766 {
00767 $fromgroup = group_getname(db_result($result[$art], $i, 'group_id')).', ';
00768 }
00769
00770 # Mention the status
00771 print ' <span class="xsmall">('.utils_get_tracker_prefix($art).' #'.db_result($result[$art], $i, 'bug_id').', '.$fromgroup.$dstatus.')</span></a>';
00772 print '</li>';
00773 }
00774 }
00775 print $HTML->box_bottom(1);
00776
00777 # Link to digest dependant items
00778 if ($dependson)
00779 {
00780 reset($artifacts);
00781 while (list(,$art) = each($artifacts))
00782 {
00783 if ($rows[$art] > 0)
00784 {
00785 switch ($art)
00786 {
00787 case "support":
00788 $linktitle = _("Digest support dependencies");
00789 break;
00790 case "bugs":
00791 $linktitle = _("Digest bug dependencies");
00792 break;
00793 case "task":
00794 $linktitle = _("Digest task dependencies");
00795 break;
00796 case "patch":
00797 $linktitle = _("Digest patch dependencies");
00798 break;
00799 # add an emergency fallback
00800 default:
00801 $linktitle = sprintf(_("Digest %s dependencies"), $art);
00802 }
00803 print utils_link($GLOBALS['sys_home'].$art.'/?group_id='.$group_id.'&func=digestselectfield&dependencies_of_item='.$item_id.'&dependencies_of_tracker='.ARTIFACT, "[$linktitle]").' ';
00804 }
00805 }
00806 }
00807
00808 }
00809 else
00810 {
00811 print '<br /><span class="warn">';
00812 if (!$dependson)
00813 { print _("No items are dependent on this one"); }
00814 else
00815 { print _("This item doesn't depend on any other items"); }
00816 print '</span>';
00817 print db_error();
00818 }
00819 }
00820
00821
00822 ?>