getID(), 'read') ; $query_id = getIntFromRequest('query_id'); $start = getIntFromRequest('start'); $paging = 0; // // The browse page can be powered by a pre-saved query // or by select boxes chosen by the user // // If there is a $query_id coming from the request OR the pref // was already saved, use the artifact factory that way. // // If the query_id = -1, unset the pref and use regular browse boxes // if (session_loggedin()) { $u =& session_get_user(); if (getStringFromRequest('setpaging')) { /* store paging preferences */ $paging = getIntFromRequest('nres'); if (!$paging) { $paging = 25; } $u->setPreference("paging", $paging); } if($query_id) { if ($query_id == '-1') { $u->setPreference('art_query'.$ath->getID(),''); } else { $aq = new ArtifactQuery($ath,$query_id); if (!$aq || !is_object($aq)) { exit_error($aq->getErrorMessage(),'tracker'); } $aq->makeDefault(); } } else { $query_id=$u->getPreference('art_query'.$ath->getID(),''); } } elseif ($query_id) { // If user is not logged, then use a cookie to store the current query. if (isset($_COOKIE["GFTrackerQuery"])) { $gf_tracker = unserialize($_COOKIE["GFTrackerQuery"]); } else { $gf_tracker = array(); } $gf_tracker[$ath->getID()] = $query_id; // Send the query_id as a cookie to save it. setcookie("GFTrackerQuery", serialize($gf_tracker)); $_COOKIE["GFTrackerQuery"] = serialize($gf_tracker); } elseif (isset($_COOKIE["GFTrackerQuery"])) { $gf_tracker = unserialize($_COOKIE["GFTrackerQuery"]); $query_id = (int)$gf_tracker[$ath->getID()]; } $af = new ArtifactFactory($ath); if (!$af || !is_object($af)) { exit_error(_('Could Not Get Factory'),'tracker'); } elseif ($af->isError()) { exit_error($af->getErrorMessage(),'tracker'); } if (!isset($_sort_col)) { /* default sort order: highest priority first */ $_sort_col = 'priority'; $_sort_ord = 'DESC'; } $offset = getStringFromRequest('offset'); $_sort_col = getStringFromRequest('_sort_col',$_sort_col); $_sort_ord = getStringFromRequest('_sort_ord',$_sort_ord); $max_rows = getIntFromRequest('max_rows', 25); $set = getStringFromRequest('set'); $_assigned_to = getIntFromRequest('_assigned_to'); $_status = getIntFromRequest('_status'); $_extra_fields = array() ; $aux_extra_fields = array() ; if ($set == 'custom') { /* may be past in next/prev url */ $i = $ath->getCustomStatusField(); $tmp_extra_fields = getArrayFromRequest('extra_fields'); if (isset($tmp_extra_fields[$i])) { $_extra_fields[$i] = $tmp_extra_fields[$i]; } } if (is_array($_extra_fields)){ $keys=array_keys($_extra_fields); foreach ($keys as $key) { if ($_extra_fields[$key] != 'Array') { $aux_extra_fields[$key] = $_extra_fields[$key]; } } } else { if (isset($_extra_fields)){ $aux_extra_fields = $_extra_fields; } else { $aux_extra_fields = ''; } } $af->setup($offset,$_sort_col,$_sort_ord,$paging,$set,$_assigned_to,$_status,$aux_extra_fields); // // These vals are sanitized and/or retrieved from ArtifactFactory stored settings // $_sort_col=$af->order_col; $_sort_ord=$af->sort; $_status=$af->status; $_assigned_to=$af->assigned_to; $_extra_fields=$af->extra_fields; $art_arr = $af->getArtifacts(); if (!$art_arr && $af->isError()) { exit_error($af->getErrorMessage(),'tracker'); } //build page title to make bookmarking easier //if a user was selected, add the user_name to the title //same for status use_javascript('/tabber/tabber.js'); $ath->header(array('atid'=>$ath->getID(), 'title'=>$ath->getName())); /** * * Build the powerful browsing options pop-up boxes * */ // // creating a custom technician box which includes "any" and "unassigned" // $engine = RBACEngine::getInstance () ; $techs = $engine->getUsersByAllowedAction ('tracker', $ath->getID(), 'tech') ; $tech_id_arr = array () ; $tech_name_arr = array () ; foreach ($techs as $tech) { $tech_id_arr[] = $tech->getID() ; $tech_name_arr[] = $tech->getRealName() ; } $tech_id_arr[]='0'; //this will be the 'any' row $tech_name_arr[]=_('Any'); if (is_array($_assigned_to)) { $_assigned_to=''; } $tech_box=html_build_select_box_from_arrays ($tech_id_arr,$tech_name_arr,'_assigned_to',$_assigned_to,true,_('Unassigned')); // // custom order by arrays to build a pop-up box // $order_name_arr=array(); $order_name_arr[]=_('ID'); $order_name_arr[]=_('Priority'); $order_name_arr[]=_('Summary'); $order_name_arr[]=_('Open Date'); $order_name_arr[]=_('Last Modified Date'); $order_name_arr[]=_('Close Date'); $order_name_arr[]=_('Submitter'); $order_name_arr[]=_('Assignee'); $order_arr=array(); $order_arr[]='artifact_id'; $order_arr[]='priority'; $order_arr[]='summary'; $order_arr[]='open_date'; $order_arr[]='last_modified_date'; $order_arr[]='close_date'; $order_arr[]='submitted_by'; $order_arr[]='assigned_to'; // // custom sort arrays to build pop-up box // $sort_name_arr=array(); $sort_name_arr[]=_('Ascending'); $sort_name_arr[]=_('Descending'); $sort_arr=array(); $sort_arr[]='ASC'; $sort_arr[]='DESC'; // // custom changed arrays to build pop-up box // $changed_name_arr=array(); $changed_name_arr[]=_('Any changes'); $changed_name_arr[]=_('Last 24H'); $changed_name_arr[]=_('Last 7days'); $changed_name_arr[]=_('Last 2weeks'); $changed_name_arr[]=_('Last 1month'); $changed_arr=array(); $changed_arr[]= 0x7fffffff; // Any $changed_arr[]= 3600 * 24; // 24 hour $changed_arr[]= 3600 * 24 * 7; // 1 week $changed_arr[]= 3600 * 24 * 14;// 2 week $changed_arr[]= 3600 * 24 * 30;// 1 month if ($art_arr && ($art_cnt = count($art_arr)) > 0) { $focus = getIntFromRequest('focus'); } else { $art_cnt = 0; $start = 0; $focus = 0; } $paging = 0; if (session_loggedin()) { /* logged in users get configurable paging */ $paging = $u->getPreference("paging"); echo '
'."\n"; } if (!$paging) { $paging = 25; } if ($art_cnt) { if ($focus) { for ($i = 0; $i < $art_cnt; ++$i) if ($art_arr[$i]->getID() == $focus) { $start = $i; break; } } $max = ($art_cnt > ($start + $paging)) ? ($start + $paging) : $art_cnt; } else { $max = 0; } printf('

