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,8 +493,13 @@ class Site extends Controller
$this->load->view ($this->VIEW_LOG, $data);
}
/*
function userlog ($userid = '', $offset = 0)
{
if ($userid != '')
$dec_userid = $this->converter->HexToAscii($userid);
else $dec_userid = $userid;
$login = $this->login->getUser ();
$this->load->library ('pagination');
@ -527,7 +532,7 @@ class Site extends Controller
$this->logs->purge ();
}
$num_log_entries = $this->logs->getNumEntries ('', $userid);
$num_log_entries = $this->logs->getNumEntries ('', $dec_userid);
if ($num_log_entries === FALSE)
{
$data['login'] = $login;
@ -536,14 +541,14 @@ class Site extends Controller
return;
}
$pagecfg['base_url'] = site_url() . "/site/userlog/$userid/";
$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'] = 4;
$pagecfg['first_link'] = $this->lang->line('First');
$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)
{
$data['login'] = $login;
@ -561,6 +566,7 @@ class Site extends Controller
$this->load->view ($this->VIEW_LOG, $data);
}
*/
function wiki ($xlink = '')
{

View File

@ -37,6 +37,7 @@ class User extends Controller
}
if ($userid == '') $userid = $login['id'];
else $userid = $this->converter->HexToAscii ($userid);
if ($userid == '')
{
redirect ('site/home');
@ -63,6 +64,7 @@ class User extends Controller
{
$data['login'] = $login;
$data['projects'] = $projects;
$data['target_userid'] = $userid;
$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);
@ -71,48 +73,18 @@ class User extends Controller
}
}
function issue ()
function log ($userid = '', $offset = 0)
{
$login = $this->login->getUser ();
if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '')
redirect ('main/signin');
if ($login['id'] == '')
{
redirect ('site/home');
redirect ('main/signin');
return;
}
$this->load->library ('IssueHelper', 'issuehelper');
$this->lang->load ('issue', CODEPOT_LANG);
$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'] == '')
if ($userid == '') $userid = $login['id'];
else $userid = $this->converter->HexToAscii ($userid);
if ($userid == '')
{
redirect ('site/home');
return;
@ -121,9 +93,10 @@ class User extends Controller
$this->load->model ('ProjectModel', 'projects');
$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)
{
$data['login'] = $login;
@ -145,7 +118,7 @@ class User extends Controller
for ($i = 0; $i < $numprojs; $i++)
$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)
{
$data['login'] = $login;
@ -155,14 +128,14 @@ class User extends Controller
return;
}
$pagecfg['base_url'] = site_url() . "/user/log/";
$pagecfg['base_url'] = site_url() . "/user/log/{$user->xid}/";
$pagecfg['total_rows'] = $num_log_entries;
$pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE;
$pagecfg['uri_segment'] = 3;
$pagecfg['uri_segment'] = 4;
$pagecfg['first_link'] = $this->lang->line('First');
$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)
{
$data['login'] = $login;
@ -290,7 +263,6 @@ class User extends Controller
function icon ($userid = '')
{
// TODO: ETag, If-None-Match???
$userid_len = strlen($userid);
if ($userid_len > 0)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -176,7 +176,12 @@ $this->load->view (
print "<li>{$icon_src}{$m}</li>";
*/
$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>

View File

@ -37,9 +37,9 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
$site = $page[$type];
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);
}
else print htmlspecialchars(CODEPOT_DEFAULT_SITE_NAME);
@ -123,8 +123,8 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
else if ($type == 'user')
{
$menuitems = array (
array ("user/home", $con->lang->line('Overview')),
array ("user/log", $con->lang->line('Log')),
array ("user/home/{$user->xid}", $con->lang->line('Overview')),
array ("user/log/{$user->xid}", $con->lang->line('Log')),
array ("user/settings", $con->lang->line('Settings'))
);
@ -137,6 +137,22 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems)
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;';
print '</div>';

View File

@ -392,23 +392,25 @@ $this->load->view (
print '<td colspan="2" class="details">';
print '<span class="description">';
$xauthor = $this->converter->AsciiToHex($x['author']);
if ($log['action'] == 'revpropchange')
{
$fmt = $this->lang->line ('MSG_LOG_REVPROP_CHANGE_BY');
//print htmlspecialchars (sprintf($fmt, $x['propname'], $x['author']));
printf (
htmlspecialchars ($fmt),
htmlspecialchars ($x['propname']),
anchor ("/site/userlog/{$x['author']}", htmlspecialchars ($x['author'])));
anchor ("/user/log/{$xauthor}", htmlspecialchars ($x['author'])));
}
else
{
$fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY');
//print htmlspecialchars (sprintf($fmt, $x['author']));
printf (
htmlspecialchars ($fmt),
anchor ("/site/userlog/{$x['author']}", htmlspecialchars ($x['author'])));
anchor ("/user/log/{$xauthor}", htmlspecialchars ($x['author'])));
}
print '</span>';
@ -474,10 +476,10 @@ $this->load->view (
print '<span class="description">';
$fmt = $this->lang->line (
'MSG_LOG_'.strtoupper($log['action']).'_BY');
//print htmlspecialchars (sprintf($fmt, $log['userid']));
$xuserid = $this->converter->AsciiToHex ($log['userid']);
printf (
htmlspecialchars ($fmt),
anchor ("/site/userlog/{$log['userid']}", htmlspecialchars ($log['userid'])));
anchor ("/user/log/{$xuserid}", htmlspecialchars ($log['userid'])));
print '</span>';
print '</td>';

View File

@ -41,7 +41,17 @@ $(function () {
<?php
$user = new stdClass();
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 (
'projectbar',
@ -49,7 +59,7 @@ $this->load->view (
'banner' => NULL,
'page' => array (
'type' => 'user',
'type' => $projectbar_type,
'id' => 'issues',
'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
$user = new stdClass();
$user->id = $login['id'];
$user->xid = $this->converter->AsciiToHex($user->id);
$this->load->view (
'projectbar',