Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
bf2c9be0
Commit
bf2c9be0
authored
Nov 28, 2014
by
Bjoern Schiessle
Browse files
concatenate queries with 'or'
parent
154628da
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/activitymanager.php
View file @
bf2c9be0
...
...
@@ -247,16 +247,28 @@ class ActivityManager implements IManager {
* @return array
*/
function
getQueryForFilter
(
$filter
)
{
$conditions
=
array
();
$parameters
=
array
();
foreach
(
$this
->
extensions
as
$extension
)
{
$c
=
$extension
();
if
(
$c
instanceof
IExtension
)
{
$result
=
$c
->
getQueryForFilter
(
$filter
);
if
(
is_array
(
$result
))
{
return
$result
;
list
(
$condition
,
$parameter
)
=
$result
;
if
(
$condition
&&
is_array
(
$parameter
))
{
$conditions
[]
=
$condition
;
$parameters
=
array_merge
(
$parameters
,
$parameter
);
}
}
}
}
return
array
(
null
,
null
);
if
(
empty
(
$conditions
))
{
return
array
(
null
,
null
);
}
return
array
(
' and (('
.
implode
(
') or ('
,
$conditions
)
.
'))'
,
$parameters
);
}
}
tests/lib/activitymanager.php
View file @
bf2c9be0
...
...
@@ -87,11 +87,14 @@ class Test_ActivityManager extends \Test\TestCase {
}
public
function
testQueryForFilter
()
{
$this
->
activityManager
->
registerExtension
(
function
()
{
return
new
SimpleExtension
();
});
$result
=
$this
->
activityManager
->
getQueryForFilter
(
'filter1'
);
$this
->
assertEquals
(
array
(
'`app` = ? and `message` like ?'
,
array
(
'mail'
,
'ownCloud%'
)
'
and ((
`app` = ? and `message` like ?
) or (`app` = ? and `message` like ?))
'
,
array
(
'mail'
,
'ownCloud%'
,
'mail'
,
'ownCloud%'
)
),
$result
);
...
...
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