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 $gfcommon.'tracker/ArtifactFactory.class.php';
12 require_once $gfcommon.'tracker/ArtifactQuery.class.php';
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 $_extra_fields = array() ;
65 $aux_extra_fields = array() ;
66 if ($set == 'custom') {
68 //may be past in next/prev url
70 if (isset($_GET['extra_fields'][$ath->getCustomStatusField()])) {
71 $_extra_fields[$ath->getCustomStatusField()] = $_GET['extra_fields'][$ath->getCustomStatusField()];
72 } elseif (isset($_POST['extra_fields'][$ath->getCustomStatusField()])) {
73 $_extra_fields[$ath->getCustomStatusField()] = $_POST['extra_fields'][$ath->getCustomStatusField()];
77 if (is_array($_extra_fields)){
78 $keys=array_keys($_extra_fields);
79 foreach ($keys as $key) {
80 if ($_extra_fields[$key] != 'Array') {
81 $aux_extra_fields[$key] = $_extra_fields[$key];
85 if (isset($_extra_fields)){
86 $aux_extra_fields = $_extra_fields;
88 $aux_extra_fields = '';
92 $af->setup($offset,$_sort_col,$_sort_ord,null,$set,$_assigned_to,$_status,$aux_extra_fields);
94 // These vals are sanitized and/or retrieved from ArtifactFactory stored settings
96 $_sort_col=$af->order_col;
99 $_assigned_to=$af->assigned_to;
100 $_extra_fields=$af->extra_fields;
102 $art_arr =& $af->getArtifacts();
104 if (!$art_arr && $af->isError()) {
105 exit_error('Error',$af->getErrorMessage());
108 //build page title to make bookmarking easier
109 //if a user was selected, add the user_name to the title
111 $ath->header(array('atid'=>$ath->getID()));
115 * Build the powerful browsing options pop-up boxes
120 // creating a custom technician box which includes "any" and "unassigned"
122 $res_tech= $ath->getTechnicians();
124 $tech_id_arr=util_result_column_to_array($res_tech,0);
125 $tech_id_arr[]='0'; //this will be the 'any' row
127 $tech_name_arr=util_result_column_to_array($res_tech,1);
128 $tech_name_arr[]=_('Any');
130 if (is_array($_assigned_to)) {
133 $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,_('Unassigned'));
137 // custom order by arrays to build a pop-up box
139 $order_name_arr=array();
140 $order_name_arr[]=_('ID');
141 $order_name_arr[]=_('Priority');
142 $order_name_arr[]=_('Summary');
143 $order_name_arr[]=_('Open Date');
144 $order_name_arr[]=_('Close Date');
145 $order_name_arr[]=_('Submitter');
146 $order_name_arr[]=_('Assignee');
150 $order_arr[]='artifact_id';
151 $order_arr[]='priority';
152 $order_arr[]='summary';
153 $order_arr[]='open_date';
154 $order_arr[]='close_date';
155 $order_arr[]='submitted_by';
156 $order_arr[]='assigned_to';
159 // custom sort arrays to build pop-up box
161 $sort_name_arr=array();
162 $sort_name_arr[]=_('Ascending');
163 $sort_name_arr[]=_('Descending');
170 // custom changed arrays to build pop-up box
172 $changed_name_arr=array();
173 $changed_name_arr[]=_('Any changes');
174 $changed_name_arr[]=_('Last 24H');
175 $changed_name_arr[]=_('Last 7days');
176 $changed_name_arr[]=_('Last 2weeks');
177 $changed_name_arr[]=_('Last 1month');
179 $changed_arr=array();
180 $changed_arr[]= 0x7fffffff; // Any
181 $changed_arr[]= 3600 * 24; // 24 hour
182 $changed_arr[]= 3600 * 24 * 7; // 1 week
183 $changed_arr[]= 3600 * 24 * 14;// 2 week
184 $changed_arr[]= 3600 * 24 * 30;// 1 month
187 // statuses can be custom in GForge 4.5+
189 if ($ath->usesCustomStatuses()) {
190 $aux_extra_fields = array();
191 if (is_array($_extra_fields)){
192 $keys=array_keys($_extra_fields);
193 foreach ($keys as $key) {
194 if (!is_array($_extra_fields[$key])) {
195 $aux_extra_fields[$key] = $_extra_fields[$key];
199 $aux_extra_fields = $_extra_fields;
201 $status_box=$ath->renderSelect ($ath->getCustomStatusField(),$aux_extra_fields[$ath->getCustomStatusField()],false,'',true,_('Any'));
203 if (is_array($_status)) {
206 $status_box = $ath->statusBox('_status',$_status,true,_('Any'));
209 <table width="100%" border="0">';
214 Logged in users get the option of seeing a power-browse box
216 if (session_loggedin()) {
217 echo '<td rowspan="2">';
218 echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">';
219 echo '<input type="hidden" name="power_query" value="1">';
220 $res=db_query("SELECT artifact_query_id,query_name
221 FROM artifact_query WHERE user_id='".user_getid()."' AND group_artifact_id='".$ath->getID()."'");
223 if (db_numrows($res)>0) {
225 html_build_select_box($res,'query_id',$af->getDefaultQuery(),false).'<br />
226 <input type="submit" name="run" value="'._('Power Query').'"></input>
227 <strong><a href="javascript:admin_window(\''.util_make_url ('/tracker/?func=query&group_id='.$group_id.'&atid='.$ath->getID()).'\')">'.
228 _('Build Query').'</a></strong>';
231 <a href="javascript:admin_window(\''.util_make_url ('/tracker/?func=query&group_id='.$group_id.'&atid='.$ath->getID()).'\')">'._('Build Query').'</a></strong>';
238 <form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" method="post">
239 <input type="hidden" name="set" value="custom" />
240 <td>'._('Assignee').'<br />'. $tech_box .'</td>'.
241 '<td>'._('Status').'<br />'. $status_box .'</td>';
245 <input type="hidden" name="query_id" value="-1">';
249 <td align="right">'._('Order by').' <a href="javascript:help_window(\''.util_make_url ('/help/tracker.php?helpname=sort_by').'\')"><strong>(?)</strong></a></span></td>'.
251 html_build_select_box_from_arrays($order_arr,$order_name_arr,'_sort_col',$_sort_col,false) .
252 html_build_select_box_from_arrays($sort_arr,$sort_name_arr,'_sort_ord',$_sort_ord,false) .
253 '<input type="submit" name="submit" value="'._('Quick Browse').'" /></span></td>
262 * Show the free-form text submitted by the project admin
264 echo $ath->getBrowseInstructions();
266 if ($art_arr && count($art_arr) > 0) {
268 if ($set=='custom') {
269 $set .= '&_assigned_to='.$_assigned_to.'&_status='.$_status.'&extra_fields['.$ath->getCustomStatusField().']='.$_extra_fields[$ath->getCustomStatusField()].'&_sort_col='.$_sort_col.'&_sort_ord='.$_sort_ord;
273 $IS_ADMIN=$ath->userIsAdmin();
277 <form name="artifactList" action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&atid='.$ath->getID().'" METHOD="POST">
278 <input type="hidden" name="form_key" value="'.form_generate_key().'">
279 <input type="hidden" name="func" value="massupdate">';
282 $display_col=array('summary'=>1,
290 $title_arr[]=_('ID');
291 if ($display_col['summary'])
292 $title_arr[]=_('Summary');
293 if ($display_col['open_date'])
294 $title_arr[]=_('Open Date');
295 if ($display_col['status'])
296 $title_arr[]=_('State');
297 if ($display_col['priority'])
298 $title_arr[]=_('Priority');
299 if ($display_col['assigned_to'])
300 $title_arr[]=_('Assigned to');
301 if ($display_col['submitted_by'])
302 $title_arr[]=_('Submitted by');
305 echo $GLOBALS['HTML']->listTableTop ($title_arr);
307 $then=(time()-$ath->getDuePeriod());
309 if (!isset($_GET['start'])) {
312 $start=$_GET['start'];
314 $max = ((count($art_arr) > ($start + 25)) ? ($start+25) : count($art_arr) );
316 for ($i=$start; $i<$max; $i++) {
318 <tr '. $HTML->boxGetAltRowStyle($i) . '>'.
320 ($IS_ADMIN?'<input type="CHECKBOX" name="artifact_id_list[]" value="'.
321 $art_arr[$i]->getID() .'"> ':'').
322 $art_arr[$i]->getID() .
324 if ($display_col['summary'])
325 echo '<td><a href="'.getStringFromServer('PHP_SELF').'?func=detail&aid='.
326 $art_arr[$i]->getID() .
327 '&group_id='. $group_id .'&atid='.
329 $art_arr[$i]->getSummary().
331 if ($display_col['open_date'])
332 echo '<td>'. (($set != 'closed' && $art_arr[$i]->getOpenDate() < $then)?'* ':' ') .
333 date(_('Y-m-d H:i'),$art_arr[$i]->getOpenDate()) .'</td>';
334 if ($display_col['status'])
335 echo '<td>'. $art_arr[$i]->getStatusName() .'</td>';
336 if ($display_col['priority'])
337 echo '<td class="priority'.$art_arr[$i]->getPriority() .'">'. $art_arr[$i]->getPriority() .'</td>';
338 if ($display_col['assigned_to'])
339 echo '<td>'. $art_arr[$i]->getAssignedRealName() .'</td>';
340 if ($display_col['submitted_by'])
341 echo '<td>'. $art_arr[$i]->getSubmittedRealName() .'</td>';
346 Show extra rows for <-- Prev / Next -->
348 //only show this if we�re not using a power query
349 if ($af->max_rows > 0) {
350 if (($offset > 0) || ($rows >= 50)) {
352 <tr><td colspan="2">';
354 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
355 $set.'&offset='.($offset-50).'"><strong><-- '._('Previous 50').'</strong></a>';
359 echo '</td><td> </td><td colspan="2">';
361 echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&group_id='.$group_id.'&atid='.$ath->getID().'&set='.
362 $set.'&offset='.($offset+50).'"><strong>'._('Next 50').' --></strong></a>';
370 echo $GLOBALS['HTML']->listTableBottom();
371 $pages = count($art_arr) / 25;
372 $currentpage = intval($start / 25);
373 //echo "Item Count: ".count($arr)."Pages: $pages";
374 $skipped_pages=false;
375 for ($j=0; $j<$pages; $j++) {
377 if ((($j > 4) && ($j < ($currentpage-5))) || (($j > ($currentpage+5)) && ($j < ($pages-5)))) {
378 if (!$skipped_pages) {
384 $skipped_pages=false;
387 if ($j == $currentpage) {
388 echo '<strong>'.($j+1).'</strong> ';
390 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> ';
398 echo '<script language="JavaScript">
400 function checkAll(val) {
401 al=document.artifactList;
402 len = al.elements.length;
404 for( i=0 ; i<len ; i++) {
405 if (al.elements[i].name==\'artifact_id_list[]\') {
406 al.elements[i].checked=val;
413 <table width="100%" border="0">
416 <a href="javascript:checkAll(1)">'._('Check all').'</a>
418 <a href="javascript:checkAll(0)">'._('Clear all').'</a>
421 <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".').'
426 // build custom fields
428 $ef =& $ath->getExtraFields(ARTIFACT_EXTRAFIELD_FILTER_INT);
429 $keys=array_keys($ef);
432 for ($i=0; $i<count($keys); $i++) {
433 if (($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) || ($ef[$keys[$i]]['field_type']==ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)) {
434 $sel[$keys[$i]]=array('100');
436 $sel[$keys[$i]]='100';
439 $ath->renderExtraFields($sel,true,_('No Change'),false,'',ARTIFACT_EXTRAFIELD_FILTER_INT,true);
441 <td><strong>'._('Priority').': <a href="javascript:help_window(\'/help/tracker.php?helpname=priority\')"><strong>(?)</strong></a>
443 echo build_priority_select_box ('priority', '100', true);
450 <td><strong>'._('Assigned to').': <a href="javascript:help_window(\'/help/tracker.php?helpname=assignee\')"><strong>(?)</strong></a>
451 </strong><br />'. $ath->technicianBox ('assigned_to','100.1',true,_('Nobody'),'100.1',_('No Change')) .'</td>
453 if (!$ath->usesCustomStatuses()) {
454 echo '<strong>'._('State').': <a href="javascript:help_window(\'/help/tracker.php?helpname=status\')"><strong>(?)</strong></a></strong>
455 <br />'. $ath->statusBox ('status_id','xzxz',true,_('No Change'));
460 <tr><td colspan="2"><strong>'._('Canned Response').':
461 <a href="javascript:help_window(\'/help/tracker.php?helpname=canned_response\')"><strong>(?)</strong></a>
462 </strong><br />'. $ath->cannedResponseBox ('canned_response') .'</td></tr>
464 <tr><td colspan="3" align="MIDDLE"><input type="SUBMIT" name="submit" value="'._('Mass update').'"></td></tr>
470 printf(_('* Denotes requests > %1$s Days Old'), ($ath->getDuePeriod()/86400));
471 show_priority_colors_key();
476 <h1>'._('No items found').'</h1>';
478 //echo "<!-- $sql -->";
482 $ath->footer(array());
486 // c-file-style: "bsd"