diff --git a/admin/tests/behat/filter_users.feature b/admin/tests/behat/filter_users.feature index 75e2b422f12..34088d546fc 100644 --- a/admin/tests/behat/filter_users.feature +++ b/admin/tests/behat/filter_users.feature @@ -6,11 +6,11 @@ Feature: An administrator can filter user accounts by role, cohort and other pro Background: Given the following "users" exist: - | username | firstname | lastname | email | auth | confirmed | - | user1 | User | One | one@example.com | manual | 0 | - | user2 | User | Two | two@example.com | ldap | 1 | - | user3 | User | Three | three@example.com | manual | 1 | - | user4 | User | Four | four@example.com | ldap | 0 | + | username | firstname | lastname | email | auth | confirmed | lastip | + | user1 | User | One | one@example.com | manual | 0 | 127.0.1.1 | + | user2 | User | Two | two@example.com | ldap | 1 | 0.0.0.0 | + | user3 | User | Three | three@example.com | manual | 1 | 0.0.0.0 | + | user4 | User | Four | four@example.com | ldap | 0 | 127.0.1.2 | And the following "cohorts" exist: | name | idnumber | | Cohort 1 | CH1 | @@ -82,3 +82,25 @@ Feature: An administrator can filter user accounts by role, cohort and other pro And I should not see "User Two" And I should not see "User Three" And I should see "User Four" + + Scenario: Filter user accounts by last IP address + When I set the following fields to these values: + | id_lastip | 127.0.1.1 | + And I press "Add filter" + Then I should see "User One" + And I should not see "User Two" + And I should not see "User Three" + And I should not see "User Four" + And I press "Remove all filters" + And I set the following fields to these values: + | id_lastip | 127.0.1.2 | + And I press "Add filter" + And I should not see "User One" + And I should not see "User Two" + And I should not see "User Three" + And I should see "User Four" + And I press "Remove all filters" + And I should see "User One" + And I should see "User Two" + And I should see "User Three" + And I should see "User Four" diff --git a/lib/testing/generator/data_generator.php b/lib/testing/generator/data_generator.php index 314ae0c3d4f..cda6868f128 100644 --- a/lib/testing/generator/data_generator.php +++ b/lib/testing/generator/data_generator.php @@ -253,7 +253,10 @@ EOD; } $record['timemodified'] = $record['timecreated']; - $record['lastip'] = '0.0.0.0'; + + if (!isset($record['lastip'])) { + $record['lastip'] = '0.0.0.0'; + } if ($record['deleted']) { $delname = $record['email'].'.'.time(); diff --git a/user/filters/lib.php b/user/filters/lib.php index 2264671a607..45d92fae1af 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -68,7 +68,7 @@ class user_filtering { 'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'anycourses' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1, - 'idnumber' => 1); + 'idnumber' => 1, 'lastip' => 1); } $this->_fields = array(); @@ -154,6 +154,7 @@ class user_filtering { case 'nevermodified': return new user_filter_checkbox('nevermodified', get_string('nevermodified', 'filters'), $advanced, array('timemodified', 'timecreated'), array('timemodified_sck', 'timemodified_eck')); case 'cohort': return new user_filter_cohort($advanced); case 'idnumber': return new user_filter_text('idnumber', get_string('idnumber'), $advanced, 'idnumber'); + case 'lastip': return new user_filter_text('lastip', get_string('lastip'), $advanced, 'lastip'); case 'auth': $plugins = core_component::get_plugin_list('auth'); $choices = array();