Main Page | Directories | File List | File Members

digest.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: digest.php 5469 2006-02-21 20:04:52Z toddy $
00006 #
00007 #  Copyright  2004 (c) Mathieu Roy <yeupou--gnu.org>
00008 #
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 if ($func == "digest")
00024 {
00025   $browse_preamble = '<p>'._("Select the items you wish to digest with the checkbox shown next to the \"Item Id\" field, on the table below. You will be able to select the fields you wish to include in your digest at the next step.").'</p><p class="warn">'._("Once your selection is made, click on the button \"Proceed to Digest next step\" at the bottom of this page.").'</p>';
00026 }
00027 elseif ($func == "digestselectfield")
00028 {
00029   # Determines items to digest, if we are supposed to digest dependancies
00030   if ($dependencies_of_item && $dependencies_of_tracker)
00031     {
00032 
00033       $sql = "SELECT is_dependent_on_item_id FROM ".$dependencies_of_tracker."_dependencies WHERE item_id='".addslashes($dependencies_of_item)."' AND is_dependent_on_item_id_artifact='".ARTIFACT."' ORDER by is_dependent_on_item_id";
00034       $res_deps = db_query($sql);
00035       $items_for_digest = array();
00036       while ($deps = db_fetch_array($res_deps))
00037         {
00038           $items_for_digest[] = $deps['is_dependent_on_item_id'];
00039         }
00040     }
00041 
00042 
00043   if (!is_array($items_for_digest))
00044     {
00045       exit_error(_("No items selected for digest"));
00046     }
00047 
00048   trackers_header(array('title'=>_("Digest Items: Fields Selection")));
00049 
00050   print '<form action="'.$PHP_SELF.'" method="get">
00051 <input type="hidden" name="group" value="'.$group_name.'" />
00052 <input type="hidden" name="func" value="digestget" />
00053 ';
00054 
00055   # Keep track of the selected items
00056   $count = 0;
00057   while (list(,$item) = each($items_for_digest))
00058     {
00059       print form_input("hidden", "items_for_digest[]", $item);
00060       $count++;
00061     }
00062 
00063   print "\n\n<p>";
00064   printf(ngettext("You selected %s item for this digest. Now you must unselect fields you do not want to be included in the digest.", "You selected %s items for this digest. Now you must unselect fields you do not want to be included in the digest.", $count), $count)."</p>\n";
00065 
00066   # Select fields
00067   while ($field_name = trackers_list_all_fields())
00068     {
00069 
00070       if (trackers_data_is_used($field_name))
00071         {
00072           # Open/Close and Group id are meaningless in this context:
00073           # they ll be on the output page in any cases
00074           if ($field_name == 'group_id' ||
00075               $field_name == 'status_id')
00076             { continue; }
00077 
00078           # Item id is mandatory
00079           if ($field_name == "bug_id")
00080             {
00081               print form_input("hidden", "field_used[".$field_name."]", "1").
00082                 "\n";
00083               continue;
00084             }
00085 
00086           print '<div class="'. utils_get_alt_row_color($i) .'">'.
00087             '<input type="checkbox" name="field_used['.$field_name.']" value="1" checked="checked" />&nbsp;&nbsp;'.trackers_data_get_label($field_name).' <span class="smaller"><em>- '.trackers_data_get_description($field_name)."</em></span></div>\n";
00088           $i++;
00089         }
00090     }
00091   # Comments is not an authentic field but could be useful. We allow
00092   # addition of the latest comment
00093   print '<div class="'. utils_get_alt_row_color($i) .'">'.
00094     '<input type="checkbox" name="field_used[latestcomment]" value="1" checked="checked" />&nbsp;&nbsp;'._("Latest Comment").' <span class="smaller"><em>- '._("Latest comment posted about the item.").'</em></span></div>'."\n";
00095 
00096   print form_footer(_("Submit"));
00097 
00098   trackers_footer(array());
00099 
00100 }
00101 elseif ($func == "digestget")
00102 {
00103 
00104   if (!is_array($items_for_digest))
00105     {
00106       exit_error(_("No items selected for digest"));
00107     }
00108 
00109   if (!is_array($field_used))
00110     {
00111       exit_error(_("No fields selected for digest"));
00112     }
00113 
00114 
00115   trackers_header(array('title'=>_("Digest").' - '.format_date($sys_datefmt,time())));
00116 
00117 
00118   # Browse the list of selected item
00119   while (list(,$item) = each($items_for_digest))
00120     {
00121       $i++;
00122 
00123       $result = db_query("SELECT * FROM ".ARTIFACT." WHERE bug_id='$item' AND group_id='$group_id'");
00124 
00125       # Skip it is it is private but the user got no privilege.
00126       # Normally, the user should not even been able to select this item.
00127       # But someone nasty could forge the arguments of the script... So its
00128       # better to check everytime.
00129       if (db_result($result,0,'privacy') == "2" && !member_check_private(0, db_result($result, 0, 'group_id')))
00130         { continue; }
00131 
00132       # Show summary if requested
00133       unset($summary);
00134       if ($field_used['summary'] == 1)
00135         {
00136           $summary = db_result($result,0,'summary');
00137         }
00138 
00139       # Show if the item is closed with an icon
00140       unset($icon);
00141       if (db_result($result, 0, 'status_id') != 1)
00142         { $icon = '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/ok.png" border="0" alt="'._("Closed Item").'" />'; }
00143       else
00144         { $icon = '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/wrong.png" border="0" alt="'._("Open Item").'" />'; }
00145 
00146       print '<div class="'. utils_get_alt_row_color($i) .'">';
00147       print '<span class="large"><span class="'.utils_get_priority_color(db_result($result,0,'priority'), db_result($result,0,'status_id')).'">'.$icon.'&nbsp; '.utils_link("?func=detailitem&amp;item_id=".$item, ARTIFACT.' #'.$item).': &nbsp;'.$summary.' &nbsp;</span></span><br /><br />';
00148 
00149       $field_count = 0;
00150       while ($field_name = trackers_list_all_fields())
00151         {
00152           # Some field can be ignored in any cases
00153           if ($field_name == "status_id" ||
00154               $field_name == "summary" ||
00155               $field_name == "bug_id" ||
00156               $field_name == "details")
00157             { continue; }
00158 
00159 # Check the fields
00160           if ($field_used[$field_name] != 1)
00161             { continue; }
00162 
00163           $field_count++;
00164           if ($field_count == 2)
00165             { $field_count = 0; }
00166 
00167           if ($field_count == 1)
00168             {  print '<span class="splitright">'; }
00169           else
00170             {  print '<span class="splitleft">'; }
00171 
00172           # Extract value
00173           $value = trackers_field_display($field_name,db_result($result, 0, 'group_id'),db_result($result,0,$field_name),false,false,true);
00174           # If it is an user name field, show full user info
00175           if ($field_name == "assigned_to" ||
00176               $field_name == "submitted_by")
00177             {
00178               $value = utils_user_link($value, user_getrealname(user_getid($value)));
00179     }
00180 
00181           print trackers_field_label_display($field_name,db_result($result, 0, 'group_id'),false,false).' '.$value;
00182 
00183           print '</span>';
00184 
00185           if ($field_count == 1)
00186             {  print '<br />'; }
00187 
00188         }
00189 
00190       # finally include details + last comment, if asked
00191       if ($field_used["details"] == 1)
00192         {
00193           print '<hr class="clearr" /><div class="smaller">'.utils_rich_markup(trackers_field_display("details",db_result($result, 0, 'group_id'),db_result($result,0,"details"),false,true,true)).'</div>';
00194         }
00195       if ($field_used["latestcomment"] == 1)
00196         {
00197           $last_comment = db_result(db_query("SELECT old_value FROM ".ARTIFACT."_history WHERE bug_id='$item' AND field_name='details' LIMIT 1"),0,'old_value');
00198           if ($last_comment)
00199             {
00200               print '<hr class="clearr" /><div class="smaller"><p>'._("Latest comment posted:").'</p>'.utils_rich_markup($last_comment).'</div>';
00201             }
00202         }
00203 
00204       print '<p class="clearr">&nbsp;</p>';
00205       print '</div>'."\n\n";
00206 
00207     }
00208   trackers_footer(array());
00209 }
00210 
00211 
00212 ?>

Generated on Sun Feb 26 13:23:03 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4