/** * Method used to get an array of the full list of the custom * filters associated with the current user and the current * 'active' project. * * @access public * @param boolean $build_url If a URL for this filter should be constructed. * @return array The full list of custom filters */ function getListing($build_url = false) { $stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_filter\n WHERE\n cst_prj_id=" . Auth::getCurrentProject() . " AND\n (\n cst_usr_id=" . Auth::getUserID() . " OR\n cst_is_global=1\n )\n ORDER BY\n cst_title"; $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return ""; } else { if (count($res) > 0 && $build_url == true) { $filter_info = Filter::getFiltersInfo(); for ($i = 0; $i < count($res); $i++) { $res[$i]['url'] = ''; foreach ($filter_info as $field => $filter) { if (@$filter['is_date'] == true) { $res[$i]['url'] .= $filter['param'] . '[filter_type]=' . $res[$i]['cst_' . $field . '_filter_type'] . '&'; if ($res[$i]['cst_' . $field . '_filter_type'] == 'in_past' || $res[$i]['cst_' . $field . '_filter_type'] == 'not_in_past') { $res[$i]['url'] .= $filter['param'] . '[time_period]=' . $res[$i]['cst_' . $field . '_time_period'] . '&'; } else { $start_date = $res[$i]['cst_' . $field]; if (!empty($start_date)) { $start_date_parts = explode("-", $start_date); $res[$i]['url'] .= $filter['param'] . '[Year]=' . $start_date_parts[0] . '&'; $res[$i]['url'] .= $filter['param'] . '[Month]=' . $start_date_parts[1] . '&'; $res[$i]['url'] .= $filter['param'] . '[Day]=' . $start_date_parts[2] . '&'; } $end_date = $res[$i]['cst_' . $field . '_end']; if (!empty($end_date)) { $end_date_parts = explode("-", $end_date); $res[$i]['url'] .= $filter['param'] . '_end[Year]=' . $end_date_parts[0] . '&'; $res[$i]['url'] .= $filter['param'] . '_end[Month]=' . $end_date_parts[1] . '&'; $res[$i]['url'] .= $filter['param'] . '_end[Day]=' . $end_date_parts[2] . '&'; } } } else { if (@$filter['is_custom'] != 1) { $res[$i]['url'] .= $filter['param'] . '=' . urlencode($res[$i]['cst_' . $field]) . '&'; } } } $res[$i]['url'] .= 'custom_field=' . urlencode($res[$i]['cst_custom_field']); } } return $res; } }
/** * Method used to get the current sorting options used in the grid layout * of the issue listing page. * * @param array $options The current search parameters * @return array The sorting options */ public static function getSortingInfo($options) { $custom_fields = Custom_Field::getFieldsToBeListed(Auth::getCurrentProject()); // default order for last action date, priority should be descending // for textual fields, like summary, ascending is reasonable $fields = array('pri_rank' => 'desc', 'sev_rank' => 'asc', 'iss_id' => 'desc', 'iss_customer_id' => 'desc', 'prc_title' => 'asc', 'sta_rank' => 'asc', 'iss_created_date' => 'desc', 'iss_summary' => 'asc', 'last_action_date' => 'desc', 'usr_full_name' => 'asc', 'iss_expected_resolution_date' => 'desc', 'pre_title' => 'asc', 'assigned' => 'asc', 'grp_name' => 'asc'); foreach ($custom_fields as $fld_id => $fld_name) { $fields['custom_field_' . $fld_id] = 'desc'; } $sortfields = array_combine(array_keys($fields), array_keys($fields)); $sortfields['pre_title'] = 'pre_scheduled_date'; $sortfields['assigned'] = 'isu_usr_id'; $items = array('links' => array(), 'images' => array()); $current_sort_by = $options['sort_by']; $current_sort_order = $options['sort_order']; foreach ($sortfields as $field => $sortfield) { $sort_order = $fields[$field]; if ($current_sort_by == $sortfield) { $items['images'][$field] = 'images/' . strtolower($current_sort_order) . '.gif'; if (strtolower($current_sort_order) == 'asc') { $sort_order = 'desc'; } else { $sort_order = 'asc'; } } $options['sort_by'] = $sortfield; $options['sort_order'] = $sort_order; $items['links'][$field] = $_SERVER['PHP_SELF'] . '?' . Filter::buildUrl(Filter::getFiltersInfo(), $options, false, true); } return $items; }
continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'combo' || $field['fld_type'] == 'multiple') { $custom_fields_display[$fld_id] = join(', ', Custom_Field::getOptions($fld_id, $search_value)); } } } $list = Issue::getListing($prj_id, $options, $pagerRow, $rows); $tpl->assign("list", $list["list"]); $tpl->assign("list_info", $list["info"]); $tpl->assign("csv_data", base64_encode(@$list["csv"])); $tpl->assign("columns", Display_Column::getColumnsToDisplay($prj_id, 'list_issues')); $tpl->assign("priorities", Priority::getAssocList($prj_id)); $tpl->assign("status", Status::getAssocStatusList($prj_id)); $tpl->assign("open_status", Status::getAssocStatusList($prj_id, true)); $tpl->assign("users", $users); $tpl->assign("assign_options", $assign_options); $tpl->assign("custom", Filter::getAssocList($prj_id)); $tpl->assign("csts", Filter::getListing(true)); $tpl->assign("filter_info", Filter::getFiltersInfo()); $tpl->assign("categories", Category::getAssocList($prj_id)); $tpl->assign("releases", Release::getAssocList($prj_id, true)); $tpl->assign("available_releases", Release::getAssocList($prj_id)); $tpl->assign("groups", $groups); $tpl->assign("custom_fields_display", $custom_fields_display); $tpl->assign("reporters", Project::getReporters($prj_id)); $prefs = Prefs::get($usr_id); $tpl->assign("refresh_rate", $prefs['list_refresh_rate'] * 60); $tpl->assign("refresh_page", "list.php"); $tpl->displayTemplate();