Commit 30ee7de9 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Link view owner names, escape view/group/user names in tables


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent e40fb07a
......@@ -311,7 +311,7 @@ function user_statistics($limit, $offset, &$sitedata) {
'admin',
$sitedata['viewsperuser'],
get_config('wwwroot') . 'user/view.php?id=' . $maxviews->id,
display_name($maxviews, null, true),
hsc(display_name($maxviews, null, true)),
$maxviews->views
);
}
......@@ -332,7 +332,7 @@ function user_statistics($limit, $offset, &$sitedata) {
'admin',
$sitedata['groupmemberaverage'],
get_config('wwwroot') . 'user/view.php?id=' . $maxgroups->id,
display_name($maxgroups, null, true),
hsc(display_name($maxgroups, null, true)),
$maxgroups->groups
);
}
......@@ -351,7 +351,7 @@ function user_statistics($limit, $offset, &$sitedata) {
'admin',
display_size(get_field('usr', 'AVG(quotaused)', 'deleted', 0)),
get_config('wwwroot') . 'user/view.php?id=' . $maxquotaused->id,
display_name($maxquotaused, null, true),
hsc(display_name($maxquotaused, null, true)),
display_size($maxquotaused->quotaused)
);
......@@ -714,7 +714,7 @@ function view_statistics($limit, $offset) {
}
function view_stats_table($limit, $offset) {
$count = count_records_select('view', 'owner != 0');
$count = count_records_select('view', 'owner != 0 OR owner IS NULL');
$pagination = build_pagination(array(
'id' => 'stats_pagination',
......@@ -740,12 +740,14 @@ function view_stats_table($limit, $offset) {
$viewdata = get_records_sql_assoc(
"SELECT
v.id, v.title, v.owner, v.group, v.institution, v.visits,
u.firstname, u.lastname
u.id AS userid, u.firstname, u.lastname,
g.id AS groupid, g.name AS groupname,
i.displayname AS institutionname
FROM {view} v
LEFT JOIN {usr} u ON v.owner = u.id
LEFT JOIN {group} g ON v.group = g.id
LEFT JOIN {institution} i ON v.institution = i.name
WHERE v.owner != 0
WHERE v.owner != 0 OR owner IS NULL
ORDER BY v.visits DESC",
array(),
$offset,
......@@ -756,7 +758,20 @@ function view_stats_table($limit, $offset) {
$comments = ArtefactTypeComment::count_comments(array_keys($viewdata));
foreach ($viewdata as &$v) {
$v->author = $v->owner ? display_name($v->owner) : null;
if ($v->owner) {
$v->ownername = display_name($v->owner);
$v->ownerurl = 'user/view.php?id=' . $v->userid;
}
else if ($v->group) {
$v->ownername = $v->groupname;
$v->ownerurl = 'group/view.php?id=' . $v->groupid;
}
else if ($v->institution == 'mahara') {
$v->ownername = get_config('sitename');
}
else if ($v->institution) {
$v->ownername = $v->institutionname;
}
$v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0;
}
......
{foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}">
<td>{$offset + $dwoo.foreach.default.iteration}</td>
<td><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name}</a></td>
<td><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name|escape}</a></td>
<td class="center">{$item->members}</td>
<td class="center">{$item->views}</td>
<td class="center">{$item->forums}</td>
......
{foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}">
<td>{$offset + $dwoo.foreach.default.iteration}</td>
<td><a href="{$WWWROOT}view/view.php?id={$item->id}">{$item->title}</a></td>
<td>{$item->author}</td>
<td><a href="{$WWWROOT}view/view.php?id={$item->id}">{$item->title|escape}</a></td>
<td>{if $item->ownerurl}<a href="{$WWWROOT}{$item->ownerurl}">{/if}{$item->ownername|escape}{if $item->ownerurl}</a>{/if}</td>
<td class="center">{$item->visits}</td>
<td class="center">{$item->comments}</td>
</tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment