enhanced user-home and user-log views to show info for a specified user

This commit is contained in:
hyung-hwan 2016-12-02 14:28:04 +00:00
parent 7dfb4fbd7a
commit 779b16c867
13 changed files with 93 additions and 208 deletions

View File

@ -493,15 +493,20 @@ class Site extends Controller
$this->load->view ($this->VIEW_LOG, $data); $this->load->view ($this->VIEW_LOG, $data);
} }
/*
function userlog ($userid = '', $offset = 0) function userlog ($userid = '', $offset = 0)
{ {
if ($userid != '')
$dec_userid = $this->converter->HexToAscii($userid);
else $dec_userid = $userid;
$login = $this->login->getUser (); $login = $this->login->getUser ();
$this->load->library ('pagination'); $this->load->library ('pagination');
$this->load->model ('LogModel', 'logs'); $this->load->model ('LogModel', 'logs');
$this->load->model ('SiteModel', 'sites'); $this->load->model ('SiteModel', 'sites');
$site = $this->sites->get ($this->config->config['language']); $site = $this->sites->get ($this->config->config['language']);
if ($site === FALSE) if ($site === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -511,7 +516,7 @@ class Site extends Controller
} }
if ($site === NULL && CODEPOT_DEFAULT_SITE_LANGUAGE != '') 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) if ($site === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -527,7 +532,7 @@ class Site extends Controller
$this->logs->purge (); $this->logs->purge ();
} }
$num_log_entries = $this->logs->getNumEntries ('', $userid); $num_log_entries = $this->logs->getNumEntries ('', $dec_userid);
if ($num_log_entries === FALSE) if ($num_log_entries === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -536,14 +541,14 @@ class Site extends Controller
return; return;
} }
$pagecfg['base_url'] = site_url() . "/site/userlog/$userid/"; $pagecfg['base_url'] = site_url() . "/site/userlog/{$userid}/";
$pagecfg['total_rows'] = $num_log_entries; $pagecfg['total_rows'] = $num_log_entries;
$pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE; $pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE;
$pagecfg['uri_segment'] = 4; $pagecfg['uri_segment'] = 4;
$pagecfg['first_link'] = $this->lang->line('First'); $pagecfg['first_link'] = $this->lang->line('First');
$pagecfg['last_link'] = $this->lang->line('Last'); $pagecfg['last_link'] = $this->lang->line('Last');
$log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], '', $userid); $log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], '', $dec_userid);
if ($log_entries === FALSE) if ($log_entries === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -561,6 +566,7 @@ class Site extends Controller
$this->load->view ($this->VIEW_LOG, $data); $this->load->view ($this->VIEW_LOG, $data);
} }
*/
function wiki ($xlink = '') function wiki ($xlink = '')
{ {

View File

@ -37,6 +37,7 @@ class User extends Controller
} }
if ($userid == '') $userid = $login['id']; if ($userid == '') $userid = $login['id'];
else $userid = $this->converter->HexToAscii ($userid);
if ($userid == '') if ($userid == '')
{ {
redirect ('site/home'); redirect ('site/home');
@ -63,6 +64,7 @@ class User extends Controller
{ {
$data['login'] = $login; $data['login'] = $login;
$data['projects'] = $projects; $data['projects'] = $projects;
$data['target_userid'] = $userid;
$data['issues'] = $issues; $data['issues'] = $issues;
$data['issue_type_array'] = $this->issuehelper->_get_type_array($this->lang); $data['issue_type_array'] = $this->issuehelper->_get_type_array($this->lang);
$data['issue_status_array'] = $this->issuehelper->_get_status_array($this->lang); $data['issue_status_array'] = $this->issuehelper->_get_status_array($this->lang);
@ -71,48 +73,18 @@ class User extends Controller
} }
} }
function issue () function log ($userid = '', $offset = 0)
{ {
$login = $this->login->getUser (); $login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ('main/signin');
if ($login['id'] == '')
{ {
redirect ('site/home'); redirect ('main/signin');
return; return;
} }
$this->load->library ('IssueHelper', 'issuehelper'); if ($userid == '') $userid = $login['id'];
$this->lang->load ('issue', CODEPOT_LANG); else $userid = $this->converter->HexToAscii ($userid);
if ($userid == '')
$this->load->model ('ProjectModel', 'projects');
$this->load->model ('IssueModel', 'issues');
$issues = $this->issues->getMyIssues (
$login['id'], $this->issuehelper->_get_open_status_array($this->lang));
if ($issues === FALSE)
{
$data['login'] = $login;
$data['message'] = 'DATABASE ERROR';
$this->load->view ($this->VIEW_ERROR, $data);
}
else
{
$data['login'] = $login;
$data['issues'] = $issues;
$data['issue_type_array'] = $this->issuehelper->_get_type_array($this->lang);
$data['issue_status_array'] = $this->issuehelper->_get_status_array($this->lang);
$data['issue_priority_array'] = $this->issuehelper->_get_priority_array($this->lang);
$this->load->view ($this->VIEW_ISSUE, $data);
}
}
function log ($offset = 0)
{
$login = $this->login->getUser ();
if ($login['id'] == '')
{ {
redirect ('site/home'); redirect ('site/home');
return; return;
@ -121,9 +93,10 @@ class User extends Controller
$this->load->model ('ProjectModel', 'projects'); $this->load->model ('ProjectModel', 'projects');
$user = new stdClass(); $user = new stdClass();
$user->id = $login['id']; $user->id = $userid;
$user->xid = $this->converter->AsciiToHex($userid);
$myprojs = $this->projects->getMyProjects ($login['id']); $myprojs = $this->projects->getMyProjects ($user->id);
if ($myprojs === FALSE) if ($myprojs === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -145,7 +118,7 @@ class User extends Controller
for ($i = 0; $i < $numprojs; $i++) for ($i = 0; $i < $numprojs; $i++)
$projids[$i] = $myprojs[$i]->id; $projids[$i] = $myprojs[$i]->id;
$num_log_entries = $this->logs->getNumEntries ($projids); $num_log_entries = $this->logs->getNumEntries ($projids, $userid);
if ($num_log_entries === FALSE) if ($num_log_entries === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -155,14 +128,14 @@ class User extends Controller
return; return;
} }
$pagecfg['base_url'] = site_url() . "/user/log/"; $pagecfg['base_url'] = site_url() . "/user/log/{$user->xid}/";
$pagecfg['total_rows'] = $num_log_entries; $pagecfg['total_rows'] = $num_log_entries;
$pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE; $pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE;
$pagecfg['uri_segment'] = 3; $pagecfg['uri_segment'] = 4;
$pagecfg['first_link'] = $this->lang->line('First'); $pagecfg['first_link'] = $this->lang->line('First');
$pagecfg['last_link'] = $this->lang->line('Last'); $pagecfg['last_link'] = $this->lang->line('Last');
$log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], $projids); $log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], $projids, $userid);
if ($log_entries === FALSE) if ($log_entries === FALSE)
{ {
$data['login'] = $login; $data['login'] = $login;
@ -290,7 +263,6 @@ class User extends Controller
function icon ($userid = '') function icon ($userid = '')
{ {
// TODO: ETag, If-None-Match???
$userid_len = strlen($userid); $userid_len = strlen($userid);
if ($userid_len > 0) if ($userid_len > 0)
{ {

View File

@ -240,11 +240,10 @@ class LdapLoginModel extends LoginModel
} }
$email = ''; $email = '';
if (CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME != '') if (CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME != '')
{ {
$filter = '(' . CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME . '=*)'; $filter = '(objectClass=*)';
$r = @ldap_search ($ldap, $f_userid, $filter, array(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME)); $r = @ldap_read ($ldap, $f_userid, $filter, array(CODEPOT_LDAP_MAIL_ATTRIBUTE_NAME));
if ($r !== FALSE) if ($r !== FALSE)
{ {
$e = @ldap_get_entries($ldap, $r); $e = @ldap_get_entries($ldap, $r);

View File

@ -66,7 +66,6 @@ class LogModel extends Model
$commits = array (); $commits = array ();
foreach ($result as $row) foreach ($result as $row)
{ {
/* $row->project must be equal to $repo */ /* $row->project must be equal to $repo */
$commits[$count]['createdon'] = $row->createdon; $commits[$count]['createdon'] = $row->createdon;
$commits[$count]['type'] = $row->type; $commits[$count]['type'] = $row->type;

View File

@ -30,7 +30,6 @@ www_DATA = \
site_show.php \ site_show.php \
taskbar.php \ taskbar.php \
user_home.php \ user_home.php \
user_issue.php \
user_settings.php \ user_settings.php \
wiki_edit.php \ wiki_edit.php \
wiki_editx.php \ wiki_editx.php \

View File

@ -175,7 +175,6 @@ www_DATA = \
site_show.php \ site_show.php \
taskbar.php \ taskbar.php \
user_home.php \ user_home.php \
user_issue.php \
user_settings.php \ user_settings.php \
wiki_edit.php \ wiki_edit.php \
wiki_editx.php \ wiki_editx.php \

View File

@ -66,6 +66,7 @@ $(function () {
if (isset($project)) if (isset($project))
{ {
$pagetype = 'project'; $pagetype = 'project';
$pageobjname = 'project';
$pageid = ''; $pageid = '';
$pageobj = $project; $pageobj = $project;
$banner = NULL; $banner = NULL;
@ -75,6 +76,7 @@ else if (isset($site))
if ($login['sysadmin?']) if ($login['sysadmin?'])
{ {
$pagetype = 'site'; $pagetype = 'site';
$pageobjname = 'site';
$pageid = 'log'; $pageid = 'log';
$pageobj = $site; $pageobj = $site;
$banner = NULL; $banner = NULL;
@ -82,6 +84,7 @@ else if (isset($site))
else else
{ {
$pagetype = ''; $pagetype = '';
$pageobjname = '';
$pageid = ''; $pageid = '';
$pageobj = NULL; $pageobj = NULL;
$banner = $site->name; $banner = $site->name;
@ -90,31 +93,35 @@ else if (isset($site))
else if (isset($user)) else if (isset($user))
{ {
$pagetype = 'user'; $pagetype = 'user';
$pageobjname = 'user';
$pageid = ''; $pageid = '';
$pageobj = $user; $pageobj = $user;
$banner = NULL; $banner = NULL;
if ($user->id != $login['id']) $pagetype = 'user-other';
} }
else else
{ {
$pagetype = ''; $pagetype = '';
$pageobjname = '';
$pageid = ''; $pageid = '';
$pageobj = NULL; $pageobj = NULL;
$banner = NULL; $banner = NULL;
} }
$this->load->view ( $this->load->view (
'projectbar', 'projectbar',
array ( array (
'banner' => $banner, 'banner' => $banner,
'page' => array ( 'page' => array (
'type' => $pagetype, 'type' => $pagetype,
'id' => $pageid, 'id' => $pageid,
$pagetype => $pageobj $pageobjname => $pageobj
), ),
'ctxmenuitems' => array () 'ctxmenuitems' => array ()
) )
); );
?> ?>
@ -205,6 +212,8 @@ $this->load->view (
print '<td class="details">'; print '<td class="details">';
print '<span class="description">'; print '<span class="description">';
$xauthor = $this->converter->AsciiToHex ($code['author']);
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');
@ -212,7 +221,7 @@ $this->load->view (
printf ( printf (
htmlspecialchars ($fmt), htmlspecialchars ($fmt),
htmlspecialchars ($code['propname']), htmlspecialchars ($code['propname']),
anchor ("/site/userlog/{$code['author']}", htmlspecialchars ($code['author']))); anchor ("/user/log/{$xauthor}", htmlspecialchars ($code['author'])));
//$code['action'] //$code['action']
} }
else else
@ -223,7 +232,7 @@ $this->load->view (
//print htmlspecialchars (sprintf($fmt, $code['author'])); //print htmlspecialchars (sprintf($fmt, $code['author']));
printf ( printf (
htmlspecialchars ($fmt), htmlspecialchars ($fmt),
anchor ("/site/userlog/{$code['author']}", htmlspecialchars ($code['author']))); anchor ("/user/log/{$xauthor}", htmlspecialchars ($code['author'])));
} }
print '</span>'; print '</span>';
@ -278,7 +287,8 @@ $this->load->view (
$fmt = $this->lang->line ( $fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY'); 'MSG_LOG_'.strtoupper($log['action']).'_BY');
printf ($fmt, anchor ("/site/userlog/{$log['userid']}", htmlspecialchars($log['userid']))); $xuserid = $this->converter->AsciiToHex($log['userid']);
printf ($fmt, anchor ("/user/log/{$xuserid}", htmlspecialchars($log['userid'])));
print '</span>'; print '</span>';
} }

View File

@ -176,7 +176,12 @@ $this->load->view (
print "<li>{$icon_src}{$m}</li>"; print "<li>{$icon_src}{$m}</li>";
*/ */
$user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($m)); $user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($m));
print "<li><img src='{$user_icon_url}' class='user_icon_img' />{$m}</li>"; //print "<li><img src='{$user_icon_url}' class='user_icon_img' />{$m}</li>";
$user_home_url = "/user/home/" . $this->converter->AsciiToHex($m);
print "<li>";
print anchor ($user_home_url, "<img src='{$user_icon_url}' class='user_icon_img' />{$m}");
print "</li>";
} }
?> ?>
</ul> </ul>

View File

@ -37,9 +37,9 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
$site = $page[$type]; $site = $page[$type];
print htmlspecialchars($site->name); print htmlspecialchars($site->name);
} }
else if ($type == 'user') else if ($type == 'user' || $type == 'user-other')
{ {
$user = $page[$type]; $user = $page['user'];
print htmlspecialchars($user->id); print htmlspecialchars($user->id);
} }
else print htmlspecialchars(CODEPOT_DEFAULT_SITE_NAME); else print htmlspecialchars(CODEPOT_DEFAULT_SITE_NAME);
@ -123,8 +123,8 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
else if ($type == 'user') else if ($type == 'user')
{ {
$menuitems = array ( $menuitems = array (
array ("user/home", $con->lang->line('Overview')), array ("user/home/{$user->xid}", $con->lang->line('Overview')),
array ("user/log", $con->lang->line('Log')), array ("user/log/{$user->xid}", $con->lang->line('Log')),
array ("user/settings", $con->lang->line('Settings')) array ("user/settings", $con->lang->line('Settings'))
); );
@ -137,6 +137,22 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
print anchor ($menulink, $item[1], $extra); print anchor ($menulink, $item[1], $extra);
} }
} }
else if ($type == 'user-other')
{
$menuitems = array (
array ("user/home/{$user->xid}", $con->lang->line('Overview')),
array ("user/log/{$user->xid}", $con->lang->line('Log'))
);
foreach ($menuitems as $item)
{
$menuid = substr ($item[0], strpos($item[0], '/') + 1);
$extra = ($menuid == $id)? 'class="selected button"': 'class="button"';
$menulink = $item[0];
print anchor ($menulink, $item[1], $extra);
}
}
else print '&nbsp;'; else print '&nbsp;';
print '</div>'; print '</div>';

View File

@ -392,23 +392,25 @@ $this->load->view (
print '<td colspan="2" class="details">'; print '<td colspan="2" class="details">';
print '<span class="description">'; print '<span class="description">';
$xauthor = $this->converter->AsciiToHex($x['author']);
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 ( printf (
htmlspecialchars ($fmt), htmlspecialchars ($fmt),
htmlspecialchars ($x['propname']), htmlspecialchars ($x['propname']),
anchor ("/site/userlog/{$x['author']}", htmlspecialchars ($x['author']))); anchor ("/user/log/{$xauthor}", 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']));
printf ( printf (
htmlspecialchars ($fmt), htmlspecialchars ($fmt),
anchor ("/site/userlog/{$x['author']}", htmlspecialchars ($x['author']))); anchor ("/user/log/{$xauthor}", htmlspecialchars ($x['author'])));
} }
print '</span>'; print '</span>';
@ -474,10 +476,10 @@ $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'])); $xuserid = $this->converter->AsciiToHex ($log['userid']);
printf ( printf (
htmlspecialchars ($fmt), htmlspecialchars ($fmt),
anchor ("/site/userlog/{$log['userid']}", htmlspecialchars ($log['userid']))); anchor ("/user/log/{$xuserid}", htmlspecialchars ($log['userid'])));
print '</span>'; print '</span>';
print '</td>'; print '</td>';

View File

@ -41,7 +41,17 @@ $(function () {
<?php <?php
$user = new stdClass(); $user = new stdClass();
$user->id = $login['id']; if ($target_userid == $login['id'])
{
$user->id = $login['id'];
$projectbar_type = 'user';
}
else
{
$user->id = $target_userid;
$projectbar_type = 'user-other';
}
$user->xid = $this->converter->AsciiTohex($user->id);
$this->load->view ( $this->load->view (
'projectbar', 'projectbar',
@ -49,7 +59,7 @@ $this->load->view (
'banner' => NULL, 'banner' => NULL,
'page' => array ( 'page' => array (
'type' => 'user', 'type' => $projectbar_type,
'id' => 'issues', 'id' => 'issues',
'user' => $user, 'user' => $user,
), ),

View File

@ -1,133 +0,0 @@
<html>
<?php
$num_issues = count($issues);
$issues_by_projects = array();
foreach ($issues as $issue)
{
if (!array_key_exists ($issue->projectid, $issues_by_projects))
$issues_by_projects[$issue->projectid] = array();
$arr = &$issues_by_projects[$issue->projectid];
array_push ($arr, $issue);
$unique_projects = array_keys ($issues_by_projects);
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/user.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/font-awesome.min.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.min.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
<script type="text/javascript">
$(function () {
<?php
for ($i = 0; $i < count($unique_projects); $i++)
{
printf ('$("#user_home_mainarea_open_issues_%d").accordion({collapsible:true, heightStyle:"content"}); ', $i);
}
?>
});
</script>
<title><?php print htmlspecialchars($login['id'])?></title>
</head>
<body>
<div class="content" id="user_home_content">
<!---------------------------------------------------------------------------->
<?php $this->load->view ('taskbar'); ?>
<!---------------------------------------------------------------------------->
<?php
$user = new stdClass();
$user->id = $login['id'];
$this->load->view (
'projectbar',
array (
'banner' => NULL,
'page' => array (
'type' => 'user',
'id' => 'issues',
'user' => $user,
),
'ctxmenuitems' => array ()
)
);
?>
<!---------------------------------------------------------------------------->
<div class="mainarea" id="user_home_mainarea">
<div id="user_home_mainarea_result" class="result">
<div id="user_home_mainarea_open_issues">
<?php
for ($i = 0; $i < count($unique_projects); $i++)
{
printf ('<div id="user_home_mainarea_open_issues_%d" class="collapsible-box">', $i);
$issues = &$issues_by_projects[$unique_projects[$i]];
printf ('<div class="collapsible-box-header">%s</div>', htmlspecialchars($unique_projects[$i]));
print '<ul>';
foreach ($issues as $issue)
{
$pro = $issue->projectid;
$xid = $this->converter->AsciiToHex ((string)$issue->id);
$anc = anchor ("issue/show/{$issue->projectid}/{$xid}", '#' . htmlspecialchars($issue->id));
$status = htmlspecialchars(
array_key_exists($issue->status, $issue_status_array)?
$issue_status_array[$issue->status]: $issue->status);
$type = htmlspecialchars(
array_key_exists($issue->type, $issue_type_array)?
$issue_type_array[$issue->type]: $issue->type);
$sum = htmlspecialchars ($issue->summary);
print "<li>{$pro} {$anc} {$type} {$status} - {$sum}</li>";
}
print '</ul>';
print '</div>';
}
?>
</div>
</div> <!-- user_home_mainarea_result -->
</div> <!-- user_home_mainarea -->
<div class='codepot-footer-pusher'></div> <!-- for sticky footer -->
</div> <!-- user_home_content -->
<!---------------------------------------------------------------------------->
<?php $this->load->view ('footer'); ?>
<!---------------------------------------------------------------------------->
</body>
</html>

View File

@ -29,6 +29,7 @@
<?php <?php
$user = new stdClass(); $user = new stdClass();
$user->id = $login['id']; $user->id = $login['id'];
$user->xid = $this->converter->AsciiToHex($user->id);
$this->load->view ( $this->load->view (
'projectbar', 'projectbar',