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
10 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
11 require_once $gfcommon.'tracker/ArtifactQuery.class.php';
13 // make sure this person has permission to view artifacts
15 if (!$ath->userCanView()) {
16 exit_permission_denied();
19 $query_id = getIntFromRequest('query_id');
22 // The browse page can be powered by a pre-saved query
23 // or by select boxes chosen by the user
25 // If there is a $query_id coming from the request OR the pref
26 // was already saved, use the artifact factory that way.
28 // If the query_id = -1, unset the pref and use regular browse boxes
30 if (session_loggedin()) {
32 if ($query_id == '-1') {
33 $u =& session_get_user();
34 $u->setPreference('art_query'.$ath->getID(),'');
36 $aq = new ArtifactQuery($ath,$query_id);
37 if (!$aq || !is_object($aq)) {
38 exit_error('Error',$aq->getErrorMessage());
43 $u =& session_get_user();
44 $query_id=$u->getPreference('art_query'.$ath->getID(),'');
46 } elseif ($query_id) {
47 // If user is not logged, then use a cookie to store the current query.
48 if (isset($_COOKIE["GFTrackerQuery"])) {
49 $gf_tracker = unserialize($_COOKIE["GFTrackerQuery"]);
51 $gf_tracker = array();
53 $gf_tracker[$ath->getID()] = $query_id;
54 // Send the query_id as a cookie to save it.
55 setcookie("GFTrackerQuery", serialize($gf_tracker));
56 $_COOKIE["GFTrackerQuery"] = serialize($gf_tracker);
57 } elseif (isset($_COOKIE["GFTrackerQuery"])) {
58 $gf_tracker = unserialize($_COOKIE["GFTrackerQuery"]);
59 $query_id = (int)$gf_tracker[$ath->getID()];
62 $af = new ArtifactFactory($ath);
64 if (!$af || !is_object($af)) {
65 exit_error('Error','Could Not Get Factory');
66 } elseif ($af->isError()) {
67 exit_error('Error',$af->getErrorMessage());
70 if (!isset($_sort_col)) {
71 /* default sort order: highest priority first */
72 $_sort_col = 'priority';
75 $offset = getStringFromRequest('offset');
76 $_sort_col = getStringFromRequest('_sort_col',$_sort_col);
77 $_sort_ord = getStringFromRequest('_sort_ord',$_sort_ord);
78 $max_rows = getStringFromRequest('max_rows');
79 $set = getStringFromRequest('set');
80 $_assigned_to = getIntFromRequest('_assigned_to');
81 $_status = getIntFromRequest('_status');
82 $_extra_fields = array() ;
83 $aux_extra_fields = array() ;
84 if ($set == 'custom') {
86 //may be past in next/prev url
88 if (isset($_GET['extra_fields'][$ath->getCustomStatusField()])) {
89 $_extra_fields[$ath->getCustomStatusField()] = $_GET['extra_fields'][$ath->getCustomStatusField()];
90 } elseif (isset($_POST['extra_fields'][$ath->getCustomStatusField()])) {
91 $_extra_fields[$ath->getCustomStatusField()] = $_POST['extra_fields'][$ath->getCustomStatusField()];
95 if (is_array($_extra_fields)){
96 $keys=array_keys($_extra_fields);
97 foreach ($keys as $key) {
98 if ($_extra_fields[$key] != 'Array') {
99 $aux_extra_fields[$key] = $_extra_fields[$key];
103 if (isset($_extra_fields)){
104 $aux_extra_fields = $_extra_fields;
106 $aux_extra_fields = '';
110 $af->setup($offset,$_sort_col,$_sort_ord,null,$set,$_assigned_to,$_status,$aux_extra_fields);
112 // These vals are sanitized and/or retrieved from ArtifactFactory stored settings
114 $_sort_col=$af->order_col;
115 $_sort_ord=$af->sort;
116 $_status=$af->status;
117 $_assigned_to=$af->assigned_to;
118 $_extra_fields=$af->extra_fields;
120 $art_arr =& $af->getArtifacts();
122 if (!$art_arr && $af->isError()) {
123 exit_error('Error',$af->getErrorMessage());
126 //build page title to make bookmarking easier
127 //if a user was selected, add the user_name to the title
129 $ath->header(array('atid'=>$ath->getID()));
133 * Build the powerful browsing options pop-up boxes
138 // creating a custom technician box which includes "any" and "unassigned"
140 $res_tech= $ath->getTechnicians();
142 $tech_id_arr=util_result_column_to_array($res_tech,0);
143 $tech_id_arr[]='0'; //this will be the 'any' row
145 $tech_name_arr=util_result_column_to_array($res_tech,1);
146 $tech_name_arr[]=_('Any');
148 if (is_array($_assigned_to)) {
151 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,_('Unassigned'));
155 // custom order by arrays to build a pop-up box
157 $order_name_arr=array();
158 $order_name_arr[]=_('ID');
159 $order_name_arr[]=_('Priority');
160 $order_name_arr[]=_('Summary');
161 $order_name_arr[]=_('Open Date');
162 $order_name_arr[]=_('Close Date');
163 $order_name_arr[]=_('Submitter');
164 $order_name_arr[]=_('Assignee');
168 $order_arr[]='artifact_id';
169 $order_arr[]='priority';
170 $order_arr[]='summary';
171 $order_arr[]='open_date';
172 $order_arr[]='close_date';
173 $order_arr[]='submitted_by';
174 $order_arr[]='assigned_to';
177 // custom sort arrays to build pop-up box
179 $sort_name_arr=array();
180 $sort_name_arr[]=_('Ascending');
181 $sort_name_arr[]=_('Descending');
188 // custom changed arrays to build pop-up box
190 $changed_name_arr=array();
191 $changed_name_arr[]=_('Any changes');
192 $changed_name_arr[]=_('Last 24H');
193 $changed_name_arr[]=_('Last 7days');
194 $changed_name_arr[]=_('Last 2weeks');
195 $changed_name_arr[]=_('Last 1month');
197 $changed_arr=array();
198 $changed_arr[]= 0x7fffffff; // Any
199 $changed_arr[]= 3600 * 24; // 24 hour
200 $changed_arr[]= 3600 * 24 * 7; // 1 week
201 $changed_arr[]= 3600 * 24 * 14;// 2 week
202 $changed_arr[]= 3600 * 24 * 30;// 1 month
206 * Show the free-form text submitted by the project admin
208 echo $ath->renderBrowseInstructions();
211 // statuses can be custom in GForge 4.5+
213 if ($ath->usesCustomStatuses()) {
214 $aux_extra_fields = array();
215 if (is_array($_extra_fields)){
216 $keys=array_keys($_extra_fields);
217 foreach ($keys as $key) {
218 if (!is_array($_extra_fields[$key])) {
219 $aux_extra_fields[$key] = $_extra_fields[$key];
223 $aux_extra_fields = $_extra_fields;
225 $status_box=$ath->renderSelect ($ath->getCustomStatusField(),$aux_extra_fields[$ath->getCustomStatusField()],false,'',true,_('Any'));
227 if (is_array($_status)) {
230 $status_box = $ath->statusBox('_status',$_status,true,_('Any'));
232 echo '<script type="text/javascript" src="/tabber/tabber.js"></script>'."\n";
234 <div id="tabber" class="tabber">
235 <div class="tabbertab" title="'._('Advanced queries').'">';
237 if (session_loggedin()) {
238 $res = db_query_params ('SELECT artifact_query_id,query_name, CASE WHEN query_type>0 THEN 1 ELSE 0 END as type
240 WHERE group_artifact_id=$1 AND (user_id=$2 OR query_type>0)
241 ORDER BY type ASC, query_name ASC',
242 array ($ath->getID(),
245 $res = db_query_params ('SELECT artifact_query_id,query_name, CASE WHEN query_type>0 THEN 1 ELSE 0 END as type
247 WHERE group_artifact_id=$1 AND query_type>0
248 ORDER BY type ASC, query_name ASC',
249 array ($ath->getID()));
253 if (db_numrows($res)>0) {
254 echo '<form action="'. getStringFromServer('PHP_SELF') .'" method="get">';
255 echo '<input type="hidden" name="group_id" value="'.$group_id.'" />';
256 echo '<input type="hidden" name="atid" value="'.$ath->getID().'" />';
257 echo '<input type="hidden" name="power_query" value="1" />';
258 echo ' <table width="100%" cellspacing="0">
262 $optgroup['key'] = 'type';
263 $optgroup['values'][0] = 'Private queries';
264 $optgroup['values'][1] = 'Project queries';
265 echo '<span style="font-size:smaller">';
266 echo '<select name="query_id">';
267 echo '<option value="100">Select One</option>';
269 $selected = $af->getDefaultQuery();
270 while ($row = db_fetch_array($res)) {
271 if ($current != $row['type']) {
274 $label = $row['type'] ? 'Project' : 'Private';
275 echo '<optgroup label="'.$label.'">';
276 $current = $row['type'];
278 echo '<option value="'.$row['artifact_query_id'].'"';
279 if ($row['artifact_query_id'] == $selected)
280 echo ' selected="selected"';
281 echo '>'. $row['query_name'] .'</option>'."\n";
287 <input type="submit" name="run" value="'._('Power Query').'" />
288 <a href="/tracker/?atid='. $ath->getID().'&group_id='.$group_id.'&func=query">'.
289 _('Build Query').'</a>
294 <a href="/tracker/?atid='. $ath->getID().'&group_id='.$group_id.'&func=query">'._('Build Query').'</a></strong>';
298 <div class="tabbertab'.($af->query_type == 'custom' ? ' tabbertabdefault' : '').'" title="'._('Simple Filtering and Sorting').'">
299 <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">
300 <input type="hidden" name="query_id" value="-1" />
301 <input type="hidden" name="set" value="custom" />
302 <table width="100%" cellspacing="0">
305 '._('Assignee').': '. $tech_box .'
308 '._('State').': '. $status_box .'
313 ': <a href="javascript:help_window(\'/help/tracker.php?helpname=sort_by\')">' .
314 '<strong>(?)</strong></a>'.
315 html_build_select_box_from_arrays($order_arr,$order_name_arr,'_sort_col',$_sort_col,false) .
316 html_build_select_box_from_arrays($sort_arr,$sort_name_arr,'_sort_ord',$_sort_ord,false) .
317 '<input type="submit" name="submit" value="'._('Quick Browse').'" />';
325 if ($af->query_type == 'default') {
326 echo '<div class="tabbertab tabbertabdefault" title="'._('Default').'">';
327 echo '<strong>'._('Viewing only opened records by default, use \'Advanced queries\' or \'Simple Filtering and Sorting\' to change.').'</strong>';
333 if ($art_arr && count($art_arr) > 0) {
335 if ($set=='custom') {
336 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status.'&_sort_col='.$_sort_col.'&_sort_ord='.$_sort_ord;
337 if (array_key_exists($ath->getCustomStatusField(),$_extra_fields)) {
338 $set .= '&extra_fields['.$ath->getCustomStatusField().']='.$_extra_fields[$ath->getCustomStatusField()];
343 $IS_ADMIN=$ath->userIsAdmin();
347 <form name="artifactList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">
348 <input type="hidden" name="form_key" value="'.form_generate_key().'" />
349 <input type="hidden" name="func" value="massupdate" />';
352 $browse_fields = explode(',', "id,".$ath->getBrowseList());
354 foreach ($browse_fields as $f) {
356 if (intval($f) > 0) {
357 $title = $ath->getExtraFieldName($f);
364 $title=_('Description');
365 if ($f == 'open_date')
366 $title=_('Open Date');
367 if ($f == 'close_date')
368 $title=_('Close Date');
369 if ($f == 'status_id')
371 if ($f == 'priority')
372 $title=_('Priority');
373 if ($f == 'assigned_to')
374 $title=_('Assigned to');
375 if ($f == 'submitted_by')
376 $title=_('Submitted by');
378 $title_arr[] = $title;
381 echo $GLOBALS['HTML']->listTableTop ($title_arr);
383 $then=(time()-$ath->getDuePeriod());
385 if (!isset($_GET['start'])) {
388 $start=$_GET['start'];
390 $max = ((count($art_arr) > ($start + 25)) ? ($start+25) : count($art_arr) );
392 for ($i=$start; $i<$max; $i++) {
393 $extra_data = $art_arr[$i]->getExtraFieldDataText();
395 <tr '. $HTML->boxGetAltRowStyle($i) . '>';
396 foreach ($browse_fields as $f) {
398 echo '<td style="white-space: nowrap;">'.
399 ($IS_ADMIN?'<input type="checkbox" name="artifact_id_list[]" value="'.
400 $art_arr[$i]->getID() .'" /> ':'').
401 '<a href="'.getStringFromServer('PHP_SELF').'?func=detail&aid='.
402 $art_arr[$i]->getID() .
403 '&group_id='. $group_id .'&atid='.
404 $ath->getID().'">'.$art_arr[$i]->getID() .
406 } else if ($f == 'summary') {
407 echo '<td><a href="'.getStringFromServer('PHP_SELF').'?func=detail&aid='.
408 $art_arr[$i]->getID() .
409 '&group_id='. $group_id .'&atid='.
411 $art_arr[$i]->getSummary().
413 } else if ($f == 'open_date') {
414 echo '<td>'. (($set != 'closed' && $art_arr[$i]->getOpenDate() < $then)?'* ':' ') .
415 date(_('Y-m-d H:i'),$art_arr[$i]->getOpenDate()) .'</td>';
416 } else if ($f == 'status_id') {
417 echo '<td>'. $art_arr[$i]->getStatusName() .'</td>';
418 } else if ($f == 'priority') {
419 echo '<td class="priority'.$art_arr[$i]->getPriority() .'">'. $art_arr[$i]->getPriority() .'</td>';
420 } else if ($f == 'assigned_to') {
421 echo '<td>'. $art_arr[$i]->getAssignedRealName() .'</td>';
422 } else if ($f == 'submitted_by') {
423 echo '<td>'. $art_arr[$i]->getSubmittedRealName() .'</td>';
424 } else if ($f == 'close_date') {
425 echo '<td>'. ($art_arr[$i]->getCloseDate() ?
426 date(_('Y-m-d H:i'),$art_arr[$i]->getCloseDate()) :' ') .'</td>';
427 } else if ($f == 'details') {
428 echo '<td>'. $art_arr[$i]->getDetails() .'</td>';
429 } else if (intval($f) > 0) {
430 // Now display extra-fields (fields are numbers).
431 $value = $extra_data[$f]['value'];
432 if ($extra_data[$f]['type'] == 9) {
433 $value = preg_replace('/\b(\d+)\b/e', "_artifactid2url('\\1')", $value);
435 echo '<td>' . $value .'</td>';
437 // Display ? for unknown values.
445 Show extra rows for <-- Prev / Next -->
447 //only show this if we're not using a power query
448 if ($af->max_rows > 0) {
449 if (($offset > 0) || ($rows >= 50)) {
451 <tr><td colspan="2">';
453 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
454 $set.'&offset='.($offset-50).'"><strong><-- '._('Previous 50').'</strong></a>';
458 echo '</td><td> </td><td colspan="2">';
460 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
461 $set.'&offset='.($offset+50).'"><strong>'._('Next 50').' --></strong></a>';
469 echo $GLOBALS['HTML']->listTableBottom();
470 $pages = count($art_arr) / 25;
471 $currentpage = intval($start / 25);
472 //echo "Item Count: ".count($arr)."Pages: $pages";
474 $skipped_pages=false;
475 for ($j=0; $j<$pages; $j++) {
477 if ((($j > 4) && ($j < ($currentpage-5))) || (($j > ($currentpage+5)) && ($j < ($pages-5)))) {
478 if (!$skipped_pages) {
484 $skipped_pages=false;
487 if ($j == $currentpage) {
488 echo '<strong>'.($j+1).'</strong> ';
490 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> ';
499 echo '<script type="text/javascript">
501 function checkAll(val) {
502 al=document.artifactList;
503 len = al.elements.length;
505 for( i=0 ; i<len ; i++) {
506 if (al.elements[i].name==\'artifact_id_list[]\') {
507 al.elements[i].checked=val;
514 <table width="100%" border="0" id="admin_mass_update">
517 <a href="javascript:checkAll(1)">'._('Check all').'</a>
519 <a href="javascript:checkAll(0)">'._('Clear all').'</a>
522 <span class="important">'._('<strong>Admin:</strong> If you wish to apply changes to all items selected above, use these controls to change their properties and click once on "Mass Update".').'</span></p>
527 // build custom fields
529 $ef =& $ath->getExtraFields(ARTIFACT_EXTRAFIELD_FILTER_INT);
530 $keys=array_keys($ef);
533 for ($i=0; $i<count($keys); $i++) {
534 if (($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) || ($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)) {
535 $sel[$keys[$i]]=array('100');
537 $sel[$keys[$i]]='100';
540 $ath->renderExtraFields($sel,true,_('No Change'),false,'',ARTIFACT_EXTRAFIELD_FILTER_INT,true);
542 <td><strong>'._('Priority').': <a href="javascript:help_window(\'/help/tracker.php?helpname=priority\')"><strong>(?)</strong></a>
544 echo build_priority_select_box ('priority', '100', true);
551 <td><strong>'._('Assigned to').': <a href="javascript:help_window(\'/help/tracker.php?helpname=assignee\')"><strong>(?)</strong></a>
552 </strong><br />'. $ath->technicianBox ('assigned_to','100.1',true,_('Nobody'),'100.1',_('No Change')) .'</td>
554 if (!$ath->usesCustomStatuses()) {
555 echo '<strong>'._('State').': <a href="javascript:help_window(\'/help/tracker.php?helpname=status\')"><strong>(?)</strong></a></strong>
556 <br />'. $ath->statusBox ('status_id','xzxz',true,_('No Change'));
561 <tr><td colspan="2"><strong>'._('Canned Response').':
562 <a href="javascript:help_window(\'/help/tracker.php?helpname=canned_response\')"><strong>(?)</strong></a>
563 </strong><br />'. $ath->cannedResponseBox ('canned_response') .'</td></tr>
565 <tr><td colspan="3" align="center"><input type="submit" name="submit" value="'._('Mass update').'" /></td></tr>
570 printf(_('* Denotes requests > %1$s Days Old'), ($ath->getDuePeriod()/86400));
572 if (in_array('priority', $browse_fields)) {
573 show_priority_colors_key();
579 <h1>'._('No items found').'</h1>';
581 //echo "<!-- $sql -->";
585 $ath->footer(array());
589 // c-file-style: "bsd"