diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index fdbff3ba..b85bd732 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -21,6 +21,9 @@ class Project extends Controller $this->load->library ('Language', 'lang'); $this->lang->load ('common', CODEPOT_LANG); $this->lang->load ('project', CODEPOT_LANG); + + $this->load->library ('IssueHelper', 'issuehelper'); + $this->lang->load ('issue', CODEPOT_LANG); } function catalog ($filter = '', $offset = '') @@ -118,6 +121,7 @@ class Project extends Controller { $this->load->model ('ProjectModel', 'projects'); $this->load->model ('LogModel', 'logs'); + $this->load->model ('IssueModel', 'issues'); $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') @@ -155,6 +159,19 @@ class Project extends Controller } else { + $total_open_issue_count = $this->issues->countIssues ('', $projectid, $this->issuehelper->_get_open_status_array($this->lang), 0); + if ($total_open_issue_count === FALSE) $open_issue_count = 0; + $data['total_open_issue_count'] = $total_open_issue_count; + + if ($login['id'] != '') + { + $your_open_issue_count = $this->issues->countIssues ($login['id'], $projectid, $this->issuehelper->_get_open_status_array($this->lang), 0); + if ($your_open_issue_count === FALSE) $your_open_issue_count = 0; + } + else $your_open_issue_count = 0; + + $data['your_open_issue_count'] = $your_open_issue_count; + $data['project'] = $project; $data['log_entries'] = $log_entries; $this->load->view ($this->VIEW_HOME, $data); diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 540abd57..6a6e11ff 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -45,7 +45,7 @@ class Site extends Controller $this->load->model ('LogModel', 'logs'); $this->load->model ('IssueModel', 'issues'); - $site = $this->sites->get ($this->config->config['language']); + $site = $this->sites->get ($this->config->config['language']); if ($site === FALSE) { $data['login'] = $login; @@ -55,7 +55,7 @@ class Site extends Controller } if ($site === NULL && CODEPOT_DEFAULT_SITE_LANGUAGE != '') { - $site = $this->sites->get (CODEPOT_DEFAULT_SITE_LANGUAGE); + $site = $this->sites->get (CODEPOT_DEFAULT_SITE_LANGUAGE); if ($site === FALSE) { $data['login'] = $login; diff --git a/codepot/src/codepot/helpers/codepot_helper.php b/codepot/src/codepot/helpers/codepot_helper.php index 5943cb56..ed81f0c5 100644 --- a/codepot/src/codepot/helpers/codepot_helper.php +++ b/codepot/src/codepot/helpers/codepot_helper.php @@ -60,16 +60,16 @@ if ( ! function_exists('codepot_unixtimetodbdate')) if ( ! function_exists('codepot_dbdatetodispdate')) { - function codepot_dbdatetodispdate($dbdate) + function codepot_dbdatetodispdate($dbdate, $format = NULL) { // display time is in the local time zone. if (CODEPOT_DATABASE_STORE_GMT) { - return strftime('%Y-%m-%d %H:%M:%S %z', strtotime($dbdate . ' +0000')); + return strftime(($format == NULL? '%Y-%m-%d %H:%M:%S %z': $format), strtotime($dbdate . ' +0000')); } else { - return strftime('%Y-%m-%d %H:%M:%S %z', strtotime($dbdate)); + return strftime(($format == NULL? '%Y-%m-%d %H:%M:%S %z': $format), strtotime($dbdate)); } } } diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index e44136d9..00c0c141 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -137,4 +137,7 @@ $lang['MSG_SIGNIN_FAILURE'] = 'Cannot sign in'; $lang['MSG_PROJECT_MEMBERSHIP_REQUIRED'] = 'You have to be a member of the %s project to perform this task'; $lang['MSG_FORM_INPUT_INCOMPLETE'] = 'Your input is incomplete'; $lang['MSG_DISCARD_CHANGES?'] = 'Do you want to discard changes?'; + +$lang['FMT_TOTAL_OPEN_ISSUES_X'] = 'Total %d open issues'; +$lang['FMT_YOUR_OPEN_ISSUES_X'] = '%d open issues assigned to you'; ?> diff --git a/codepot/src/codepot/models/issuemodel.php b/codepot/src/codepot/models/issuemodel.php index 04d9b8dc..38a4010e 100644 --- a/codepot/src/codepot/models/issuemodel.php +++ b/codepot/src/codepot/models/issuemodel.php @@ -127,14 +127,14 @@ class IssueModel extends Model return $query->result (); } - function getMyIssues ($userid, $filter, $hour_limit = 0) + function getMyIssues ($userid, $status_filter, $hour_limit = 0) { $this->db->trans_start (); if (strlen($userid) > 0) $this->db->where ('owner', $userid); - if (is_array($filter)) + if (is_array($status_filter)) { - $this->db->where_in ('status', array_keys($filter)); + $this->db->where_in ('status', array_keys($status_filter)); } if ($hour_limit > 0) @@ -160,6 +160,43 @@ class IssueModel extends Model return $query->result (); } + function countIssues ($userid, $projectid, $status_filter, $hour_limit = 0) + { + $this->db->trans_begin (); + if (strlen($userid) > 0) $this->db->where ('owner', $userid); + if (strlen($projectid) > 0) $this->db->where ('projectid', $projectid); + + if (is_array($status_filter)) + { + $this->db->where_in ('status', array_keys($status_filter)); + } + + if ($hour_limit > 0) + { + //$this->db->where ("updatedon >= SYSDATE() - INTERVAL {$hour_limit} HOUR"); + $this->db->where ("updatedon >= CURRENT_TIMESTAMP - INTERVAL '{$hour_limit}' HOUR"); + } + + $this->db->select ('COUNT(id) AS issue_count'); + $query = $this->db->get ('issue'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } + + $this->db->trans_commit(); + + $result = $query->result (); + if (empty($result)) + { + // weird error but return 0. + return 0; + } + return $result[0]->issue_count; + } + function getFile ($userid, $project, $issueid, $filename) { $this->db->trans_start (); @@ -184,14 +221,15 @@ class IssueModel extends Model $now = codepot_nowtodbdate(); // TODO: check if userid can do this.. - $this->db->trans_start (); + $this->db->trans_begin (); $this->db->where ('projectid', $issue->projectid); $this->db->select ('MAX(id) as maxid'); $query = $this->db->get ('issue'); if ($this->db->trans_status() === FALSE) { - $this->db->trans_complete (); + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); return FALSE; } @@ -213,6 +251,12 @@ class IssueModel extends Model $this->db->set ('createdby', $userid); $this->db->set ('updatedby', $userid); $this->db->insert ('issue'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } $this->db->set ('projectid', $issue->projectid); $this->db->set ('id', $newid); @@ -227,6 +271,12 @@ class IssueModel extends Model $this->db->set ('updatedon', $now); $this->db->set ('updatedby', $userid); $this->db->insert ('issue_change'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } $this->db->set ('createdon', $now); $this->db->set ('type', 'issue'); @@ -235,10 +285,14 @@ class IssueModel extends Model $this->db->set ('userid', $userid); $this->db->set ('message', $newid); $this->db->insert ('log'); + if ($this->db->trans_status() === FALSE) + { + $this->errmsg = $this->db->_error_message(); + $this->db->trans_rollback (); + return FALSE; + } - $this->db->trans_complete (); - if ($this->db->trans_status() === FALSE) return FALSE; - + $this->db->trans_commit (); return $newid; } diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index 966fdf88..d9420bea 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -39,19 +39,30 @@ function render_wiki() prettyPrint (); $("#project_home_sidebar_info_box").accordion ({ - collapsible: true + collapsible: true, + heightStyle: "content" }); + 0): ?> + $("#project_home_sidebar_issue_box").accordion ({ + collapsible: true, + heightStyle: "content" + }); + + $("#project_home_sidebar_member_box").accordion ({ - collapsible: true + collapsible: true, + heightStyle: "content" }); $("#project_home_sidebar_repo_box").accordion ({ - collapsible: true + collapsible: true, + heightStyle: "content" }); $("#project_home_sidebar_log_box").accordion ({ - collapsible: true + collapsible: true, + heightStyle: "content" }); $("#project_home_sidebar_log_all_button").button ().click (function () { @@ -104,17 +115,28 @@ $this->load->view (