changed the project home view to show open issue count
This commit is contained in:
		| @ -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); | ||||
|  | ||||
| @ -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)); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -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'; | ||||
| ?> | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| @ -39,19 +39,30 @@ function render_wiki() | ||||
| 	prettyPrint (); | ||||
|  | ||||
| 	$("#project_home_sidebar_info_box").accordion ({ | ||||
| 		collapsible: true  | ||||
| 		collapsible: true, | ||||
| 		heightStyle: "content" | ||||
| 	}); | ||||
|  | ||||
| <?php if ($total_open_issue_count > 0): ?> | ||||
| 	$("#project_home_sidebar_issue_box").accordion ({ | ||||
| 		collapsible: true, | ||||
| 		heightStyle: "content" | ||||
| 	}); | ||||
| <?php endif; ?> | ||||
|  | ||||
| 	$("#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 ( | ||||
| <!-- /////////////////////////////////////////////////////////////////////// --> | ||||
| <div class="codepot-sidebar" id="project_home_sidebar"> | ||||
|  | ||||
|  | ||||
| <div id="project_home_sidebar_info_box" class="collapsible-box"> | ||||
| <div id="project_home_sidebar_info_header" class="collapsible-box-header"><?php print $this->lang->line('Summary')?></div> | ||||
| <ul id="project_home_sidebar_info_list" class="collapsible-box-list"> | ||||
| <li><?php print $this->lang->line('Created on')?> <?php print codepot_dbdatetodispdate($project->createdon);?></li> | ||||
| <li><?php print $this->lang->line('Created by')?> <?php print $project->createdby;?></li> | ||||
| <li><?php print $this->lang->line('Last updated on')?> <?php print codepot_dbdatetodispdate($project->updatedon);?></li> | ||||
| <li><?php print $this->lang->line('Last updated by')?> <?php print $project->updatedby?></li> | ||||
| </ul> | ||||
| 	<div id="project_home_sidebar_info_header" class="collapsible-box-header"><?php print $this->lang->line('Summary')?></div> | ||||
|  | ||||
| 	<ul id="project_home_sidebar_info_list" class="collapsible-box-list"> | ||||
| 	<li><?php print $this->lang->line('Created on')?> <?php print codepot_dbdatetodispdate($project->createdon);?></li> | ||||
| 	<li><?php print $this->lang->line('Created by')?> <?php print $project->createdby;?></li> | ||||
| 	<li><?php print $this->lang->line('Last updated on')?> <?php print codepot_dbdatetodispdate($project->updatedon);?></li> | ||||
| 	<li><?php print $this->lang->line('Last updated by')?> <?php print $project->updatedby?></li> | ||||
| 	</ul> | ||||
| </div> | ||||
|  | ||||
| <?php if ($total_open_issue_count > 0): ?> | ||||
| <div id="project_home_sidebar_issue_box" class="collapsible-box"> | ||||
| 	<div id="project_home_sidebar_issue_header" class="collapsible-box-header"><?php print $this->lang->line('Issues')?></div> | ||||
|  | ||||
| 	<ul id="project_home_issue_stat_list" class="collapsible-box-list"> | ||||
| 	<li><a href='<?php print site_url() . "/issue/home/{$project->id}"; ?>'><?php printf ($this->lang->line('FMT_TOTAL_OPEN_ISSUES_X'), $total_open_issue_count); ?></a></li> | ||||
| 	<li><a href='<?php print site_url() . "/issue/home/{$project->id}"; ?>'><?php printf ($this->lang->line('FMT_YOUR_OPEN_ISSUES_X'), $your_open_issue_count); ?></a></li> | ||||
| 	</ul> | ||||
| </div> | ||||
| <?php endif; ?> | ||||
|  | ||||
| <div id="project_home_sidebar_member_box" class="collapsible-box"> | ||||
| <div id="project_home_sidebar_member_header" class="collapsible-box-header"><?php print $this->lang->line('Members')?></div> | ||||
| <ul id="project_home_sidebar_member_list" class="collapsible-box-list"> | ||||
| @ -192,10 +214,8 @@ foreach ($urls as $url) | ||||
| 		$xdot = $this->converter->AsciiToHex ('.'); | ||||
| 		foreach ($log_entries as $log) | ||||
| 		{ | ||||
| 			if (CODEPOT_DATABASE_STORE_GMT) | ||||
| 				$createdon = $log['createdon'] . ' +0000'; | ||||
| 			else | ||||
| 				$createdon = $log['createdon']; | ||||
|  | ||||
| 			$createdon_mmdd = codepot_dbdatetodispdate ($log['createdon'], '%m-%d'); | ||||
|  | ||||
| 			if ($log['type'] == 'code') | ||||
| 			{ | ||||
| @ -203,7 +223,7 @@ foreach ($urls as $url) | ||||
| 				print '<tr class="odd">'; | ||||
| 				print '<td class="date">'; | ||||
| 				 | ||||
| 				print strftime ('%m-%d', strtotime($createdon)); | ||||
| 				print $createdon_mmdd; | ||||
| 				print '</td>'; | ||||
| 				print '<td class="object">'; | ||||
| 				print anchor (	 | ||||
| @ -247,7 +267,7 @@ foreach ($urls as $url) | ||||
| 			{ | ||||
| 				print '<tr class="odd">'; | ||||
| 				print '<td class="date">'; | ||||
| 				print strftime ('%m-%d', strtotime($createdon)); | ||||
| 				print $createdon_mmdd; | ||||
| 				print '</td>'; | ||||
|  | ||||
| 				print '<td class="object">'; | ||||
|  | ||||
| @ -6,6 +6,24 @@ | ||||
|  * project home view  | ||||
|  *-----------------------------------------------*/ | ||||
|  | ||||
| #project_home_issue_stat_list li { | ||||
| 	margin-top: 0.1em; | ||||
| 	margin-bottom: 0.1em; | ||||
| 	line-height: 2em; | ||||
| 	background-color: #BB4444; | ||||
|  | ||||
| 	border: none; | ||||
| 	-moz-border-radius: 3px; | ||||
| 	-webkit-border-radius: 3px; | ||||
| 	border-radius: 3px; | ||||
| } | ||||
|  | ||||
| #project_home_issue_stat_list a { | ||||
| 	color: white; | ||||
| 	font-weight: bold; | ||||
| } | ||||
|  | ||||
|  | ||||
| #project_home_sidebar_log_all_button { | ||||
| 	color: #1C94C4; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user