Commit 58e3fd38 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1514272: User search is failing when 'email address' option is on



Need to pass the correct number of prepare statement values for the
sql string.

Change-Id: Ib3071b420e739292f089cd029fb9c7219a83bb3e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent d8859ba8
......@@ -213,8 +213,12 @@ class PluginSearchInternal extends PluginSearch {
// Get a list of match expressions to use in the WHERE clause
$matches = new StdClass;
$checkemail = false;
foreach (array_merge($required, $optional) as $f) {
$matches->{$f} = self::match_user_field_expression($f, $usralias);
if ($f == 'email') {
$checkemail = true;
}
}
$querydata = self::split_query_string(strtolower(trim($query_string)));
......@@ -237,12 +241,13 @@ class PluginSearchInternal extends PluginSearch {
$where = '';
$values = array();
$pad = (get_config_plugin('search', 'internal', 'exactusersearch') == true && $checkemail) ? 6 : 4;
foreach ($querydata as $term) {
$where .= '
AND (
' . $termsql . '
)';
$values = array_pad($values, count($values) + 4 + count($optional), $term);
$values = array_pad($values, count($values) + $pad + count($optional), $term);
}
return array($where, $values);
......@@ -434,12 +439,13 @@ class PluginSearchInternal extends PluginSearch {
$termsql = join(" OR ", $matches);
$values = array();
$pad = (get_config_plugin('search', 'internal', 'exactusersearch')) ? 7 : 5;
foreach ($querydata as $term) {
$where .= '
AND (
' . $termsql . '
)';
$values = array_pad($values, count($values) + 7, $term);
$values = array_pad($values, count($values) + $pad, $term);
}
$firstcols = 'u.id';
......
......@@ -4,11 +4,13 @@ In order to change the configuration of the user search page
As an admin
So I can benefit from the use of different configurations
Scenario: Turning the switches on and off on user search page (Bug 1431569)
Given I log in as "admin" with password "Kupuhipa1"
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| userA | Kupuhipa1 | test01@example.com | Pete | Mc | mahara | internal | admin |
Scenario: Testing functions for user search page (Bug 1431569)
Given I log in as "admin" with password "Kupuhipa1"
And I follow "Administration"
And I choose "User search" in "Users"
And I follow "Advanced options"
......@@ -21,17 +23,20 @@ Scenario: Turning the switches on and off on user search page (Bug 1431569)
| Site staff | 0 |
| Site administrator | 1 |
| Disable email | 0 |
# Flicking the switch to the opposite of the default
# Flicking the switches to new settings
And I set the following fields to these values:
| Force password change on next login | 1 |
| Site staff | 1 |
| Site administrator | 0 |
| Disable email | 1 |
# Flicking the switch back to the default setting
And I set the following fields to these values:
| Force password change on next login | 0 |
| Site staff | 0 |
| Site administrator | 1 |
| Disable email | 0 |
And I press "Save changes"
And I press "Save changes"
# Check that I can do user search when 'Email address' option is on
And I follow "Administration"
And I choose "Plugin administration" in "Extensions"
And I follow "Configuration for artefact internal"
And I set the field "Searchable fields: Email address" to "1"
And I press "Save"
Then I should see "Settings saved"
And I set the following fields to these values:
| Search users | Pete Mc |
And I press the key "Enter" in the "Search users" field
Then I should see "userA"
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