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
e8dab9af
Commit
e8dab9af
authored
Jun 18, 2010
by
Pierre Spring
Browse files
Added optional random ordering for group member search
Signed-off-by:
Pierre Spring
<
pierre.spring@caillou.ch
>
parent
33a264cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/searchlib.php
View file @
e8dab9af
...
...
@@ -333,14 +333,15 @@ function admin_user_search($queries, $constraints, $offset, $limit, $sortfield,
*
* The search term is applied against first and last names of the users in the group
*
* @param int $group The group to build results for
* @param string $query A search string to filter by
* @param int $offset What result to start showing paginated results from
* @param int $limit How many results to show
* @param array $extra User membershiptype
* @param int $group The group to build results for
* @param string $query A search string to filter by
* @param int $offset What result to start showing paginated results from
* @param int $limit How many results to show
* @param array $membershiptype User membershiptype
* @param bool $random Set to true if you want the result to be ordered by random, default false
*
*/
function
get_group_user_search_results
(
$group
,
$query
,
$offset
,
$limit
,
$membershiptype
)
{
function
get_group_user_search_results
(
$group
,
$query
,
$offset
,
$limit
,
$membershiptype
,
$random
=
false
)
{
$queries
=
array
();
$constraints
=
array
();
if
(
!
empty
(
$query
))
{
...
...
@@ -363,7 +364,7 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
}
}
$results
=
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
);
$results
=
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$random
);
if
(
$results
[
'count'
])
{
$userids
=
array_map
(
create_function
(
'$a'
,
'return $a["id"];'
),
$results
[
'data'
]);
$introductions
=
get_records_sql_assoc
(
"SELECT
\"
owner
\"
, title
...
...
@@ -383,7 +384,7 @@ function get_group_user_search_results($group, $query, $offset, $limit, $members
}
function
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
)
{
function
group_user_search
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$random
=
false
)
{
$plugin
=
get_config
(
'searchplugin'
);
safe_require
(
'search'
,
$plugin
);
return
call_static_method
(
generate_class_name
(
'search'
,
$plugin
),
'group_search_user'
,
...
...
htdocs/search/internal/lib.php
View file @
e8dab9af
...
...
@@ -352,7 +352,7 @@ class PluginSearchInternal extends PluginSearch {
}
public
static
function
group_search_user
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
)
{
public
static
function
group_search_user
(
$group
,
$queries
,
$constraints
,
$offset
,
$limit
,
$membershiptype
,
$random
=
false
)
{
// Only handle OR/AND expressions at the top level. Eventually we may need subexpressions.
$searchsql
=
''
;
$values
=
array
();
...
...
@@ -429,6 +429,10 @@ class PluginSearchInternal extends PluginSearch {
$orderby
=
"gm.role = 'admin' DESC, gm.ctime, u.firstname, u.lastname, u.id"
;
}
if
(
$random
)
{
$orderby
=
db_random
();
}
$count
=
get_field_sql
(
'SELECT COUNT(*)'
.
$from
,
$values
);
if
(
$count
>
0
)
{
...
...
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