Commit 6636a154 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge "Bug 1826788: Allow tags on institutions / group items still show"

parents f80330c3 a4a8e6ae
......@@ -144,14 +144,40 @@ function get_all_tags_for_user($query = null, $limit = null, $offset = null, $in
// get all the institution tags the user can use
$values = array($userid);
if ($USER->get('institutions')) {
$userinstitutiontags = "
UNION ALL
SELECT t.tag, 0 AS count, NULL AS prefix
FROM {tag} t
JOIN {institution} i ON i.name = t.ownerid AND t.ownertype = 'institution'
JOIN {usr_institution} ui ON ui.institution = i.name AND ui.usr = ?
WHERE t.resourcetype IN ('artefact', 'view', 'collection', 'blocktype') AND tag NOT LIKE ('tagid_%')";
$values[] = $userid;
}
else if ($USER->get('admin')) {
$userinstitutiontags = "
UNION ALL
SELECT t.tag, 0 AS count, NULL AS prefix
FROM {tag} t
WHERE t.ownertype = 'institution'
AND t.resourcetype IN ('artefact', 'view', 'collection', 'blocktype') AND tag NOT LIKE ('tagid_%')";
}
else {
$userinstitutiontags = "
UNION ALL
SELECT t.tag, 0 AS count, NULL AS prefix
FROM {tag} t
WHERE t.ownertype = 'institution' AND t.ownerid = 'mahara'
AND t.resourcetype IN ('artefact', 'view', 'collection', 'blocktype') AND tag NOT LIKE ('tagid_%')";
}
$values[] = $userid;
if ($USER->get('admin') && isset($institution)) {
$values[] = $institution;
$insttagsforuser = "
UNION ALL
SELECT t.tag, 0 AS count, i.displayname AS prefix
FROM {tag} t
JOIN {institution} i ON i.name = t.ownerid AND i.tags = 1 AND t.resourcetype='institution' AND i.name = ?
WHERE t.resourcetype != 'usr'";
JOIN {institution} i ON i.name = t.ownerid AND i.tags = 1 AND t.resourcetype='institution' AND i.name = ?";
}
else {
$values[] = $userid;
......@@ -160,8 +186,7 @@ function get_all_tags_for_user($query = null, $limit = null, $offset = null, $in
SELECT t.tag, 0 AS count, i.displayname AS prefix
FROM {tag} t
JOIN {institution} i ON i.name = t.ownerid AND i.tags = 1 AND t.resourcetype='institution'
JOIN {usr_institution} ui ON ui.institution = i.name AND ui.usr = ?
WHERE t.resourcetype != 'usr'";
JOIN {usr_institution} ui ON ui.institution = i.name AND ui.usr = ?";
}
$querystr = '';
......@@ -178,6 +203,7 @@ function get_all_tags_for_user($query = null, $limit = null, $offset = null, $in
$sql = "
SELECT tag, SUM(count) AS count, prefix
FROM (
-- Selecting tags used in user section that you own
SELECT
(CASE
WHEN t.tag LIKE 'tagid_%' THEN t2.tag
......@@ -185,9 +211,19 @@ function get_all_tags_for_user($query = null, $limit = null, $offset = null, $in
END) AS tag, COUNT(*) AS count, i.displayname AS prefix
FROM {tag} t
LEFT JOIN {tag} t2 ON t2.id" . $typecast . " = SUBSTRING(t.tag, 7)
LEFT JOIN {institution} i ON i.name = t2.ownerid AND t2.resourcetype='institution'
LEFT JOIN {institution} i ON i.name = t2.ownerid AND t2.resourcetype = 'institution'
WHERE t.editedby=? AND t.resourcetype IN ('artefact', 'view', 'collection', 'blocktype')
GROUP BY 1, 3
-- Selecting tags used in institution section that you belong to
" . $userinstitutiontags . "
-- Selecting tags used in groups that you belong to
UNION ALL
SELECT t.tag, 0 AS count, NULL AS prefix
FROM {tag} t
JOIN {group} g ON g.id" . $typecast . " = t.ownerid AND t.ownertype='group'
JOIN {group_member} gm ON gm.group = g.id AND gm.member = ?
WHERE t.resourcetype IN ('artefact', 'view', 'collection', 'blocktype') AND tag NOT LIKE ('tagid_%')
-- Selecting the special 'Institution tags' tags that you can see
" . $insttagsforuser . "
) tags
" . $querystr . "
......
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