/** * Method used to get all open issues and group them by user. * * @access public * @param integer $prj_id The project ID * @param integer $cutoff_days The number of days to use as a cutoff period * @return array The list of issues */ function getOpenIssuesByUser($prj_id, $cutoff_days) { $prj_id = Misc::escapeInteger($prj_id); $cutoff_days = Misc::escapeInteger($cutoff_days); $ts = Date_API::getCurrentUnixTimestampGMT(); $cutoff_ts = $ts - $cutoff_days * DAY; $stmt = "SELECT\n usr_full_name,\n iss_id,\n iss_summary,\n sta_title,\n iss_sta_id,\n iss_created_date,\n iss_updated_date,\n iss_last_response_date,\n sta_color\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n " . ETEL_USER_TABLE . "\n )\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n ON\n iss_sta_id=sta_id\n WHERE\n sta_is_closed=0 AND\n iss_prj_id={$prj_id} AND\n iss_id=isu_iss_id AND\n isu_usr_id=usr_id AND\n UNIX_TIMESTAMP(iss_created_date) < {$cutoff_ts}\n ORDER BY\n usr_full_name"; $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 { Time_Tracking::getTimeSpentByIssues($res); $issues = array(); for ($i = 0; $i < count($res); $i++) { if (empty($res[$i]['iss_updated_date'])) { $res[$i]['iss_updated_date'] = $res[$i]['iss_created_date']; } if (empty($res[$i]['iss_last_response_date'])) { $res[$i]['iss_last_response_date'] = $res[$i]['iss_created_date']; } $issues[$res[$i]['usr_full_name']][$res[$i]['iss_id']] = array('iss_summary' => $res[$i]['iss_summary'], 'sta_title' => $res[$i]['sta_title'], 'iss_created_date' => Date_API::getFormattedDate($res[$i]['iss_created_date']), 'time_spent' => Misc::getFormattedTime($res[$i]['time_spent']), 'status_color' => $res[$i]['sta_color'], 'last_update' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_updated_date'], Date_API::getDefaultTimezone())), 'last_email_response' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_API::getDefaultTimezone()))); } return $issues; } }
/** * Returns the status of a quarantine. * * @param integer $issue_id The issue ID * @return integer Indicates what the current state of quarantine is. */ function getQuarantineInfo($issue_id) { $stmt = "SELECT\n iqu_status,\n iqu_expiration\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n WHERE\n iqu_iss_id = " . Misc::escapeInteger($issue_id) . " AND\n (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR\n iqu_expiration IS NULL)"; $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return array(); } else { if (!empty($res["iqu_expiration"])) { $expiration_ts = Date_API::getUnixTimestamp($res['iqu_expiration'], Date_API::getDefaultTimezone()); $res["time_till_expiration"] = Date_API::getFormattedDateDiff($expiration_ts, Date_API::getCurrentUnixTimestampGMT()); } return $res; } }