Commit c3b4dbc0 authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Fix bug with show tags for user tags (bug #802309)"

parents 9c206da5 f1175eba
......@@ -30,12 +30,25 @@ define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
if ($USER->is_logged_in()) {
$usertags = "";
if ($USER->get('admin')) {
$usertags = "
UNION ALL
SELECT tag,COUNT(*) AS count FROM {usr_tag} t INNER JOIN {usr} u ON t.usr=u.id GROUP BY 1";
}
else if ($admininstitutions = $USER->get('admininstitutions')) {
$insql = "'" . join("','", $admininstitutions) . "'";
$usertags = "
UNION ALL
SELECT tag,COUNT(*) AS count FROM {usr_tag} t INNER JOIN {usr} u ON t.usr=u.id INNER JOIN {usr_institution} ui ON ui.usr=u.id WHERE ui.institution IN ($insql) GROUP BY 1";
}
$result = get_records_sql_array("
SELECT tag, SUM(count) AS count
FROM (
SELECT tag,COUNT(*) AS count FROM {artefact_tag} t INNER JOIN {artefact} a ON t.artefact=a.id WHERE a.owner=? GROUP BY 1
UNION ALL
SELECT tag,COUNT(*) AS count FROM {view_tag} t INNER JOIN {view} v ON t.view=v.id WHERE v.owner=? GROUP BY 1
SELECT tag,COUNT(*) AS count FROM {view_tag} t INNER JOIN {view} v ON t.view=v.id WHERE v.owner=? GROUP BY 1" .
$usertags . "
) tags
GROUP BY tag
ORDER BY LOWER(tag)
......
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