/** * Method used to get the list of news entries available in the * system for a given project. * * @access public * @param integer $prj_id The project ID * @return array The list of news entries */ function getListByProject($prj_id, $show_full_message = FALSE) { $stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "news,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_news\n WHERE\n prn_nws_id=nws_id AND\n prn_prj_id=" . Misc::escapeInteger($prj_id) . " AND\n nws_status='active'\n ORDER BY\n nws_created_date DESC\n LIMIT\n 0, 3"; $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 { for ($i = 0; $i < count($res); $i++) { $res[$i]['nws_created_date'] = Date_API::getSimpleDate($res[$i]["nws_created_date"]); if (!$show_full_message && strlen($res[$i]['nws_message']) > 300) { $next_space = strpos($res[$i]['nws_message'], ' ', 254); if (empty($next_space)) { $next_space = strpos($res[$i]['nws_message'], "\n", 254); } if ($next_space > 0 && $next_space - 255 < 50) { $cut = $next_space; } else { $cut = 255; } $res[$i]['nws_message'] = substr($res[$i]['nws_message'], 0, $cut) . '...'; } $res[$i]['nws_message'] = nl2br(htmlspecialchars($res[$i]['nws_message'])); } return $res; } }
/** * Returns the list of FAQ entries associated to a given support level. * * @access public * @param integer $support_level_id The support level ID * @return array The list of FAQ entries */ function getListBySupportLevel($support_level_id) { $support_level_id = Misc::escapeInteger($support_level_id); $prj_id = Auth::getCurrentProject(); if ($support_level_id == -1) { $stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n WHERE\n faq_prj_id = {$prj_id}\n ORDER BY\n faq_rank ASC"; } else { $stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq_support_level\n WHERE\n faq_id=fsl_faq_id AND\n fsl_support_level_id={$support_level_id} AND\n faq_prj_id = {$prj_id}\n ORDER BY\n faq_rank ASC"; } $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 { for ($i = 0; $i < count($res); $i++) { if (empty($res[$i]['faq_updated_date'])) { $res[$i]['faq_updated_date'] = $res[$i]['faq_created_date']; } $res[$i]['faq_updated_date'] = Date_API::getSimpleDate($res[$i]["faq_updated_date"]); } return $res; } }
/** * Method used to get the list of issues to be displayed in the grid layout. * * @access public * @param integer $prj_id The current project ID * @param array $options The search parameters * @param integer $current_row The current page number * @param integer $max The maximum number of rows per page * @return array The list of issues to be displayed */ function getListing($prj_id, $options, $current_row = 0, $max = 5, $get_reporter = FALSE) { if (strtoupper($max) == "ALL") { $max = 9999999; } $start = $current_row * $max; // get the current user's role $usr_id = Auth::getUserID(); $role_id = User::getRoleByUser($usr_id, $prj_id); // get any custom fields that should be displayed $custom_fields = Custom_Field::getFieldsToBeListed($prj_id); $stmt = "SELECT\n iss_id,\n iss_grp_id,\n iss_prj_id,\n iss_sta_id,\n iss_customer_id,\n iss_created_date,\n iss_updated_date,\n iss_last_response_date,\n iss_closed_date,\n iss_last_customer_action_date,\n iss_usr_id,\n iss_summary,\n pri_title,\n prc_title,\n sta_title,\n sta_color status_color,\n sta_id,\n iqu_status,\n grp_name `group`,\n pre_title,\n iss_last_public_action_date,\n iss_last_public_action_type,\n iss_last_internal_action_date,\n iss_last_internal_action_type,\n " . Issue::getLastActionFields() . ",\n IF(iss_last_internal_action_date > iss_last_public_action_date, 'internal', 'public') AS action_type,\n iss_private,\n CONCAT(en_firstname,' ', en_lastname) as usr_full_name,\n iss_percent_complete,\n iss_dev_time,\n iss_expected_resolution_date\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . ETEL_USER_TABLE_NOSUB . ""; // join custom fields if we are searching by custom fields if (is_array($options['custom_field']) && count($options['custom_field']) > 0) { foreach ($options['custom_field'] as $fld_id => $search_value) { if (empty($search_value)) { continue; } $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'date' && (empty($search_value['Year']) || empty($search_value['Month']) || empty($search_value['Day']))) { continue; } if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeInteger($search_value); foreach ($search_value as $cfo_id) { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . '_' . $cfo_id . "\n"; } } else { $stmt .= ",\n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf" . $fld_id . "\n"; } } } $stmt .= ")"; // check for the custom fields we want to sort by if (strstr($options['sort_by'], 'custom_field') !== false) { $fld_id = str_replace("custom_field_", '', $options['sort_by']); $stmt .= "\n LEFT JOIN \n" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field as cf_sort\n ON\n (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = {$fld_id}) \n"; } // START ETEL MODIFIED if (!empty($options["show_authorized_issues"]) || $role_id <= User::getRoleID("Standard User") && Project::getSegregateReporters($prj_id)) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user_replier\n ON\n iur_iss_id=iss_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id"; } else { if (!empty($options["users"])) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user\n ON\n isu_iss_id=iss_id"; } } // END ETEL MODIFIED if (!empty($options["show_notification_list_issues"])) { $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "subscription\n ON\n sub_iss_id=iss_id"; } $stmt .= "\n LEFT JOIN\n " . APP_DEFAULT_DB . ".`" . APP_TABLE_PREFIX . "group`\n ON\n iss_grp_id=grp_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_category\n ON\n iss_prc_id=prc_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_release\n ON\n iss_pre_id = pre_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n ON\n iss_sta_id=sta_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n ON\n iss_pri_id=pri_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n ON\n iss_id=iqu_iss_id AND\n (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR iqu_expiration IS NULL)\n WHERE\n iss_prj_id= " . Misc::escapeInteger($prj_id); $stmt .= Issue::buildWhereClause($options); //echo $stmt; if (strstr($options["sort_by"], 'custom_field') !== false) { $sort_by = 'cf_sort.icf_value'; } else { $sort_by = Misc::escapeString($options["sort_by"]); } $stmt .= "\n GROUP BY\n iss_id\n ORDER BY\n " . $sort_by . " " . Misc::escapeString($options["sort_order"]) . ",\n iss_id DESC"; $total_rows = Pager::getTotalRows($stmt); if ($max > 100) { $max = 100; } $stmt .= "\n LIMIT\n " . Misc::escapeInteger($start) . ", " . Misc::escapeInteger($max); $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); // echo $stmt; if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return array("list" => "", "info" => ""); } else { if (count($res) > 0) { if ($get_reporter) { Issue::getReportersByIssues($res); } Issue::getAssignedUsersByIssues($res); Time_Tracking::getTimeSpentByIssues($res); // need to get the customer titles for all of these issues... if (Customer::hasCustomerIntegration($prj_id)) { Customer::getCustomerTitlesByIssues($prj_id, $res); } Issue::formatLastActionDates($res); Issue::getLastStatusChangeDates($prj_id, $res); } elseif ($current_row > 0) { // if there are no results, and the page is not the first page reset page to one and reload results Auth::redirect(APP_RELATIVE_URL . "list.php?pagerRow=0&rows={$max}"); } $groups = Group::getAssocList($prj_id); $categories = Category::getAssocList($prj_id); $column_headings = Issue::getColumnHeadings($prj_id); if (count($custom_fields) > 0) { $column_headings = array_merge($column_headings, $custom_fields); } $csv[] = @implode("\t", $column_headings); for ($i = 0; $i < count($res); $i++) { $res[$i]["time_spent"] = Misc::getFormattedTime($res[$i]["time_spent"]); $res[$i]["iss_expected_resolution_date"] = Date_API::getSimpleDate($res[$i]["iss_expected_resolution_date"], false); $fields = array($res[$i]['pri_title'], $res[$i]['iss_id']); // hide the group column from the output if no // groups are available in the database if (count($groups) > 0) { $fields[] = $res[$i]['group']; } $fields[] = $res[$i]['assigned_users']; $fields[] = $res[$i]['time_spent']; // hide the category column from the output if no // categories are available in the database if (count($categories) > 0) { $fields[] = $res[$i]['prc_title']; } if (Customer::hasCustomerIntegration($prj_id)) { $fields[] = @$res[$i]['customer_title']; // check if current user is acustomer and has a per incident contract. // if so, check if issue is redeemed. if (User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) { if (Customer::hasPerIncidentContract($prj_id, Issue::getCustomerID($res[$i]['iss_id'])) && Customer::isRedeemedIncident($prj_id, $res[$i]['iss_id'])) { $res[$i]['redeemed'] = true; } } } $fields[] = $res[$i]['sta_title']; $fields[] = $res[$i]["status_change_date"]; $fields[] = $res[$i]["last_action_date"]; $fields[] = $res[$i]['iss_summary']; if (count($custom_fields) > 0) { $res[$i]['custom_field'] = array(); $custom_field_values = Custom_Field::getListByIssue($prj_id, $res[$i]['iss_id']); foreach ($custom_field_values as $this_field) { if (!empty($custom_fields[$this_field['fld_id']])) { $res[$i]['custom_field'][$this_field['fld_id']] = $this_field['icf_value']; $fields[] = $this_field['icf_value']; } } } $csv[] = @implode("\t", $fields); } $total_pages = ceil($total_rows / $max); $last_page = $total_pages - 1; return array("list" => $res, "info" => array("current_page" => $current_row, "start_offset" => $start, "end_offset" => $start + count($res), "total_rows" => $total_rows, "total_pages" => $total_pages, "previous_page" => $current_row == 0 ? "-1" : $current_row - 1, "next_page" => $current_row == $last_page ? "-1" : $current_row + 1, "last_page" => $last_page, "custom_fields" => $custom_fields), "csv" => @implode("\n", $csv)); } }