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);
51 if (!$af || !is_object($af)) {
52 exit_error('Error','Could Not Get Factory');
53 } elseif ($af->isError()) {
54 exit_error('Error',$af->getErrorMessage());
57 $offset = getStringFromRequest('offset',$offset);
58 $_sort_col = getStringFromRequest('_sort_col',$_sort_col);
59 $_sort_ord = getStringFromRequest('_sort_ord',$_sort_ord);
60 $max_rows = getStringFromRequest('max_rows',$max_rows);
61 $set = getStringFromRequest('set',$set);
62 $_assigned_to = getStringFromRequest('_assigned_to',$_assigned_to);
63 $_status = getStringFromRequest('_status',$_status);
64 if ($set == 'custom') {
66 //may be past in next/prev url
68 if ($_GET['extra_fields'][$ath->getCustomStatusField()]) {
69 $_extra_fields[$ath->getCustomStatusField()] = $_GET['extra_fields'][$ath->getCustomStatusField()];
71 $_extra_fields[$ath->getCustomStatusField()] = $_POST['extra_fields'][$ath->getCustomStatusField()];
75 if (is_array($_extra_fields)){
76 $keys=array_keys($_extra_fields);
77 foreach ($keys as $key) {
78 if ($_extra_fields[$key] != 'Array') {
79 $aux_extra_fields[$key] = $_extra_fields[$key];
83 $aux_extra_fields = $_extra_fields;
86 $af->setup($offset,$_sort_col,$_sort_ord,null,$set,$_assigned_to,$_status,$aux_extra_fields);
88 // These vals are sanitized and/or retrieved from ArtifactFactory stored settings
90 $_sort_col=$af->order_col;
93 $_assigned_to=$af->assigned_to;
94 $_extra_fields=$af->extra_fields;
96 $art_arr =& $af->getArtifacts();
98 if (!$art_arr && $af->isError()) {
99 exit_error('Error',$af->getErrorMessage());
102 //build page title to make bookmarking easier
103 //if a user was selected, add the user_name to the title
105 $ath->header(array('atid'=>$ath->getID()));
109 * Build the powerful browsing options pop-up boxes
114 // creating a custom technician box which includes "any" and "unassigned"
116 $res_tech= $ath->getTechnicians();
118 $tech_id_arr=util_result_column_to_array($res_tech,0);
119 $tech_id_arr[]='0'; //this will be the 'any' row
121 $tech_name_arr=util_result_column_to_array($res_tech,1);
122 $tech_name_arr[]=$Language->getText('tracker','any');
124 if (is_array($_assigned_to)) {
127 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,$Language->getText('tracker','unassigned'));
131 // custom order by arrays to build a pop-up box
133 $order_name_arr=array();
134 $order_name_arr[]=$Language->getText('tracker','id');
135 $order_name_arr[]=$Language->getText('tracker','priority');
136 $order_name_arr[]=$Language->getText('tracker','summary');
137 $order_name_arr[]=$Language->getText('tracker','open_date');
138 $order_name_arr[]=$Language->getText('tracker','close_date');
139 $order_name_arr[]=$Language->getText('tracker','submitter');
140 $order_name_arr[]=$Language->getText('tracker','assignee');
144 $order_arr[]='artifact_id';
145 $order_arr[]='priority';
146 $order_arr[]='summary';
147 $order_arr[]='open_date';
148 $order_arr[]='close_date';
149 $order_arr[]='submitted_by';
150 $order_arr[]='assigned_to';
153 // custom sort arrays to build pop-up box
155 $sort_name_arr=array();
156 $sort_name_arr[]=$Language->getText('tracker_browse','ascending');
157 $sort_name_arr[]=$Language->getText('tracker_browse','descending');
164 // custom changed arrays to build pop-up box
166 $changed_name_arr=array();
167 $changed_name_arr[]=$Language->getText('tracker_browse','changed_any');
168 $changed_name_arr[]=$Language->getText('tracker_browse','hour24');
169 $changed_name_arr[]=$Language->getText('tracker_browse','day7');
170 $changed_name_arr[]=$Language->getText('tracker_browse','week2');
171 $changed_name_arr[]=$Language->getText('tracker_browse','month1');
173 $changed_arr=array();
174 $changed_arr[]= 0x7fffffff; // Any
175 $changed_arr[]= 3600 * 24; // 24 hour
176 $changed_arr[]= 3600 * 24 * 7; // 1 week
177 $changed_arr[]= 3600 * 24 * 14;// 2 week
178 $changed_arr[]= 3600 * 24 * 30;// 1 month
181 // statuses can be custom in GForge 4.5+
183 if ($ath->usesCustomStatuses()) {
184 $aux_extra_fields = array();
185 if (is_array($_extra_fields)){
186 $keys=array_keys($_extra_fields);
187 foreach ($keys as $key) {
188 if (!is_array($_extra_fields[$key])) {
189 $aux_extra_fields[$key] = $_extra_fields[$key];
193 $aux_extra_fields = $_extra_fields;
195 $status_box=$ath->renderSelect ($ath->getCustomStatusField(),$aux_extra_fields[$ath->getCustomStatusField()],false,'',true,$Language->getText('tracker','status_any'));
197 if (is_array($_status)) {
200 $status_box = $ath->statusBox('_status',$_status,true,$Language->getText('tracker','status_any'));
203 <table width="100%" border="0">';
208 Logged in users get the option of seeing a power-browse box
210 if (session_loggedin()) {
211 echo '<td rowspan="2">';
212 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">';
213 echo '<input type="hidden" name="power_query" value="1">';
214 $res=db_query("SELECT artifact_query_id,query_name
215 FROM artifact_query WHERE user_id='".user_getid()."' AND group_artifact_id='".$ath->getID()."'");
217 if (db_numrows($res)>0) {
219 html_build_select_box($res,'query_id',$af->getDefaultQuery(),false).'<br />
220 <input type="submit" name="run" value="'.$Language->getText('tracker','run_query').'"></input>
221 <strong><a href="javascript:admin_window('.$GLOBALS['sys_urlprefix'].'\'/tracker/?func=query&group_id='.$group_id.'&atid='. $ath->getID().'\')">'.
222 $Language->getText('tracker','build_query').'</a></strong>';
225 <a href="javascript:admin_window('.$GLOBALS['sys_urlprefix'].'\'/tracker/?func=query&group_id='.$group_id.'&atid='. $ath->getID().'\')">'.$Language->getText('tracker','build_query').'</a></strong>';
232 <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">
233 <input type="hidden" name="set" value="custom" />
234 <td>'.$Language->getText('tracker','assignee').': <br />'. $tech_box .'</td>'.
235 '<td>'.$Language->getText('tracker','status').': <br />'. $status_box .'</td>';
239 <input type="hidden" name="query_id" value="-1">';
243 <td align="right">'.$Language->getText('tracker_browse','sort_by').': <a href="javascript:help_window('.$GLOBALS['sys_urlprefix'].'\'/help/tracker.php?helpname=sort_by\')"><strong>(?)</strong></a></span></td>'.
245 html_build_select_box_from_arrays($order_arr,$order_name_arr,'_sort_col',$_sort_col,false) .
246 html_build_select_box_from_arrays($sort_arr,$sort_name_arr,'_sort_ord',$_sort_ord,false) .
247 '<input type="submit" name="submit" value="'.$Language->getText('tracker','quickbrowse').'" /></span></td>
256 * Show the free-form text submitted by the project admin
258 echo $ath->getBrowseInstructions();
260 if ($art_arr && count($art_arr) > 0) {
262 if ($set=='custom') {
263 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status.'&extra_fields['.$ath->getCustomStatusField().']='.$extra_fields[$ath->getCustomStatusField()].'&_sort_col='.$_sort_col.'&_sort_ord='.$_sort_ord;
267 $IS_ADMIN=$ath->userIsAdmin();
271 <form name="artifactList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" METHOD="POST">
272 <input type="hidden" name="form_key" value="'.form_generate_key().'">
273 <input type="hidden" name="func" value="massupdate">';
276 $display_col=array('summary'=>1,
284 $title_arr[]=$Language->getText('tracker','id');
285 if ($display_col['summary'])
286 $title_arr[]=$Language->getText('tracker','summary');
287 if ($display_col['open_date'])
288 $title_arr[]=$Language->getText('tracker','open_date');
289 if ($display_col['status'])
290 $title_arr[]=$Language->getText('tracker','status');
291 if ($display_col['priority'])
292 $title_arr[]=$Language->getText('tracker','priority');
293 if ($display_col['assigned_to'])
294 $title_arr[]=$Language->getText('tracker','assigned_to');
295 if ($display_col['submitted_by'])
296 $title_arr[]=$Language->getText('tracker','submitted_by');
299 echo $GLOBALS['HTML']->listTableTop ($title_arr);
301 $then=(time()-$ath->getDuePeriod());
303 if (!isset($_GET['start'])) {
306 $start=$_GET['start'];
308 $max = ((count($art_arr) > ($start + 25)) ? ($start+25) : count($art_arr) );
310 for ($i=$start; $i<$max; $i++) {
312 <tr '. $HTML->boxGetAltRowStyle($i) . '>'.
314 ($IS_ADMIN?'<input type="CHECKBOX" name="artifact_id_list[]" value="'.
315 $art_arr[$i]->getID() .'"> ':'').
316 $art_arr[$i]->getID() .
318 if ($display_col['summary'])
319 echo '<td><a href="'.getStringFromServer('PHP_SELF').'?func=detail&aid='.
320 $art_arr[$i]->getID() .
321 '&group_id='. $group_id .'&atid='.
323 $art_arr[$i]->getSummary().
325 if ($display_col['open_date'])
326 echo '<td>'. (($set != 'closed' && $art_arr[$i]->getOpenDate() < $then)?'* ':' ') .
327 date($sys_datefmt,$art_arr[$i]->getOpenDate()) .'</td>';
328 if ($display_col['status'])
329 echo '<td>'. $art_arr[$i]->getStatusName() .'</td>';
330 if ($display_col['priority'])
331 echo '<td class="priority'.$art_arr[$i]->getPriority() .'">'. $art_arr[$i]->getPriority() .'</td>';
332 if ($display_col['assigned_to'])
333 echo '<td>'. $art_arr[$i]->getAssignedRealName() .'</td>';
334 if ($display_col['submitted_by'])
335 echo '<td>'. $art_arr[$i]->getSubmittedRealName() .'</td>';
340 Show extra rows for <-- Prev / Next -->
342 //only show this if we�re not using a power query
343 if ($af->max_rows > 0) {
344 if (($offset > 0) || ($rows >= 50)) {
346 <tr><td colspan="2">';
348 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
349 $set.'&offset='.($offset-50).'"><strong><-- '.$Language->getText('tracker_browse','previous').'</strong></a>';
353 echo '</td><td> </td><td colspan="2">';
355 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
356 $set.'&offset='.($offset+50).'"><strong>'.$Language->getText('tracker_browse','next').' --></strong></a>';
364 echo $GLOBALS['HTML']->listTableBottom();
365 $pages = count($art_arr) / 25;
366 $currentpage = intval($start / 25);
367 //echo "Item Count: ".count($arr)."Pages: $pages";
368 $skipped_pages=false;
369 for ($j=0; $j<$pages; $j++) {
371 if ((($j > 4) && ($j < ($currentpage-5))) || (($j > ($currentpage+5)) && ($j < ($pages-5)))) {
372 if (!$skipped_pages) {
378 $skipped_pages=false;
381 if ($j == $currentpage) {
382 echo '<strong>'.($j+1).'</strong> ';
384 echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&group_id=".$group_id.'&atid='.$ath->getID().'&set='. $set.'&start='.($j*25).'"><strong>'.($j+1).'</strong></a> ';
392 echo '<script language="JavaScript">
394 function checkAll(val) {
395 al=document.artifactList;
396 len = al.elements.length;
398 for( i=0 ; i<len ; i++) {
399 if (al.elements[i].name==\'artifact_id_list[]\') {
400 al.elements[i].checked=val;
407 <table width="100%" border="0">
410 <a href="javascript:checkAll(1)">'.$Language->getText('tracker_browse','check_all').'</a>
412 <a href="javascript:checkAll(0)">'.$Language->getText('tracker_browse','clear_all').'</a>
415 <span class="important">'.$Language->getText('tracker_browse','admin_mass_update').'
420 // build custom fields
422 $ef =& $ath->getExtraFields(ARTIFACT_EXTRAFIELD_FILTER_INT);
423 $keys=array_keys($ef);
426 for ($i=0; $i<count($keys); $i++) {
427 if (($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) || ($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)) {
428 $sel[$keys[$i]]=array('100');
430 $sel[$keys[$i]]='100';
433 $ath->renderExtraFields($sel,true,$Language->getText('tracker_browse','no_change'),false,'',ARTIFACT_EXTRAFIELD_FILTER_INT,true);
435 <td><strong>'.$Language->getText('tracker','priority').': <a href="javascript:help_window(\'/help/tracker.php?helpname=priority\')"><strong>(?)</strong></a>
437 echo build_priority_select_box ('priority', '100', true);
444 <td><strong>'.$Language->getText('tracker','assigned_to').': <a href="javascript:help_window(\'/help/tracker.php?helpname=assignee\')"><strong>(?)</strong></a>
445 </strong><br />'. $ath->technicianBox ('assigned_to','100.1',true,$Language->getText('tracker_artifacttype','nobody'),'100.1',$Language->getText('tracker_browse','no_change')) .'</td>
447 if (!$ath->usesCustomStatuses()) {
448 echo '<strong>'.$Language->getText('tracker','status').': <a href="javascript:help_window(\'/help/tracker.php?helpname=status\')"><strong>(?)</strong></a></strong>
449 <br />'. $ath->statusBox ('status_id','xzxz',true,$Language->getText('tracker_browse','no_change'));
454 <tr><td colspan="2"><strong>'.$Language->getText('tracker_browse','canned_response').':
455 <a href="javascript:help_window(\'/help/tracker.php?helpname=canned_response\')"><strong>(?)</strong></a>
456 </strong><br />'. $ath->cannedResponseBox ('canned_response') .'</td></tr>
458 <tr><td colspan="3" align="MIDDLE"><input type="SUBMIT" name="submit" value="'.$Language->getText('tracker_browse','mass_update').'"></td></tr>
464 echo $Language->getText('tracker_browse','old_requests',array(($ath->getDuePeriod()/86400) ));
465 show_priority_colors_key();
470 <h1>'.$Language->getText('tracker_browse','no_items').'</h1>';
472 //echo "<!-- $sql -->";
476 $ath->footer(array());