Commit d6e681cb authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

added option to search_user of exlclude which excludes a user from the search

so user/find.php doesn't include the searcher in the results
parent d169d3b4
...@@ -44,6 +44,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -44,6 +44,7 @@ class PluginSearchInternal extends PluginSearch {
* can contain: * can contain:
* 'group' => integer, // only users in this group * 'group' => integer, // only users in this group
* 'owner' => boolean // include the group ownwer (only if group is set) * 'owner' => boolean // include the group ownwer (only if group is set)
* 'exclude'=> int // excludes a user
* @return array A data structure containing results looking like ... * @return array A data structure containing results looking like ...
* $results = array( * $results = array(
* count => integer, // total number of results * count => integer, // total number of results
...@@ -122,6 +123,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -122,6 +123,7 @@ class PluginSearchInternal extends PluginSearch {
AND ( a.title ILIKE \'%\' || ? || \'%\') AND ( a.title ILIKE \'%\' || ? || \'%\')
) )
) )
' . (isset($data['exclude']) ? 'AND u.id != ' . $data['exclude'] : '') . '
'; ';
$count = get_field_sql($sql, array($query_string, $query_string, $query_string, $query_string)); $count = get_field_sql($sql, array($query_string, $query_string, $query_string, $query_string));
...@@ -156,6 +158,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -156,6 +158,7 @@ class PluginSearchInternal extends PluginSearch {
AND ( a.title ILIKE \'%\' || ? || \'%\') AND ( a.title ILIKE \'%\' || ? || \'%\')
) )
) )
' . (isset($data['exclude']) ? 'AND u.id != ' . $data['exclude'] : '') . '
ORDER BY u.firstname, u.lastname, u.id'; ORDER BY u.firstname, u.lastname, u.id';
$data = get_records_sql_array($sql, $data = get_records_sql_array($sql,
array($query_string, $query_string, $query_string, $query_string), array($query_string, $query_string, $query_string, $query_string),
...@@ -211,6 +214,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -211,6 +214,7 @@ class PluginSearchInternal extends PluginSearch {
AND ( a.title LIKE \'%\' || ? || \'%\') AND ( a.title LIKE \'%\' || ? || \'%\')
) )
) )
' . (isset($data['exclude']) ? 'AND u.id != ' . $data['exclude'] : '') . '
'; ';
$count = get_field_sql($sql, array($query_string, $query_string, $query_string)); $count = get_field_sql($sql, array($query_string, $query_string, $query_string));
...@@ -247,6 +251,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -247,6 +251,7 @@ class PluginSearchInternal extends PluginSearch {
AND ( a.title LIKE \'%\' || ? || \'%\') AND ( a.title LIKE \'%\' || ? || \'%\')
) )
) )
' . (isset($data['exclude']) ? 'AND u.id != ' . $data['exclude'] : '') . '
ORDER BY u.firstname, u.lastname, u.id'; ORDER BY u.firstname, u.lastname, u.id';
get_records_sql_array($sql, array($query_string, $query_string, $query_string), get_records_sql_array($sql, array($query_string, $query_string, $query_string),
$offset, $offset,
......
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