Skip to content
GitLab
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
f8c1aa47
Commit
f8c1aa47
authored
Jan 19, 2007
by
Martyn Smith
Committed by
Martyn Smith
Jan 19, 2007
Browse files
Fix up searching for communities to allow searching for all communities
parent
70d2e124
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/json/search.php
View file @
f8c1aa47
...
...
@@ -46,7 +46,7 @@ $offset = param_integer('offset', 0);
switch
(
$type
)
{
case
'community'
:
$data
=
search_community
(
$query
,
$limit
,
$offset
);
$data
=
search_community
(
$query
,
$limit
,
$offset
,
true
);
foreach
(
$data
[
'data'
]
as
&
$result
)
{
$result
->
type
=
'community'
;
}
...
...
htdocs/lib/searchlib.php
View file @
f8c1aa47
...
...
@@ -141,10 +141,10 @@ function search_group($query_string, $limit, $offset = 0) {
* ),
* );
*/
function
search_community
(
$query_string
,
$limit
,
$offset
=
0
)
{
function
search_community
(
$query_string
,
$limit
,
$offset
=
0
,
$all
=
false
)
{
$plugin
=
get_config
(
'searchplugin'
);
safe_require
(
'search'
,
$plugin
);
return
call_static_method
(
generate_class_name
(
'search'
,
$plugin
),
'search_community'
,
$query_string
,
$limit
,
$offset
);
return
call_static_method
(
generate_class_name
(
'search'
,
$plugin
),
'search_community'
,
$query_string
,
$limit
,
$offset
,
$all
);
}
?>
htdocs/search/internal/lib.php
View file @
f8c1aa47
...
...
@@ -241,10 +241,10 @@ class PluginSearchInternal extends PluginSearch {
* ),
* );
*/
public
static
function
search_community
(
$query_string
,
$limit
,
$offset
=
0
)
{
public
static
function
search_community
(
$query_string
,
$limit
,
$offset
=
0
,
$all
=
false
)
{
global
$USER
;
if
(
is_postgres
()
)
{
$
data
=
get_records_sql_array
(
"
$
sql
=
"
SELECT
id, name, description, jointype, owner, ctime, mtime
FROM
...
...
@@ -252,18 +252,20 @@ class PluginSearchInternal extends PluginSearch {
WHERE (
name ILIKE '%' || ? || '%'
OR description ILIKE '%' || ? || '%'
) AND (
)"
;
$values
=
array
(
$query_string
,
$query_string
);
if
(
!
$all
)
{
$sql
.
=
"AND (
owner = ? OR id IN (
SELECT community FROM "
.
get_config
(
'dbprefix'
)
.
"community_member WHERE member = ?
)
)
"
,
array
(
$query_string
,
$query_string
,
$USER
->
get
(
'id'
),
$USER
->
get
(
'id'
)),
$offset
,
$limit
);
)"
;
$values
[]
=
$USER
->
get
(
'id'
);
$values
[]
=
$USER
->
get
(
'id'
);
}
$data
=
get_records_sql_array
(
$sql
,
$values
,
$offset
,
$limit
);
$
count
=
get_field_sql
(
"
$
sql
=
"
SELECT
COUNT(*)
FROM
...
...
@@ -271,14 +273,16 @@ class PluginSearchInternal extends PluginSearch {
WHERE (
name ILIKE '%' || ? || '%'
OR description ILIKE '%' || ? || '%'
) AND (
owner = ? OR id IN (
SELECT community FROM "
.
get_config
(
'dbprefix'
)
.
"community_member WHERE member = ?
)"
;
if
(
!
$all
)
{
$sql
.
=
"AND (
owner = ? OR id IN (
SELECT community FROM "
.
get_config
(
'dbprefix'
)
.
"community_member WHERE member = ?
)
)
)
"
,
array
(
$query_string
,
$query_string
,
$USER
->
get
(
'id'
),
$USER
->
get
(
'id'
))
);
"
;
}
$count
=
get_field_sql
(
$sql
,
$values
);
}
// TODO
// else if ( is_mysql() ) {
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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