3 * SourceForge Generic Tracker facility
5 * SourceForge: Breaking Down the Barriers to Open Source Development
6 * Copyright 1999-2001 (c) VA Linux Systems
7 * http://sourceforge.net
11 require_once('common/tracker/ArtifactFactory.class');
12 require_once('common/tracker/ArtifactQuery.class');
14 // make sure this person has permission to view artifacts
16 if (!$ath->userCanView()) {
17 exit_permission_denied();
21 // The browse page can be powered by a pre-saved query
22 // or by select boxes chosen by the user
24 // If there is a $query_id coming from the request OR the pref
25 // was already saved, use the artifact factory that way.
27 // If the query_id = -1, unset the pref and use regular browse boxes
29 if (session_loggedin()) {
30 $query_id = getIntFromRequest('query_id');
33 if ($query_id == '-1') {
34 $u =& session_get_user();
35 $u->setPreference('art_query'.$ath->getID(),'');
37 $aq = new ArtifactQuery($ath,$query_id);
38 if (!$aq || !is_object($aq)) {
39 exit_error('Error',$aq->getErrorMessage());
44 $u =& session_get_user();
45 $query_id=$u->getPreference('art_query'.$ath->getID(),'');
49 $af = new ArtifactFactory($ath);
50 if (!$af || !is_object($af)) {
51 exit_error('Error','Could Not Get Factory');
52 } elseif ($af->isError()) {
53 exit_error('Error',$af->getErrorMessage());
56 $offset = getStringFromRequest('offset',$offset);
57 $_sort_col = getStringFromRequest('_sort_col',$_sort_col);
58 $_sort_ord = getStringFromRequest('_sort_ord',$_sort_ord);
59 $max_rows = getStringFromRequest('max_rows',$max_rows);
60 $set = getStringFromRequest('set',$set);
61 $_assigned_to = getStringFromRequest('_assigned_to',$_assigned_to);
62 $_status = getStringFromRequest('_status',$_status);
63 if ($func != 'postadd' && $func != 'postmod' && $func != 'massupdate') {
64 $_extra_fields = getArrayFromRequest('extra_fields');
67 $af->setup($offset,$_sort_col,$_sort_ord,$max_rows,$set,$_assigned_to,$_status,$_extra_fields);
68 $_sort_col=$af->order_col;
71 $_assigned_to=$af->assigned_to;
73 $art_arr =& $af->getArtifacts();
75 if (!$art_arr && $af->isError()) {
76 exit_error('Error',$af->getErrorMessage());
79 //build page title to make bookmarking easier
80 //if a user was selected, add the user_name to the title
82 $ath->header(array('atid'=>$ath->getID()));
86 * Build the powerful browsing options pop-up boxes
91 // creating a custom technician box which includes "any" and "unassigned"
93 $res_tech= $ath->getTechnicians();
95 $tech_id_arr=util_result_column_to_array($res_tech,0);
96 $tech_id_arr[]='0'; //this will be the 'any' row
98 $tech_name_arr=util_result_column_to_array($res_tech,1);
99 $tech_name_arr[]=$Language->getText('tracker','any');
101 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,$Language->getText('tracker','unassigned'));
105 // custom order by arrays to build a pop-up box
107 $order_name_arr=array();
108 $order_name_arr[]=$Language->getText('tracker','id');
109 $order_name_arr[]=$Language->getText('tracker','priority');
110 $order_name_arr[]=$Language->getText('tracker','summary');
111 $order_name_arr[]=$Language->getText('tracker','open_date');
112 $order_name_arr[]=$Language->getText('tracker','close_date');
113 $order_name_arr[]=$Language->getText('tracker','submitter');
114 $order_name_arr[]=$Language->getText('tracker','assignee');
118 $order_arr[]='artifact_id';
119 $order_arr[]='priority';
120 $order_arr[]='summary';
121 $order_arr[]='open_date';
122 $order_arr[]='close_date';
123 $order_arr[]='submitted_by';
124 $order_arr[]='assigned_to';
127 // custom sort arrays to build pop-up box
129 $sort_name_arr=array();
130 $sort_name_arr[]=$Language->getText('tracker_browse','ascending');
131 $sort_name_arr[]=$Language->getText('tracker_browse','descending');
138 // custom changed arrays to build pop-up box
140 $changed_name_arr=array();
141 $changed_name_arr[]=$Language->getText('tracker_browse','changed_any');
142 $changed_name_arr[]=$Language->getText('tracker_browse','hour24');
143 $changed_name_arr[]=$Language->getText('tracker_browse','day7');
144 $changed_name_arr[]=$Language->getText('tracker_browse','week2');
145 $changed_name_arr[]=$Language->getText('tracker_browse','month1');
147 $changed_arr=array();
148 $changed_arr[]= 0x7fffffff; // Any
149 $changed_arr[]= 3600 * 24; // 24 hour
150 $changed_arr[]= 3600 * 24 * 7; // 1 week
151 $changed_arr[]= 3600 * 24 * 14;// 2 week
152 $changed_arr[]= 3600 * 24 * 30;// 1 month
155 // statuses can be custom in GForge 4.5+
157 if ($ath->usesCustomStatuses()) {
158 $status_box=$ath->renderSelect ($ath->getCustomStatusField(),$extra_fields[$ath->getCustomStatusField()],false,'',true,$Language->getText('tracker','status_any'));
160 $status_box = $ath->statusBox('_status',$_status,true,$Language->getText('tracker','status_any'));
163 <table width="100%" border="0">';
168 Logged in users get the option of seeing a power-browse box
170 if (session_loggedin()) {
171 echo '<td rowspan="2">';
172 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">';
173 echo '<input type="hidden" name="power_query" value="1">';
174 $res=db_query("SELECT artifact_query_id,query_name
175 FROM artifact_query WHERE user_id='".user_getid()."' AND group_artifact_id='".$ath->getID()."'");
177 if (db_numrows($res)>0) {
179 <span style="font-size:smaller">'.html_build_select_box($res,'query_id',$af->getDefaultQuery(),false).'</span><br />
180 <span style="font-size:smaller"><input type="submit" name="run" value="'.$Language->getText('tracker','run_query').'"></input>
181 <span style="font-size:smaller"><strong><a href="javascript:admin_window(\'/tracker/?func=query&group_id='.$group_id.'&atid='. $ath->getID().'\')">'.
182 $Language->getText('tracker','build_query').'</a></strong></span>';
184 echo '<span style="font-size:smaller"><strong>
185 <a href="javascript:admin_window(\'/tracker/?func=query&group_id='.$group_id.'&atid='. $ath->getID().'\')">'.$Language->getText('tracker','build_query').'</a></strong></span>';
192 <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">
193 <input type="hidden" name="set" value="custom" />
194 <td><span style="font-size:smaller">'.$Language->getText('tracker','assignee').': <br />'. $tech_box .'</span></td>'.
195 '<td><span style="font-size:smaller">'.$Language->getText('tracker','status').': <br />'. $status_box .'</span></td>';
199 <input type="hidden" name="query_id" value="-1">';
203 <td align="right"><span style="font-size:smaller">'.$Language->getText('tracker_browse','sort_by').': <a href="javascript:help_window(\'/help/tracker.php?helpname=sort_by\')"><strong>(?)</strong></a></span></td>'.
204 '<td><span style="font-size:smaller">'.
205 html_build_select_box_from_arrays($order_arr,$order_name_arr,'_sort_col',$_sort_col,false) .
206 html_build_select_box_from_arrays($sort_arr,$sort_name_arr,'_sort_ord',$_sort_ord,false) .
207 '<input type="submit" name="submit" value="'.$Language->getText('tracker','quickbrowse').'" /></span></td>
216 * Show the free-form text submitted by the project admin
218 echo $ath->getBrowseInstructions();
220 if ($art_arr && count($art_arr) > 0) {
222 if ($set=='custom') {
223 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status.'&_sort_col='.$_sort_col.'&_sort_ord='.$_sort_ord;
227 $IS_ADMIN=$ath->userIsAdmin();
231 <form name="artifactList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" METHOD="POST">
232 <input type="hidden" name="form_key" value="'.form_generate_key().'">
233 <input type="hidden" name="func" value="massupdate">';
236 $display_col=array('summary'=>1,
244 $title_arr[]=$Language->getText('tracker','id');
245 if ($display_col['summary'])
246 $title_arr[]=$Language->getText('tracker','summary');
247 if ($display_col['open_date'])
248 $title_arr[]=$Language->getText('tracker','open_date');
249 if ($display_col['status'])
250 $title_arr[]=$Language->getText('tracker','status');
251 if ($display_col['priority'])
252 $title_arr[]=$Language->getText('tracker','priority');
253 if ($display_col['assigned_to'])
254 $title_arr[]=$Language->getText('tracker','assigned_to');
255 if ($display_col['submitted_by'])
256 $title_arr[]=$Language->getText('tracker','submitted_by');
259 echo $GLOBALS['HTML']->listTableTop ($title_arr);
261 $then=(time()-$ath->getDuePeriod());
262 $rows=count($art_arr);
263 for ($i=0; $i < $rows; $i++) {
265 <tr bgcolor="'. html_get_priority_color( $art_arr[$i]->getPriority() ) .'">'.
267 ($IS_ADMIN?'<input type="CHECKBOX" name="artifact_id_list[]" value="'.
268 $art_arr[$i]->getID() .'"> ':'').
269 $art_arr[$i]->getID() .
271 if ($display_col['summary'])
272 echo '<td><a href="'.getStringFromServer('PHP_SELF').'?func=detail&aid='.
273 $art_arr[$i]->getID() .
274 '&group_id='. $group_id .'&atid='.
276 $art_arr[$i]->getSummary().
278 if ($display_col['open_date'])
279 echo '<td>'. (($set != 'closed' && $art_arr[$i]->getOpenDate() < $then)?'* ':' ') .
280 date($sys_datefmt,$art_arr[$i]->getOpenDate()) .'</td>';
281 if ($display_col['status'])
282 echo '<td>'. $art_arr[$i]->getStatusName() .'</td>';
283 if ($display_col['priority'])
284 echo '<td>'. $art_arr[$i]->getPriority() .'</td>';
285 if ($display_col['assigned_to'])
286 echo '<td>'. $art_arr[$i]->getAssignedRealName() .'</td>';
287 if ($display_col['submitted_by'])
288 echo '<td>'. $art_arr[$i]->getSubmittedRealName() .'</td>';
293 Show extra rows for <-- Prev / Next -->
295 //only show this if we´re not using a power query
296 if (!getStringFromRequest('power_query')) {
297 if (($offset > 0) || ($rows >= 50)) {
299 <tr><td colspan="2">';
301 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
302 $set.'&offset='.($offset-50).'"><strong><-- '.$Language->getText('tracker_browse','previous').'</strong></a>';
306 echo '</td><td> </td><td colspan="2">';
308 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
309 $set.'&offset='.($offset+50).'"><strong>'.$Language->getText('tracker_browse','next').' --></strong></a>';
316 echo $GLOBALS['HTML']->listTableBottom();
321 echo '<script language="JavaScript">
323 function checkAll(val) {
324 al=document.artifactList;
325 len = al.elements.length;
327 for( i=0 ; i<len ; i++) {
328 if (al.elements[i].name==\'artifact_id_list[]\') {
329 al.elements[i].checked=val;
336 <table width="100%" border="0">
339 <a href="javascript:checkAll(1)">'.$Language->getText('tracker_browse','check_all').'</a>
341 <a href="javascript:checkAll(0)">'.$Language->getText('tracker_browse','clear_all').'</a>
344 <FONT COLOR="#FF0000">'.$Language->getText('tracker_browse','admin_mass_update').'
349 // build custom fields
351 $ef =& $ath->getExtraFields(ARTIFACT_EXTRAFIELD_FILTER_INT);
352 $keys=array_keys($ef);
355 for ($i=0; $i<count($keys); $i++) {
356 if (($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) || ($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)) {
357 $sel[$keys[$i]]=array('100');
359 $sel[$keys[$i]]='100';
362 $ath->renderExtraFields($sel,true,$Language->getText('tracker_browse','no_change'),false,'',ARTIFACT_EXTRAFIELD_FILTER_INT,true);
364 <td><strong>'.$Language->getText('tracker','priority').': <a href="javascript:help_window(\'/help/tracker.php?helpname=priority\')"><strong>(?)</strong></a>
366 echo build_priority_select_box ('priority', '100', true);
373 <td><strong>'.$Language->getText('tracker','assigned_to').': <a href="javascript:help_window(\'/help/tracker.php?helpname=assignee\')"><strong>(?)</strong></a>
374 </strong><br />'. $ath->technicianBox ('assigned_to','100.1',true,$Language->getText('tracker_artifacttype','nobody'),'100.1',$Language->getText('tracker_browse','no_change')) .'</td>
376 if (!$ath->usesCustomStatuses()) {
377 echo '<strong>'.$Language->getText('tracker','status').': <a href="javascript:help_window(\'/help/tracker.php?helpname=status\')"><strong>(?)</strong></a></strong>
378 <br />'. $ath->statusBox ('status_id','xzxz',true,$Language->getText('tracker_browse','no_change'));
383 <tr><td colspan="2"><strong>'.$Language->getText('tracker_browse','canned_response').':
384 <a href="javascript:help_window(\'/help/tracker.php?helpname=canned_response\')"><strong>(?)</strong></a>
385 </strong><br />'. $ath->cannedResponseBox ('canned_response') .'</td></tr>
387 <tr><td colspan="3" align="MIDDLE"><input type="SUBMIT" name="submit" value="'.$Language->getText('tracker_browse','mass_update').'"></td></tr>
393 echo $Language->getText('tracker_browse','old_requests',array(($ath->getDuePeriod()/86400) ));
394 show_priority_colors_key();
399 <h1>'.$Language->getText('tracker_browse','no_items').'</h1>';
401 //echo "<!-- $sql -->";
405 $ath->footer(array());