Commit 0fd04e12 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use clean view urls on tags page



Bug #1006634, part 3

Views and artefacts are pulled from the db together in a UNION query.
We can't simply pass the whole list of records through to a View
method - it's easier to generate the urls one by one in
build_portfolio_search_html.

Change-Id: I59b1ab91e141611d4a41e60b28a0bfdf13167749
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent f51a7b57
......@@ -2862,12 +2862,15 @@ function cron_sitemap_daily() {
function build_portfolio_search_html(&$data) {
global $THEME;
$artefacttypes = get_records_assoc('artefact_installed_type');
require_once('view.php');
foreach ($data->data as &$item) {
$item->ctime = format_date($item->ctime);
if ($item->type == 'view') {
$item->typestr = get_string('view');
$item->icon = $THEME->get_url('images/view.gif');
$item->url = get_config('wwwroot') . 'view/view.php?id=' . $item->id;
$v = new View(0, (array)$item);
$v->set('dirty', false);
$item->url = $v->get_url();
}
else { // artefact
safe_require('artefact', $artefacttypes[$item->artefacttype]->plugin);
......
......@@ -889,11 +889,13 @@ class PluginSearchInternal extends PluginSearch {
}
$from = "FROM (
(SELECT a.id, a.title, a.description, 'artefact' AS type, a.artefacttype, " . db_format_tsfield('a.ctime', 'ctime') . "
(SELECT a.id, a.title, a.description, 'artefact' AS type, a.artefacttype, " . db_format_tsfield('a.ctime', 'ctime') . ",
a.owner, a.group, a.institution, NULL AS urlid
FROM {artefact} a JOIN {artefact_tag} at ON (a.id = at.artefact)
WHERE a.owner = ?" . $artefacttypefilter . ")
UNION
(SELECT v.id, v.title, v.description, 'view' AS type, NULL AS artefacttype, " . db_format_tsfield('v.ctime', 'ctime') . "
(SELECT v.id, v.title, v.description, 'view' AS type, NULL AS artefacttype, " . db_format_tsfield('v.ctime', 'ctime') . ",
v.owner, v.group, v.institution, v.urlid
FROM {view} v JOIN {view_tag} vt ON (v.id = vt.view)
WHERE v.owner = ? " . $viewfilter . ")
) p";
......
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