diff --git a/codepot/etc/post-commit b/codepot/etc/post-commit index c95bf1e1..f99d3129 100755 --- a/codepot/etc/post-commit +++ b/codepot/etc/post-commit @@ -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 diff --git a/codepot/src/codepot/controllers/api.php b/codepot/src/codepot/controllers/api.php index 763ba5fb..b217340a 100644 --- a/codepot/src/codepot/controllers/api.php +++ b/codepot/src/codepot/controllers/api.php @@ -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); /* diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 1c832693..afcc4bb5 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -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 (); diff --git a/codepot/src/codepot/models/logmodel.php b/codepot/src/codepot/models/logmodel.php index 8ff227ba..db0f5fee 100644 --- a/codepot/src/codepot/models/logmodel.php +++ b/codepot/src/codepot/models/logmodel.php @@ -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); diff --git a/codepot/src/codepot/views/log.php b/codepot/src/codepot/views/log.php index 32329975..df20661e 100644 --- a/codepot/src/codepot/views/log.php +++ b/codepot/src/codepot/views/log.php @@ -123,7 +123,7 @@ $this->load->view (
-lang->line ('Change log') ?> +lang->line ('Change log')) ?>
@@ -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 ''; @@ -267,7 +275,11 @@ $this->load->view ( print ''; $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 ''; } diff --git a/codepot/src/codepot/views/site_home.php b/codepot/src/codepot/views/site_home.php index 4d57db94..bd6df251 100644 --- a/codepot/src/codepot/views/site_home.php +++ b/codepot/src/codepot/views/site_home.php @@ -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 ''; @@ -203,7 +210,10 @@ foreach ($latest_projects as $project) print ''; $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 ''; print '';