Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
7f067328
Commit
7f067328
authored
Aug 22, 2008
by
Richard Mansfield
Browse files
View owner search function
parent
72bb6069
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/view.php
View file @
7f067328
...
...
@@ -1611,6 +1611,64 @@ class View {
}
/**
* Search view owners.
*/
public
static
function
search_view_owners
(
$query
=
null
,
$template
=
null
,
$limit
=
null
,
$offset
=
0
)
{
if
(
$template
)
{
$tsql
=
' AND v.template = 1'
;
}
else
if
(
$template
===
false
)
{
$tsql
=
' AND v.template = 0'
;
}
else
{
$tsql
=
''
;
}
$query
=
''
;
if
(
$query
)
{
$ph
=
array
(
$query
);
$qsql
=
' WHERE display '
.
db_ilike
()
.
" '%' || ? || '%' "
;
}
else
{
$ph
=
array
();
$qsql
=
''
;
}
$sql
=
"
SELECT
'user' AS type,
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
UNION
SELECT 'group' AS type, 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
UNION
SELECT 'institution' AS type, 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"
;
$count
=
count_records_sql
(
"SELECT COUNT(*) FROM (
$sql
) q
$qsql
"
,
$ph
);
$data
=
get_records_sql_array
(
"SELECT * FROM (
$sql
) q
$qsql
"
,
$ph
,
$offset
,
$limit
);
return
(
object
)
array
(
'data'
=>
array_values
(
$data
),
'count'
=>
$count
,
'limit'
=>
$limit
,
'offset'
=>
$offset
,
);
}
/**
* Get views which have been explicitly shared to a group and are
* not owned by the group
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment