added userlog

This commit is contained in:
hyung-hwan 2013-12-11 15:33:30 +00:00
parent ff3f81b2e7
commit cea27322d9
6 changed files with 108 additions and 12 deletions

View File

@ -3,6 +3,8 @@
REPOBASE="`basename "${1}"`" REPOBASE="`basename "${1}"`"
REV="${2}" REV="${2}"
AUTHOR="$(svnlook author -r ${REV} ${1})"
# does not care if logging has failed. # 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 exit 0

View File

@ -46,14 +46,14 @@ class API extends Controller
} }
function logCodeCommit ($type, $repo, $rev) function logCodeCommit ($type, $repo, $rev, $userid)
{ {
$this->check_access (); $this->check_access ();
if (!isset($repo) || !isset($rev)) return; if (!isset($repo) || !isset($rev)) return;
$this->load->model ('LogModel', 'logs'); $this->load->model ('LogModel', 'logs');
$this->logs->writeCodeCommit ($type, $repo, $rev, ''); $this->logs->writeCodeCommit ($type, $repo, $rev, $userid);
/* /*

View File

@ -431,6 +431,75 @@ class Site extends Controller
$this->load->view ($this->VIEW_LOG, $data); $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 = '') function wiki ($xlink = '')
{ {
$login = $this->login->getUser (); $login = $this->login->getUser ();

View File

@ -8,7 +8,7 @@ class LogModel extends Model
$this->load->database (); $this->load->database ();
} }
function getNumEntries ($projectid = '') function getNumEntries ($projectid = '', $userid = '')
{ {
$this->db->trans_start (); $this->db->trans_start ();
@ -21,6 +21,8 @@ class LogModel extends Model
$this->db->where ('projectid', $projectid); $this->db->where ('projectid', $projectid);
//$num = $this->db->count_all ('log'); //$num = $this->db->count_all ('log');
if ($userid != '') $this->db->where ('userid', $userid);
$this->db->select ('count(id) as count'); $this->db->select ('count(id) as count');
$query = $this->db->get ('log'); $query = $this->db->get ('log');
if ($this->db->trans_status() === FALSE) if ($this->db->trans_status() === FALSE)
@ -39,7 +41,7 @@ class LogModel extends Model
return $num; return $num;
} }
function getEntries ($offset, $limit, $projectid = '') function getEntries ($offset, $limit, $projectid = '', $userid = '')
{ {
$this->db->trans_start (); $this->db->trans_start ();
@ -50,6 +52,7 @@ class LogModel extends Model
else if ($projectid != '') else if ($projectid != '')
$this->db->where ('projectid', $projectid); $this->db->where ('projectid', $projectid);
if ($userid != '') $this->db->where ('userid', $userid);
$this->db->order_by ('createdon', 'desc'); $this->db->order_by ('createdon', 'desc');
$query = $this->db->get ('log', $limit, $offset); $query = $this->db->get ('log', $limit, $offset);

View File

@ -123,7 +123,7 @@ $this->load->view (
<div class="mainarea" id="log_mainarea"> <div class="mainarea" id="log_mainarea">
<div class="title" id="log_mainarea_title"> <div class="title" id="log_mainarea_title">
<?= $this->lang->line ('Change log') ?> <?= anchor ("site/log", $this->lang->line ('Change log')) ?>
</div> </div>
<?php if ($login['sysadmin?'] && isset($site)): ?> <?php if ($login['sysadmin?'] && isset($site)): ?>
@ -206,14 +206,22 @@ $this->load->view (
if ($log['action'] == 'revpropchange') if ($log['action'] == 'revpropchange')
{ {
$fmt = $this->lang->line ('MSG_LOG_REVPROP_CHANGE_BY'); $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'] //$code['action']
} }
else else
{ {
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); '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>'; print '</span>';
@ -267,7 +275,11 @@ $this->load->view (
print '<span class="description">'; print '<span class="description">';
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); '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 '</span>';
} }

View File

@ -132,13 +132,20 @@ foreach ($latest_projects as $project)
if ($log['action'] == 'revpropchange') if ($log['action'] == 'revpropchange')
{ {
$fmt = $this->lang->line ('MSG_LOG_REVPROP_CHANGE_BY'); $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 else
{ {
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); '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>'; print '</span>';
@ -203,7 +210,10 @@ foreach ($latest_projects as $project)
print '<span class="description">'; print '<span class="description">';
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); '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 '</span>';
print '</td>'; print '</td>';