/** * Method used to get the details for a specific issue. * * @param integer $issue_id The issue ID * @param boolean $force_refresh If the cache should not be used. * @return array The details for the specified issue */ public static function getDetails($issue_id, $force_refresh = false) { static $returns; if (empty($issue_id)) { return ''; } if (!empty($returns[$issue_id]) && $force_refresh != true) { return $returns[$issue_id]; } $stmt = 'SELECT {{%issue}}.*, prj_title, prc_title, pre_title, pri_title, sev_title, sta_title, sta_abbreviation, sta_color status_color, sta_is_closed FROM ( {{%issue}}, {{%project}} ) LEFT JOIN {{%project_priority}} ON iss_pri_id=pri_id LEFT JOIN {{%project_severity}} ON iss_sev_id=sev_id LEFT JOIN {{%status}} ON iss_sta_id=sta_id LEFT JOIN {{%project_category}} ON iss_prc_id=prc_id LEFT JOIN {{%project_release}} ON iss_pre_id=pre_id WHERE iss_id=? AND iss_prj_id=prj_id'; try { $res = DB_Helper::getInstance()->getRow($stmt, array($issue_id)); } catch (DbException $e) { return ''; } if (empty($res)) { return ''; } $created_date_ts = Date_Helper::getUnixTimestamp($res['iss_created_date'], Date_Helper::getDefaultTimezone()); // get customer information, if any if (!empty($res['iss_customer_id']) && CRM::hasCustomerIntegration($res['iss_prj_id'])) { $crm = CRM::getInstance($res['iss_prj_id']); try { $customer = $crm->getCustomer($res['iss_customer_id']); $contract = $crm->getContract($res['iss_customer_contract_id']); $res['contact_local_time'] = Date_Helper::getFormattedDate(Date_Helper::getCurrentDateGMT(), $res['iss_contact_timezone']); $res['customer'] = $customer; $res['contract'] = $contract; $res['contact'] = $crm->getContact($res['iss_customer_contact_id']); // TODOCRM: Deal with incidents // $res['redeemed_incidents'] = Customer::getRedeemedIncidentDetails($res['iss_prj_id'], $res['iss_id']); $max_first_response_time = $contract->getMaximumFirstResponseTime($issue_id); $res['max_first_response_time'] = Misc::getFormattedTime($max_first_response_time / 60); if (empty($res['iss_first_response_date'])) { $first_response_deadline = $created_date_ts + $max_first_response_time; if (time() <= $first_response_deadline) { $res['max_first_response_time_left'] = Date_Helper::getFormattedDateDiff($first_response_deadline, time()); } else { $res['overdue_first_response_time'] = Date_Helper::getFormattedDateDiff(time(), $first_response_deadline); } } } catch (CRMException $e) { // TODOCRM: Log exception? } } $res['iss_original_description'] = $res['iss_description']; $res['iss_original_percent_complete'] = $res['iss_percent_complete']; $res['iss_description'] = nl2br(htmlspecialchars($res['iss_description'])); $res['iss_resolution'] = Resolution::getTitle($res['iss_res_id']); $res['iss_impact_analysis'] = nl2br(htmlspecialchars($res['iss_impact_analysis'])); $res['iss_created_date_ts'] = $created_date_ts; $res['assignments'] = @implode(', ', array_values(self::getAssignedUsers($res['iss_id']))); list($res['authorized_names'], $res['authorized_repliers']) = Authorized_Replier::getAuthorizedRepliers($res['iss_id']); $temp = self::getAssignedUsersStatus($res['iss_id']); $res['has_inactive_users'] = 0; $res['assigned_users'] = array(); $res['assigned_inactive_users'] = array(); foreach ($temp as $usr_id => $usr_status) { if (!User::isActiveStatus($usr_status)) { $res['assigned_inactive_users'][] = $usr_id; $res['has_inactive_users'] = 1; } else { $res['assigned_users'][] = $usr_id; } } if (@in_array(Auth::getUserID(), $res['assigned_users'])) { $res['is_current_user_assigned'] = 1; } else { $res['is_current_user_assigned'] = 0; } $res['associated_issues_details'] = self::getAssociatedIssuesDetails($res['iss_id']); $res['associated_issues'] = self::getAssociatedIssues($res['iss_id']); $res['reporter'] = User::getFullName($res['iss_usr_id']); if (empty($res['iss_updated_date'])) { $res['iss_updated_date'] = $res['iss_created_date']; } $res['estimated_formatted_time'] = Misc::getFormattedTime($res['iss_dev_time']); if (Release::isAssignable($res['iss_pre_id'])) { $release = Release::getDetails($res['iss_pre_id']); $res['pre_title'] = $release['pre_title']; $res['pre_status'] = $release['pre_status']; } // need to return the list of issues that are duplicates of this one $res['duplicates'] = self::getDuplicateList($res['iss_id']); $res['duplicates_details'] = self::getDuplicateDetailsList($res['iss_id']); // also get the issue title of the duplicated issue if (!empty($res['iss_duplicated_iss_id'])) { $res['duplicated_issue'] = self::getDuplicatedDetails($res['iss_duplicated_iss_id']); } // get group information if (!empty($res['iss_grp_id'])) { $res['group'] = Group::getDetails($res['iss_grp_id']); } // get quarantine issue $res['quarantine'] = self::getQuarantineInfo($res['iss_id']); $res['products'] = Product::getProductsByIssue($res['iss_id']); $returns[$issue_id] = $res; return $res; }
include_once APP_INC_PATH . "class.auth.php"; include_once APP_INC_PATH . "class.user.php"; include_once APP_INC_PATH . "class.project.php"; include_once APP_INC_PATH . "class.release.php"; include_once APP_INC_PATH . "db_access.php"; $tpl = new Template_API(); $tpl->setTemplate("manage/index.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "releases"); $role_id = Auth::getCurrentRole(); if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) { if ($role_id == User::getRoleID('administrator')) { $tpl->assign("show_setup_links", true); } @($prj_id = $HTTP_POST_VARS["prj_id"] ? $HTTP_POST_VARS["prj_id"] : $HTTP_GET_VARS["prj_id"]); $tpl->assign("project", Project::getDetails($prj_id)); if (@$HTTP_POST_VARS["cat"] == "new") { $tpl->assign("result", Release::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Release::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Release::remove(); } if (@$HTTP_GET_VARS["cat"] == "edit") { $tpl->assign("info", Release::getDetails($HTTP_GET_VARS["id"])); } $tpl->assign("list", Release::getList($prj_id)); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
// +----------------------------------------------------------------------+ // | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/releases.tpl.html'); Auth::checkAuthentication(APP_COOKIE); $role_id = Auth::getCurrentRole(); if ($role_id < User::getRoleID('manager')) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } @($prj_id = $_POST['prj_id'] ? $_POST['prj_id'] : $_GET['prj_id']); $tpl->assign('project', Project::getDetails($prj_id)); if (@$_POST['cat'] == 'new') { $res = Release::insert(); $tpl->assign('result', $res); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the release was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the release.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new release.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'update') { $res = Release::update(); $tpl->assign('result', $res); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the release was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the release.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this release.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'delete') { Release::remove(); } if (@$_GET['cat'] == 'edit') { $tpl->assign('info', Release::getDetails($_GET['id'])); } $tpl->assign('list', Release::getList($prj_id)); $tpl->displayTemplate();
/** * Method used to get the details for a specific issue. * * @access public * @param integer $issue_id The issue ID * @param boolean $force_refresh If the cache should not be used. * @return array The details for the specified issue */ function getDetails($issue_id, $force_refresh = false) { global $HTTP_SERVER_VARS; static $returns; $issue_id = Misc::escapeInteger($issue_id); if (empty($issue_id)) { return ''; } if (!empty($returns[$issue_id]) && $force_refresh != true) { return $returns[$issue_id]; } $stmt = "SELECT\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue.*,\n prj_title,\n prc_title,\n pre_title,\n pri_title,\n sta_title,\n sta_abbreviation,\n sta_color status_color,\n sta_is_closed,\n\t\t\t\t\tsup_id as last_sup_id,\n\t\t\t\t\tseb_body as last_seb_body,\n\t\t\t\t\tema_id,\n\t\t\t\t\ten_email as reporter_email\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project\n )\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 . "status\n ON\n iss_sta_id=sta_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 " . ETEL_USER_TABLE_NOSUB . "\n ON\n iss_usr_id=en_ID\n LEFT JOIN\n (\n\t\t\t\t\t\tSelect sup_id,sup_iss_id,seb_body\n\t\t\t\t\t\tfrom " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email\n\t\t\t\t\t\tleft join " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body on seb_sup_id = sup_id \n\t\t\t\t\t\twhere sup_iss_id = {$issue_id} order by sup_date desc\n\t\t\t\t\t) as sup\n ON\n sup_iss_id = iss_id\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account\n ON\n ema_prj_id = iss_prj_id\n WHERE\n iss_id={$issue_id} AND\n iss_prj_id=prj_id"; $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 ""; } else { if (empty($res)) { return ""; } else { $created_date_ts = Date_API::getUnixTimestamp($res['iss_created_date'], Date_API::getDefaultTimezone()); // get customer information, if any if (!empty($res['iss_customer_id']) && Customer::hasCustomerIntegration($res['iss_prj_id'])) { $res['customer_business_hours'] = Customer::getBusinessHours($res['iss_prj_id'], $res['iss_customer_id']); $res['contact_local_time'] = Date_API::getFormattedDate(Date_API::getCurrentDateGMT(), $res['iss_contact_timezone']); $res['customer_info'] = Customer::getDetails($res['iss_prj_id'], $res['iss_customer_id']); $res['redeemed_incidents'] = Customer::getRedeemedIncidentDetails($res['iss_prj_id'], $res['iss_id']); $max_first_response_time = Customer::getMaximumFirstResponseTime($res['iss_prj_id'], $res['iss_customer_id']); $res['max_first_response_time'] = Misc::getFormattedTime($max_first_response_time / 60); if (empty($res['iss_first_response_date'])) { $first_response_deadline = $created_date_ts + $max_first_response_time; if (Date_API::getCurrentUnixTimestampGMT() <= $first_response_deadline) { $res['max_first_response_time_left'] = Date_API::getFormattedDateDiff($first_response_deadline, Date_API::getCurrentUnixTimestampGMT()); } else { $res['overdue_first_response_time'] = Date_API::getFormattedDateDiff(Date_API::getCurrentUnixTimestampGMT(), $first_response_deadline); } } } $res['iss_original_description'] = $res["iss_description"]; if (!strstr($HTTP_SERVER_VARS["PHP_SELF"], 'update.php')) { $res["iss_description"] = nl2br(htmlspecialchars($res["iss_description"])); $res["iss_resolution"] = Resolution::getTitle($res["iss_res_id"]); } $res["iss_impact_analysis"] = nl2br(htmlspecialchars($res["iss_impact_analysis"])); $res["iss_created_date"] = Date_API::getFormattedDate($res["iss_created_date"]); $res['iss_created_date_ts'] = $created_date_ts; $res["assignments"] = @implode(", ", array_values(Issue::getAssignedUsers($res["iss_id"]))); list($res['authorized_names'], $res['authorized_repliers']) = Authorized_Replier::getAuthorizedRepliers($res["iss_id"]); $temp = Issue::getAssignedUsersStatus($res["iss_id"]); $res["has_inactive_users"] = 0; $res["assigned_users"] = array(); $res["assigned_inactive_users"] = array(); foreach ($temp as $usr_id => $usr_status) { if (!User::isActiveStatus($usr_status)) { $res["assigned_inactive_users"][] = $usr_id; $res["has_inactive_users"] = 1; } else { $res["assigned_users"][] = $usr_id; } } if (@in_array(Auth::getUserID(), $res["assigned_users"])) { $res["is_current_user_assigned"] = 1; } else { $res["is_current_user_assigned"] = 0; } $res["associated_issues_details"] = Issue::getAssociatedIssuesDetails($res["iss_id"]); $res["associated_issues"] = Issue::getAssociatedIssues($res["iss_id"]); $res["reporter"] = User::getFullName($res["iss_usr_id"]); $res["email_list_details"] = Support::getFirstEmailer($issue_id); if (!$res["reporter"]) { $first_emailer = Support::getFirstEmailer($issue_id); $res["reporter"] = $first_emailer . " (No Account)"; $res["reporter_email"] = preg_replace('/.*<|>/', '', $first_emailer); } if (empty($res["iss_updated_date"])) { $res["iss_updated_date"] = 'not updated yet'; } else { $res["iss_updated_date"] = Date_API::getFormattedDate($res["iss_updated_date"]); } $res["estimated_formatted_time"] = Misc::getFormattedTime($res["iss_dev_time"]); if (Release::isAssignable($res["iss_pre_id"])) { $release = Release::getDetails($res["iss_pre_id"]); $res["pre_title"] = $release["pre_title"]; $res["pre_status"] = $release["pre_status"]; } // need to return the list of issues that are duplicates of this one $res["duplicates"] = Issue::getDuplicateList($res["iss_id"]); $res["duplicates_details"] = Issue::getDuplicateDetailsList($res["iss_id"]); // also get the issue title of the duplicated issue if (!empty($res['iss_duplicated_iss_id'])) { $res['duplicated_issue'] = Issue::getDuplicatedDetails($res['iss_duplicated_iss_id']); } // get group information if (!empty($res["iss_grp_id"])) { $res["group"] = Group::getDetails($res["iss_grp_id"]); } // get quarantine issue $res["quarantine"] = Issue::getQuarantineInfo($res["iss_id"]); $returns[$issue_id] = $res; return $res; } } }