Commit f4040586 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use clean urls in admin stats area



Bug #1006634, part 3

Simplifies the view query and passes the results through
get_extra_view_info to pull out the urls.

Change-Id: I8c39548b00b02634193e78fb72ff0e5d4215ce68
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent c433512b
...@@ -754,14 +754,8 @@ function view_stats_table($limit, $offset) { ...@@ -754,14 +754,8 @@ function view_stats_table($limit, $offset) {
$viewdata = get_records_sql_assoc( $viewdata = get_records_sql_assoc(
"SELECT "SELECT
v.id, v.title, v.owner, v.group, v.institution, v.visits, v.id, v.title, v.owner, v.group, v.institution, v.visits, v.type, v.ownerformat, v.urlid
u.id AS userid, u.firstname, u.lastname,
g.id AS groupid, g.name AS groupname,
i.displayname AS institutionname
FROM {view} v 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 OR \"owner\" IS NULL) AND v.type != ? WHERE (v.owner != 0 OR \"owner\" IS NULL) AND v.type != ?
ORDER BY v.visits DESC, v.title, v.id", ORDER BY v.visits DESC, v.title, v.id",
array('dashboard'), array('dashboard'),
...@@ -769,23 +763,27 @@ function view_stats_table($limit, $offset) { ...@@ -769,23 +763,27 @@ function view_stats_table($limit, $offset) {
$limit $limit
); );
require_once('view.php');
require_once('group.php');
View::get_extra_view_info($viewdata, false, false);
safe_require('artefact', 'comment'); safe_require('artefact', 'comment');
$comments = ArtefactTypeComment::count_comments(array_keys($viewdata)); $comments = ArtefactTypeComment::count_comments(array_keys($viewdata));
foreach ($viewdata as &$v) { foreach ($viewdata as &$v) {
$v = (object) $v;
if ($v->owner) { if ($v->owner) {
$v->ownername = display_name($v->owner); $v->ownername = display_name($v->user);
$v->ownerurl = 'user/view.php?id=' . $v->userid; $v->ownerurl = profile_url($v->user);
}
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) { else {
$v->ownername = $v->institutionname; $v->ownername = $v->sharedby;
if ($v->group) {
$v->ownerurl = group_homepage_url($v->groupdata);
}
else if ($v->institution && $v->institution != 'mahara') {
$v->ownerurl = get_config('wwwroot') . 'institution/index.php?institution=' . $v->institution;
}
} }
$v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0; $v->comments = isset($comments[$v->id]) ? (int) $comments[$v->id]->comments : 0;
} }
......
{foreach from=$data item=item key=key} {foreach from=$data item=item key=key}
<tr class="{cycle values='r0,r1'}"> <tr class="{cycle values='r0,r1'}">
<td>{$offset + $dwoo.foreach.default.iteration}</td> <td>{$offset + $dwoo.foreach.default.iteration}</td>
<td><a href="{$WWWROOT}view/view.php?id={$item->id}">{$item->title}</a></td> <td><a href="{$item->fullurl}">{$item->title}</a></td>
<td>{if $item->ownerurl}<a href="{$WWWROOT}{$item->ownerurl}">{/if}{$item->ownername}{if $item->ownerurl}</a>{/if}</td> <td>{if $item->ownerurl}<a href="{$item->ownerurl}">{/if}{$item->ownername}{if $item->ownerurl}</a>{/if}</td>
<td class="right">{$item->visits}</td> <td class="right">{$item->visits}</td>
<td class="center">{$item->comments}</td> <td class="center">{$item->comments}</td>
</tr> </tr>
......
Supports Markdown
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