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

New view 'type' column causing multiple results in view owner search

parent 76505827
......@@ -1676,23 +1676,23 @@ class View {
$sql = "
SELECT
'user' AS type,
'user' AS ownertype,
CASE WHEN u.preferredname IS NULL OR u.preferredname = '' THEN u.firstname || ' ' || u.lastname
ELSE u.preferredname END AS display,
CAST (u.id AS TEXT), COUNT(v.id)
FROM {usr} u INNER JOIN {view} v ON (v.owner = u.id)
WHERE u.deleted = 0 $tsql
GROUP BY type, display, u.id
GROUP BY ownertype, display, u.id
UNION
SELECT 'group' AS type, g.name AS display, CAST (g.id AS TEXT), COUNT(v.id)
SELECT 'group' AS ownertype, g.name AS display, CAST (g.id AS TEXT), COUNT(v.id)
FROM {group} g INNER JOIN {view} v ON (g.id = v.group)
WHERE g.deleted = 0 $tsql
GROUP BY type, display, g.id
GROUP BY ownertype, display, g.id
UNION
SELECT 'institution' AS type, i.displayname AS display, i.name AS id, COUNT(v.id)
SELECT 'institution' AS ownertype, i.displayname AS display, i.name AS id, COUNT(v.id)
FROM {institution} i INNER JOIN {view} v ON (i.name = v.institution)
WHERE TRUE $tsql
GROUP BY type, display, i.name ORDER BY display";
GROUP BY ownertype, display, i.name ORDER BY display";
$count = count_records_sql("SELECT COUNT(*) FROM ($sql) q $qsql", $ph);
$data = get_records_sql_array("SELECT * FROM ($sql) q $qsql", $ph, $offset, $limit);
......
......@@ -11,16 +11,16 @@
{foreach from=$results.data item=row}
<tr class="r{cycle values=0,1}">
<td>
{if $row->type == 'institution'}
{if $row->ownertype == 'institution'}
{$row->display|escape}
{elseif $row->type == 'group'}
{elseif $row->ownertype == 'group'}
<a href="{$WWWROOT}group/view.php?id={$row->id|escape}" target="_blank">{$row->display|escape}</a>
{else}
<a href="{$WWWROOT}user/view.php?id={$row->id|escape}" target="_blank">{$row->display|escape}</a>
{/if}
</td>
<td style="text-align: center;">{$row->count|escape}</td>
<td class="selectowner"><a href="{$viewurl}&amp;owntype={$row->type}&amp;ownid={$row->id}">{str tag=listviews section=view}</a>&nbsp;<img src="{theme_path location='images/icon_fieldset_left.gif'}" alt=""></td>
<td class="selectowner"><a href="{$viewurl}&amp;owntype={$row->ownertype}&amp;ownid={$row->id}">{str tag=listviews section=view}</a>&nbsp;<img src="{theme_path location='images/icon_fieldset_left.gif'}" alt=""></td>
</tr>
{/foreach}
{else}
......
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