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
94a9d57e
Commit
94a9d57e
authored
Feb 07, 2012
by
Francois Marier
Committed by
Gerrit Code Review
Feb 07, 2012
Browse files
Merge "Allow searching and filtering by tag in view_search"
parents
797d671f
fc40db28
Changes
1
Show whitespace changes
Inline
Side-by-side
htdocs/lib/view.php
View file @
94a9d57e
...
...
@@ -2810,15 +2810,22 @@ class View {
* @param array $types List of view types to filter by
* @param bool $collection Use query against collection names and descriptions
* @param array $accesstypes Only return views visible due to the given access types
* @param array $tag Only return views with this tag
*
*/
public
static
function
view_search
(
$query
=
null
,
$ownerquery
=
null
,
$ownedby
=
null
,
$copyableby
=
null
,
$limit
=
null
,
$offset
=
0
,
$extra
=
true
,
$sort
=
null
,
$types
=
null
,
$collection
=
false
,
$accesstypes
=
null
)
{
$extra
=
true
,
$sort
=
null
,
$types
=
null
,
$collection
=
false
,
$accesstypes
=
null
,
$tag
=
null
)
{
global
$USER
;
$admin
=
$USER
->
get
(
'admin'
);
$loggedin
=
$USER
->
is_logged_in
();
$viewerid
=
$USER
->
get
(
'id'
);
$from
=
'
FROM {view} v
LEFT OUTER JOIN {collection_view} cv ON cv.view = v.id
LEFT OUTER JOIN {collection} c ON cv.collection = c.id
'
;
$where
=
'
WHERE (v.owner IS NULL OR v.owner > 0)
AND (v.group IS NULL OR v.group NOT IN (SELECT id FROM {group} WHERE deleted = 1))'
;
...
...
@@ -2847,10 +2854,13 @@ class View {
}
$like
=
db_ilike
();
if
(
$query
)
{
if
(
$query
)
{
// Include matches on the title, description or tag
$from
.
=
"
LEFT JOIN
{
view_tag
}
vt ON (vt.view = v.id AND vt.tag = ?)"
;
$where
.
=
"
AND (v.title
$like
'%' || ? || '%' OR v.description
$like
'%' || ? || '%' "
;
$ph
=
array
(
$query
,
$query
);
AND (v.title
$like
'%' || ? || '%' OR v.description
$like
'%' || ? || '%'
OR vt.tag = ?
"
;
$ph
=
array
(
$query
,
$query
,
$query
,
$query
);
if
(
$collection
)
{
$where
.
=
"
OR c.name
$like
'%' || ? || '%' OR c.description
$like
'%' || ? || '%' "
;
...
...
@@ -2858,6 +2868,11 @@ class View {
}
$where
.
=
")"
;
}
else
if
(
$tag
)
{
// Filter by the tag
$from
.
=
"
INNER JOIN
{
view_tag
}
vt ON (vt.view = v.id AND vt.tag = ?)"
;
$ph
=
array
(
$tag
);
}
else
{
$ph
=
array
();
}
...
...
@@ -2874,12 +2889,6 @@ class View {
$accesstypes
=
array
(
'public'
);
}
$from
=
'
FROM {view} v
LEFT OUTER JOIN {collection_view} cv ON cv.view = v.id
LEFT OUTER JOIN {collection} c ON cv.collection = c.id
'
;
if
(
$editableviews
)
{
$editablesql
=
"v.owner = ? -- user owns the view
OR v.group IN ( -- group view, editable by the user
...
...
Write
Preview
Markdown
is supported
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