Skip to content

Commit

Permalink
Merge branch 'MDL-71347' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Oct 1, 2021
2 parents a096fb5 + a6f9bad commit 123c8dd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions admin/settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$choices['firstaccess'] = new lang_string('firstaccess', 'filters');
$choices['lastaccess'] = new lang_string('lastaccess');
$choices['neveraccessed'] = new lang_string('neveraccessed', 'filters');
$choices['timecreated'] = new lang_string('timecreated');
$choices['timemodified'] = new lang_string('lastmodified');
$choices['nevermodified'] = new lang_string('nevermodified', 'filters');
$choices['auth'] = new lang_string('authentication');
Expand Down
1 change: 1 addition & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,7 @@
$string['thiscategory'] = 'This category';
$string['thiscategorycontains'] = 'This category contains';
$string['time'] = 'Time';
$string['timecreated'] = 'Time created';
$string['timecreatedcourse'] = 'Course time created';
$string['timezone'] = 'Timezone';
$string['to'] = 'To';
Expand Down
5 changes: 3 additions & 2 deletions user/filters/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public function __construct($fieldnames = null, $baseurl = null, $extraparams =
$fieldnames = array('realname' => 1, 'lastname' => 1, 'firstname' => 1, 'username' => 1, 'email' => 1, 'city' => 1,
'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, 'institution' => 1, 'department' => 1, 'lastip' => 1);
'neveraccessed' => 1, 'timecreated' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'auth' => 1,
'mnethostid' => 1, 'idnumber' => 1, 'institution' => 1, 'department' => 1, 'lastip' => 1);

// Get the config which filters the admin wanted to show by default.
$userfiltersdefault = get_config('core', 'userfiltersdefault');
Expand Down Expand Up @@ -175,6 +175,7 @@ public function get_field($fieldname, $advanced) {
case 'firstaccess': return new user_filter_date('firstaccess', get_string('firstaccess', 'filters'), $advanced, 'firstaccess');
case 'lastaccess': return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess');
case 'neveraccessed': return new user_filter_checkbox('neveraccessed', get_string('neveraccessed', 'filters'), $advanced, 'firstaccess', array('lastaccess_sck', 'lastaccess_eck', 'firstaccess_eck', 'firstaccess_sck'));
case 'timecreated': return new user_filter_date('timecreated', get_string('timecreated'), $advanced, 'timecreated');
case 'timemodified': return new user_filter_date('timemodified', get_string('lastmodified'), $advanced, 'timemodified');
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);
Expand Down
52 changes: 52 additions & 0 deletions user/tests/behat/filter_timecreated.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@core @core_user
Feature: Filter users by time created
In order to find users created relative to a date
As an admin
I need to be able to filter users by their time created date

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| user01 | User | One | user01@example.com |

@javascript
Scenario Outline: Matching user filter by time created
Given I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Show more..."
# Set the filter fields, excluding admin.
When I set the following fields to these values:
| <enablefield>[enabled] | 1 |
| <enablefield>[year] | <year> |
| Username field limiter | doesn't contain |
| Username value | admin |
And I press "Add filter"
Then I should see "User One" in the "users" "table"
And I should see "1 / 2 Users"
Examples:
| enablefield | year |
# Time created, is after.
| timecreated_sdt | ## -1 year ## %Y ## |
# Time created, is before.
| timecreated_edt | ## +1 year ## %Y ## |

@javascript
Scenario Outline: Non-matching user filter by time created
Given I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Show more..."
# Set the filter fields, excluding admin.
When I set the following fields to these values:
| <enablefield>[enabled] | 1 |
| <enablefield>[year] | <year> |
| Username field limiter | doesn't contain |
| Username value | admin |
And I press "Add filter"
Then "Users" "table" should not exist
And I should see "0 / 2 Users"
Examples:
| enablefield | year |
# Time created, is after.
| timecreated_sdt | ## +1 year ## %Y ## |
# Time created, is before.
| timecreated_edt | ## -1 year ## %Y ## |

0 comments on commit 123c8dd

Please sign in to comment.