' . _('Displaying results %1$d‒%2$d out of %3$d total.'), $start + 1, $max, $art_cnt); if (session_loggedin()) { printf(' ' . _('Displaying %2$s results.') . "\n\t' . "\n

\n
\n", _('Change'), html_build_select_box_from_array(array( '10', '25', '50', '100', '1000'), 'nres', $paging, 1)); } else { echo "

\n"; } /** * * Show the free-form text submitted by the project admin */ echo $ath->renderBrowseInstructions(); // // statuses can be custom in GForge 4.5+ // if ($ath->usesCustomStatuses()) { $aux_extra_fields = array(); if (is_array($_extra_fields)){ $keys=array_keys($_extra_fields); foreach ($keys as $key) { if (!is_array($_extra_fields[$key])) { $aux_extra_fields[$key] = $_extra_fields[$key]; } } } else { $aux_extra_fields = $_extra_fields; } $status_box=$ath->renderSelect ($ath->getCustomStatusField(),$aux_extra_fields[$ath->getCustomStatusField()],false,'',true,_('Any')); } else { if (is_array($_status)) { $_status=''; } $status_box = $ath->statusBox('_status',$_status,true,_('Any')); } // start of RDFa $proj_name = $group->getUnixName(); $proj_url = util_make_url_g($group->getUnixName(),$group_id); // the tracker's URIs are constructed in order to support addition of an OSLC-CM REST server // inside /tracker/cm/. There each tracker has a URL in the form .../project/PROJ_NAME/atid/ATID $tracker_stdzd_uri = util_make_url('/tracker/cm/project/'. $proj_name .'/atid/'. $ath->getID()); print '
'."\n"; print ''."\n"; print ''."\n"; print "
\n"; // end of about echo '
'; if (session_loggedin()) { $res = db_query_params ('SELECT artifact_query_id,query_name, CASE WHEN query_type>0 THEN 1 ELSE 0 END as type FROM artifact_query WHERE group_artifact_id=$1 AND (user_id=$2 OR query_type>0) ORDER BY type ASC, query_name ASC', array ($ath->getID(), user_getid())); } else { $res = db_query_params ('SELECT artifact_query_id,query_name, CASE WHEN query_type>0 THEN 1 ELSE 0 END as type FROM artifact_query WHERE group_artifact_id=$1 AND query_type>0 ORDER BY type ASC, query_name ASC', array ($ath->getID())); } if (db_numrows($res)>0) { echo '
'; echo ''; echo ''; echo ''; echo '
'; $optgroup['key'] = 'type'; $optgroup['values'][0] = 'Private queries'; $optgroup['values'][1] = 'Project queries'; echo ''; echo ''; echo '   '. _('Build Query').'
'; } else { echo ' '._('Build Query').''; } echo '
'._('Assignee').': '. $tech_box .' '._('State').': '. $status_box .' '; // Compute the list of fields which can be sorted. $efarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_TEXT, ARTIFACT_EXTRAFIELDTYPE_TEXTAREA, ARTIFACT_EXTRAFIELDTYPE_INTEGER, ARTIFACT_EXTRAFIELDTYPE_SELECT, ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_STATUS)); $keys=array_keys($efarr); for ($k=0; $k'; echo '
'; if ($af->query_type == 'default') { echo '
'; echo ''._('Viewing only opened records by default, use \'Advanced queries\' or \'Simple Filtering and Sorting\' to change.').''; echo '
'; } echo '
'; $art_cnt = count($art_arr); if ($art_arr && $art_cnt > 0) { if ($query_id) { $aq = new ArtifactQuery($ath,$query_id); $has_bargraph = (in_array('bargraph', $aq->getQueryOptions())); } else { $has_bargraph = false; } if ($has_bargraph) { // Display the roadmap block based on the values of the Status field. $colors = array('#a71d16', '#ffa0a0', '#f5f5b5', '#bae0ba', '#16a716'); $count = array(); $percent = array(); foreach($art_arr as $art) { if ($ath->usesCustomStatuses()) { $custom_id = $ath->getCustomStatusField(); $extra_data = $art->getExtraFieldDataText(); @$count[ $extra_data[$custom_id]['value'] ]++; } else { @$count[ $art->getStatusName()]++; } } foreach($count as $n => $c) { $percent[$n] = round(100*$c/$art_cnt); } if ($ath->getCustomStatusField()) { $efarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_STATUS)); $keys=array_keys($efarr); $field_id = $keys[0]; $custom_states = $ath->getExtraFieldElements($field_id); $states = array(); if (is_array($custom_states)) { foreach($custom_states as $state) { $states[] = $state['element_name']; } } } else { $colors = array('#ffa0a0', '#bae0ba'); $res = $ath->getStatuses(); while ($row = db_fetch_array($res)) { $states[] = $row['status_name']; } } $i=0; $graph = ''; $legend = ''; if (is_array($states)) { foreach($states as $name) { if ($count[$name]) { $graph .= ' '; $legend .= ''."$name: $count[$name] ($percent[$name]%)"; } $i++; } } if ($graph) { ?>
getCustomStatusField(),$_extra_fields)) { $set .= '&extra_fields['.$ath->getCustomStatusField().']='.$_extra_fields[$ath->getCustomStatusField()]; } } $IS_ADMIN = forge_check_perm ('tracker', $ath->getID(), 'manager') ; if ($IS_ADMIN) { echo '
'; } $browse_fields = explode(',', "id,".$ath->getBrowseList()); $title_arr=array(); foreach ($browse_fields as $f) { $title=$f; if (intval($f) > 0) { $title = $ath->getExtraFieldName($f); } else { if ($f == 'id') $title=_('ID'); if ($f == 'summary') $title=_('Summary'); if ($f == 'details') $title=_('Description'); if ($f == 'open_date') $title=_('Open Date'); if ($f == 'close_date') $title=_('Close Date'); if ($f == 'status_id') $title=_('State'); if ($f == 'priority') $title=_('Priority'); if ($f == 'assigned_to') $title=_('Assigned to'); if ($f == 'submitted_by') $title=_('Submitted by'); if ($f == 'related_tasks') $title=_('Related tasks'); if ($f == 'last_modified_date') $title=_('Last Modified Date'); } $title_arr[] = $title; } if ($start < $max) { echo $GLOBALS['HTML']->listTableTop ($title_arr); } $then=(time()-$ath->getDuePeriod()); for ($i=$start; $i<$max; $i++) { $extra_data = $art_arr[$i]->getExtraFieldDataText(); echo ' boxGetAltRowStyle($i) . '>'; foreach ($browse_fields as $f) { if ($f == 'id') { echo ''. ($IS_ADMIN?' ':''). ''.$art_arr[$i]->getID() . ''; } else if ($f == 'summary') { echo ''. $art_arr[$i]->getSummary(). ''; } else if ($f == 'open_date') { echo ''. (($set != 'closed' && $art_arr[$i]->getOpenDate() < $then)?'* ':'  ') . date(_('Y-m-d H:i'),$art_arr[$i]->getOpenDate()) .''; } else if ($f == 'status_id') { echo ''. $art_arr[$i]->getStatusName() .''; } else if ($f == 'priority') { echo ''. $art_arr[$i]->getPriority() .''; } else if ($f == 'assigned_to') { echo ''. $art_arr[$i]->getAssignedRealName() .''; } else if ($f == 'submitted_by') { echo ''. $art_arr[$i]->getSubmittedRealName() .''; } else if ($f == 'close_date') { echo ''. ($art_arr[$i]->getCloseDate() ? date(_('Y-m-d H:i'),$art_arr[$i]->getCloseDate()) :'  ') .''; } else if ($f == 'details') { echo ''. $art_arr[$i]->getDetails() .''; } else if ($f == 'related_tasks') { echo ''; $tasks_res = $art_arr[$i]->getRelatedTasks(); $s =''; while ($rest = db_fetch_array($tasks_res)) { $link = '/pm/task.php?func=detailtask&project_task_id='.$rest['project_task_id']. '&group_id='.$group_id.'&group_project_id='.$rest['group_project_id']; $title = '[T'.$rest['project_task_id'].']'; if ($rest['status_id'] == 2) { $title = ''.$title.''; } print $s.''.$title.''; $s = ' '; } echo ''; } else if ($f == 'last_modified_date') { echo ''. ($art_arr[$i]->getLastModifiedDate() ? date(_('Y-m-d H:i'),$art_arr[$i]->getLastModifiedDate()) :'  ') .''; } else if (intval($f) > 0) { // Now display extra-fields (fields are numbers). $value = $extra_data[$f]['value']; if ($extra_data[$f]['type'] == 9) { $value = preg_replace('/\b(\d+)\b/e', "_artifactid2url('\\1')", $value); } else if ($extra_data[$f]['type'] == 7) { if ($art_arr[$i]->getStatusID() == 2) { $value = ''.$value.''; } } echo '' . $value .''; } else { // Display ? for unknown values. echo '?'; } } echo ''; } if ($start < $max) { echo $GLOBALS['HTML']->listTableBottom(); } $pages = $art_cnt / $paging; $currentpage = intval($start / $paging); if ($pages >= 1) { $skipped_pages=false; for ($j=0; $j<$pages; $j++) { if ($pages > 20) { if ((($j > 4) && ($j < ($currentpage-5))) || (($j > ($currentpage+5)) && ($j < ($pages-5)))) { if (!$skipped_pages) { $skipped_pages=true; echo ".... "; } continue; } else { $skipped_pages=false; } } if ($j * $paging == $start) { echo ''.($j+1).'  '; } else { echo 'getID().'&set='. $set.'&start='.($j*$paging).'">'.($j+1).'  '; } } } /* Mass Update Code */ if ($IS_ADMIN) { echo ' '; // // build custom fields // $ef = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELD_FILTER_INT)); $keys=array_keys($ef); $sel=array(); for ($i=0; $irenderExtraFields($sel,true,_('No Change'),false,'',array(ARTIFACT_EXTRAFIELD_FILTER_INT),true); echo '
'._('Check  all').' - '._('Clear  all').'
'._('Admin: If you wish to apply changes to all items selected above, use these controls to change their properties and click once on "Mass Update".').'
'._('Priority').':
'; echo build_priority_select_box ('priority', '100', true); echo '
'; echo '
'._('Assigned to').':
'. $ath->technicianBox ('assigned_to','100.1',true,_('Nobody'),'100.1',_('No Change')) .'
'; if (!$ath->usesCustomStatuses()) { echo ''._('State').':
'. $ath->statusBox ('status_id','xzxz',true,_('No Change')); } echo '
'._('Canned Response').':
'. $ath->cannedResponseBox ('canned_response') .'
'; } printf(_('* Denotes requests > %1$s Days Old'), ($ath->getDuePeriod()/86400)); if (in_array('priority', $browse_fields)) { show_priority_colors_key(); } } else { echo '

'._('No items found').'

'; echo db_error(); } $ath->footer(array()); // Local Variables: // mode: php // c-file-style: "bsd" // End: ?>