added userlog
This commit is contained in:
		| @ -3,6 +3,8 @@ | ||||
| REPOBASE="`basename "${1}"`" | ||||
| REV="${2}" | ||||
|  | ||||
| AUTHOR="$(svnlook author -r ${REV} ${1})" | ||||
|  | ||||
| # does not care if logging has failed. | ||||
| wget -q -O- "%API%/logCodeCommit/svn/${REPOBASE}/${REV}" 2>/dev/null | ||||
| wget -q -O- "%API%/logCodeCommit/svn/${REPOBASE}/${REV}/${AUTHOR}" 2>/dev/null | ||||
| exit 0 | ||||
|  | ||||
| @ -46,14 +46,14 @@ class API extends Controller | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	function logCodeCommit ($type, $repo, $rev) | ||||
| 	function logCodeCommit ($type, $repo, $rev, $userid) | ||||
| 	{ | ||||
| 		$this->check_access (); | ||||
|  | ||||
| 		if (!isset($repo) || !isset($rev)) return; | ||||
|  | ||||
| 		$this->load->model ('LogModel', 'logs'); | ||||
| 		$this->logs->writeCodeCommit ($type, $repo, $rev, ''); | ||||
| 		$this->logs->writeCodeCommit ($type, $repo, $rev, $userid); | ||||
|  | ||||
|  | ||||
| 		/* | ||||
|  | ||||
| @ -431,6 +431,75 @@ class Site extends Controller | ||||
| 		$this->load->view ($this->VIEW_LOG, $data); | ||||
| 	} | ||||
|  | ||||
| 	function userlog ($userid = '', $offset = 0) | ||||
| 	{ | ||||
| 		$login = $this->login->getUser (); | ||||
|  | ||||
| 		$this->load->library ('pagination'); | ||||
| 		$this->load->model ('LogModel', 'logs'); | ||||
| 		$this->load->model ('SiteModel', 'sites'); | ||||
|  | ||||
|                 $site = $this->sites->get ($this->config->config['language']); | ||||
| 		if ($site === FALSE) | ||||
| 		{ | ||||
| 			$data['login'] = $login; | ||||
| 			$data['message'] = 'DATABASE ERROR'; | ||||
| 			$this->load->view ($this->VIEW_ERROR, $data); | ||||
| 			return; | ||||
| 		} | ||||
| 		if ($site === NULL && CODEPOT_DEFAULT_SITE_LANGUAGE != '')  | ||||
| 		{ | ||||
|                 	$site = $this->sites->get (CODEPOT_DEFAULT_SITE_LANGUAGE); | ||||
| 			if ($site === FALSE) | ||||
| 			{ | ||||
| 				$data['login'] = $login; | ||||
| 				$data['message'] = 'DATABASE ERROR'; | ||||
| 				$this->load->view ($this->VIEW_ERROR, $data); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($login['sysadmin?'] &&  | ||||
| 		    $this->input->post('purge_log') == 'yes') | ||||
| 		{ | ||||
| 			$this->logs->purge (); | ||||
| 		} | ||||
|  | ||||
| 		$num_log_entries = $this->logs->getNumEntries ('', $userid); | ||||
| 		if ($num_log_entries === FALSE) | ||||
| 		{ | ||||
| 			$data['login'] = $login; | ||||
| 			$data['message'] = 'DATABASE ERROR'; | ||||
| 			$this->load->view ($this->VIEW_ERROR, $data); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		$pagecfg['base_url'] = site_url() . "/site/userlog/$userid/"; | ||||
| 		$pagecfg['total_rows'] = $num_log_entries; | ||||
| 		$pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE;  | ||||
| 		$pagecfg['uri_segment'] = 3; | ||||
| 		$pagecfg['first_link'] = $this->lang->line('First'); | ||||
| 		$pagecfg['last_link'] = $this->lang->line('Last'); | ||||
|  | ||||
| 		$log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], '', $userid); | ||||
| 		if ($log_entries === FALSE) | ||||
| 		{ | ||||
| 			$data['login'] = $login; | ||||
| 			$data['message'] = 'DATABASE ERROR'; | ||||
| 			$this->load->view ($this->VIEW_ERROR, $data); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		$this->pagination->initialize ($pagecfg); | ||||
|  | ||||
| 		$data['site'] = $site; | ||||
| 		$data['login'] = $login; | ||||
| 		$data['log_entries'] = $log_entries; | ||||
| 		$data['page_links'] = $this->pagination->create_links (); | ||||
|  | ||||
| 		$this->load->view ($this->VIEW_LOG, $data); | ||||
| 	} | ||||
|  | ||||
| 	function wiki ($xlink = '') | ||||
| 	{ | ||||
| 		$login = $this->login->getUser (); | ||||
|  | ||||
| @ -8,7 +8,7 @@ class LogModel extends Model | ||||
| 		$this->load->database (); | ||||
| 	} | ||||
|  | ||||
| 	function getNumEntries ($projectid = '') | ||||
| 	function getNumEntries ($projectid = '', $userid = '') | ||||
| 	{ | ||||
| 		$this->db->trans_start (); | ||||
|  | ||||
| @ -21,6 +21,8 @@ class LogModel extends Model | ||||
| 			$this->db->where ('projectid', $projectid); | ||||
| 		//$num = $this->db->count_all ('log'); | ||||
|  | ||||
| 		if ($userid != '') $this->db->where ('userid', $userid); | ||||
|  | ||||
| 		$this->db->select ('count(id) as count'); | ||||
| 		$query = $this->db->get ('log'); | ||||
| 		if ($this->db->trans_status() === FALSE)  | ||||
| @ -39,7 +41,7 @@ class LogModel extends Model | ||||
| 		return $num; | ||||
| 	} | ||||
|  | ||||
| 	function getEntries ($offset, $limit, $projectid = '') | ||||
| 	function getEntries ($offset, $limit, $projectid = '', $userid = '') | ||||
| 	{ | ||||
| 		$this->db->trans_start (); | ||||
|  | ||||
| @ -50,6 +52,7 @@ class LogModel extends Model | ||||
| 		else if ($projectid != '')  | ||||
| 			$this->db->where ('projectid', $projectid); | ||||
|  | ||||
| 		if ($userid != '') $this->db->where ('userid', $userid); | ||||
| 		$this->db->order_by ('createdon', 'desc'); | ||||
| 		$query = $this->db->get ('log', $limit, $offset); | ||||
|  | ||||
|  | ||||
| @ -123,7 +123,7 @@ $this->load->view ( | ||||
| <div class="mainarea" id="log_mainarea"> | ||||
|  | ||||
| <div class="title" id="log_mainarea_title"> | ||||
| <?= $this->lang->line ('Change log') ?> | ||||
| <?= anchor ("site/log", $this->lang->line ('Change log')) ?> | ||||
| </div> | ||||
|  | ||||
| <?php if ($login['sysadmin?'] && isset($site)): ?> | ||||
| @ -206,14 +206,22 @@ $this->load->view ( | ||||
| 			if ($log['action'] == 'revpropchange') | ||||
| 			{ | ||||
| 				$fmt = $this->lang->line ('MSG_LOG_REVPROP_CHANGE_BY'); | ||||
| 				print htmlspecialchars (sprintf($fmt, $code['propname'], $code['author'])); | ||||
| 				//print htmlspecialchars (sprintf($fmt, $code['propname'], $code['author'])); | ||||
| 				printf ( | ||||
| 					htmlspecialchars ($fmt), | ||||
| 					htmlspecialchars ($code['propname']), | ||||
| 					anchor ("/site/userlog/{$code['author']}", htmlspecialchars ($code['author']))); | ||||
| 				//$code['action'] | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				$fmt = $this->lang->line ( | ||||
| 					'MSG_LOG_'.strtoupper($log['action']).'_BY'); | ||||
| 				print htmlspecialchars (sprintf($fmt, $code['author'])); | ||||
|  | ||||
| 				//print htmlspecialchars (sprintf($fmt, $code['author'])); | ||||
| 				printf ( | ||||
| 					htmlspecialchars ($fmt), | ||||
| 					anchor ("/site/userlog/{$code['author']}", htmlspecialchars ($code['author']))); | ||||
| 			} | ||||
| 			print '</span>'; | ||||
|  | ||||
| @ -267,7 +275,11 @@ $this->load->view ( | ||||
| 			print '<span class="description">'; | ||||
| 			$fmt = $this->lang->line ( | ||||
| 				'MSG_LOG_'.strtoupper($log['action']).'_BY'); | ||||
| 			print htmlspecialchars (sprintf($fmt, $log['userid'])); | ||||
|  | ||||
| 			//print htmlspecialchars (sprintf($fmt, $log['userid'])); | ||||
| 			printf ( | ||||
| 				htmlspecialchars ($fmt), | ||||
| 				anchor ("/site/userlog/{$log['userid']}", htmlspecialchars ($log['userid']))); | ||||
| 			print '</span>'; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| @ -132,13 +132,20 @@ foreach ($latest_projects as $project) | ||||
| 			if ($log['action'] == 'revpropchange') | ||||
| 			{ | ||||
| 				$fmt = $this->lang->line ('MSG_LOG_REVPROP_CHANGE_BY'); | ||||
| 				print htmlspecialchars (sprintf($fmt, $x['propname'], $x['author'])); | ||||
| 				//print htmlspecialchars (sprintf($fmt, $x['propname'], $x['author'])); | ||||
| 				printf ( | ||||
| 					htmlspecialchars ($fmt), | ||||
| 					htmlspecialchars ($x['propname']), | ||||
| 					anchor ("/site/userlog/{$code['author']}", htmlspecialchars ($x['author']))); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				$fmt = $this->lang->line ( | ||||
| 					'MSG_LOG_'.strtoupper($log['action']).'_BY'); | ||||
| 				print htmlspecialchars (sprintf($fmt, $x['author'])); | ||||
| 				//print htmlspecialchars (sprintf($fmt, $x['author'])); | ||||
| 				printf ( | ||||
| 					htmlspecialchars ($fmt), | ||||
| 					anchor ("/site/userlog/{$x['author']}", htmlspecialchars ($x['author']))); | ||||
| 			} | ||||
| 			print '</span>'; | ||||
|  | ||||
| @ -203,7 +210,10 @@ foreach ($latest_projects as $project) | ||||
| 			print '<span class="description">'; | ||||
| 			$fmt = $this->lang->line ( | ||||
| 				'MSG_LOG_'.strtoupper($log['action']).'_BY'); | ||||
| 			print htmlspecialchars (sprintf($fmt, $log['userid'])); | ||||
| 			//print htmlspecialchars (sprintf($fmt, $log['userid'])); | ||||
| 			printf ( | ||||
| 				htmlspecialchars ($fmt), | ||||
| 				anchor ("/site/userlog/{$log['userid']}", htmlspecialchars ($log['userid']))); | ||||
| 			print '</span>'; | ||||
| 			print '</td>'; | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user