Commit b217de6f authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Rename "results" field in JSON return to "data" for more consistancy

parent 2a23f640
......@@ -49,7 +49,7 @@ $offset = param_integer('offset', 0);
$data = search_user($query, $limit, $offset);
foreach ($data['results'] as &$result) {
foreach ($data['data'] as &$result) {
$result->name = display_name($result);
unset($result->email);
......
......@@ -35,6 +35,8 @@ class PluginSearchInternal extends PluginSearch {
/**
* Implement user searching with SQL
*
* NOTE: user with ID zero should never be returned
*
* @param string The query string
* @param integer How many results to return
* @param integer What result to start at (0 == first result)
......@@ -43,7 +45,7 @@ class PluginSearchInternal extends PluginSearch {
* count => integer, // total number of results
* limit => integer, // how many results are returned
* offset => integer, // starting from which result
* results => array( // the result records
* data => array( // the result records
* array(
* id => integer,
* username => string,
......@@ -74,10 +76,13 @@ class PluginSearchInternal extends PluginSearch {
FROM
" . get_config('dbprefix') . "usr u
WHERE
firstname ILIKE '%' || ? || '%'
OR lastname ILIKE '%' || ? || '%'
OR preferredname ILIKE '%' || ? || '%'
OR email ILIKE '%' || ? || '%'
id <> 0
AND (
firstname ILIKE '%' || ? || '%'
OR lastname ILIKE '%' || ? || '%'
OR preferredname ILIKE '%' || ? || '%'
OR email ILIKE '%' || ? || '%'
)
",
array($query_string, $query_string, $query_string, $query_string),
$offset,
......@@ -90,10 +95,13 @@ class PluginSearchInternal extends PluginSearch {
FROM
" . get_config('dbprefix') . "usr u
WHERE
firstname ILIKE '%' || ? || '%'
OR lastname ILIKE '%' || ? || '%'
OR preferredname ILIKE '%' || ? || '%'
OR email ILIKE '%' || ? || '%'
id <> 0
AND (
firstname ILIKE '%' || ? || '%'
OR lastname ILIKE '%' || ? || '%'
OR preferredname ILIKE '%' || ? || '%'
OR email ILIKE '%' || ? || '%'
)
",
array($query_string, $query_string, $query_string, $query_string),
$offset,
......@@ -111,7 +119,7 @@ class PluginSearchInternal extends PluginSearch {
'count' => $count,
'limit' => $limit,
'offset' => $offset,
'results' => $data,
'data' => $data,
);
}
}
......
......@@ -35,6 +35,8 @@ abstract class PluginSearch extends Plugin {
/**
* Given a query string and limits, return an array of matching users
*
* NOTE: user with ID zero should never be returned
*
* @param string The query string
* @param integer How many results to return
* @param integer What result to start at (0 == first result)
......@@ -43,7 +45,7 @@ abstract class PluginSearch extends Plugin {
* count => integer, // total number of results
* limit => integer, // how many results are returned
* offset => integer, // starting from which result
* results => array( // the result records
* data => array( // the result records
* array(
* id => integer,
......
......@@ -21,7 +21,7 @@
});
replaceChildNodes('{{$name}}_potential');
forEach(users.results, function(user) {
forEach(users.data, function(user) {
if (members[user.id]) {
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment