From c052717bd1eed319563cd53ae42284c75c52814b Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Wed, 25 Mar 2020 13:24:29 +0100 Subject: [PATCH 01/14] add filter --- .../src/Controller/UsersController.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 0938f7439e60a..c7b30cc601783 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -11,6 +11,7 @@ \defined('_JEXEC') or die; +use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\MVC\Controller\ApiController; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; @@ -65,4 +66,49 @@ protected function save($recordKey = null) return parent::save($recordKey); } + + /** + * User list view with filtering of data + * + * @return static A BaseController object to support chaining. + * + * @since __DEPLOY_VERSION__ + */ + public function displayList() + { + $apiFilterInfo = $this->input->get('filter', [], 'array'); + $filter = InputFilter::getInstance(); + + if (array_key_exists('state', $apiFilterInfo)) + { + $this->modelState->set('filter.state', $filter->clean($apiFilterInfo['state'], 'INT')); + } + + if (array_key_exists('active', $apiFilterInfo)) + { + $this->modelState->set('filter.active', $filter->clean($apiFilterInfo['active'], 'INT')); + } + + if (array_key_exists('groupid', $apiFilterInfo)) + { + $this->modelState->set('filter.group_id', $filter->clean($apiFilterInfo['groupid'], 'INT')); + } + + if (array_key_exists('search', $apiFilterInfo)) + { + $this->modelState->set('filter.search', $filter->clean($apiFilterInfo['search'], 'STRING')); + } + + if (array_key_exists('registrationdate', $apiFilterInfo)) + { + $this->modelState->set('filter.range', $filter->clean($apiFilterInfo['registrationdate'], 'STRING')); + } + + if (array_key_exists('lastvisitdate', $apiFilterInfo)) + { + $this->modelState->set('filter.lastvisitrange', $filter->clean($apiFilterInfo['lastvisitdate'], 'STRING')); + } + + return parent::displayList(); + } } From c387cca53284e3daed08179007385d0626a9c517 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Thu, 26 Mar 2020 09:37:46 +0100 Subject: [PATCH 02/14] send a 400 response send a 400 response if date filter value is unsupported --- .../src/Controller/UsersController.php | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index c7b30cc601783..07210af25b516 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -12,7 +12,9 @@ \defined('_JEXEC') or die; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\ApiController; +use Joomla\CMS\Response\JsonResponse; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; /** @@ -38,6 +40,25 @@ class UsersController extends ApiController */ protected $default_view = 'users'; + /** + * The supported filter values for date range. + * + * @var array + * @since 4.0 + */ + protected $supportedRange + = [ + 'past_week', + 'past_1month', + 'past_3month', + 'past_6month', + 'past_6month', + 'past_year', + 'post_year', + 'today', + 'never', + ]; + /** * Method to save a record. * @@ -101,14 +122,56 @@ public function displayList() if (array_key_exists('registrationdate', $apiFilterInfo)) { - $this->modelState->set('filter.range', $filter->clean($apiFilterInfo['registrationdate'], 'STRING')); + $rangeFilter = $filter->clean($apiFilterInfo['registrationdate'], 'STRING'); + + if (!array_key_exists($rangeFilter, $this->supportedRange)) + { + // Send the error response + $this->sendResponse('registrationdate', 400); + } + + $this->modelState->set('filter.range', $rangeFilter); } if (array_key_exists('lastvisitdate', $apiFilterInfo)) { - $this->modelState->set('filter.lastvisitrange', $filter->clean($apiFilterInfo['lastvisitdate'], 'STRING')); + $rangeFilter = $filter->clean($apiFilterInfo['lastvisitdate'], 'STRING'); + + if (!array_key_exists($rangeFilter, $this->supportedRange)) + { + // Send the error response + $this->sendResponse('lastvisitdate', 400); + } + + $this->modelState->set('filter.lastvisitrange', $rangeFilter); } return parent::displayList(); } + + /** + * Send the given data as JSON response in the following format: + * + * {"success":true,"message":"ok","messages":null,"data":[{"type":"dir","name":"banners","path":"//"}]} + * + * @param string $field The wrong field + * @param integer $responseCode The response code + * + * @return void + * + * @since 4.0.0 + */ + private function sendResponse(string $field = null, int $responseCode = 200): void + { + // Set the correct content type + $this->app->setHeader('Content-Type', 'application/json'); + + // Set the status code for the response + http_response_code($responseCode); + + // Send the data + echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $field), true); + + $this->app->close(); + } } From ce92a861753b873a5bfff6ccdab30c47ad11f0ab Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Thu, 26 Mar 2020 10:16:24 +0100 Subject: [PATCH 03/14] oops --- api/components/com_users/src/Controller/UsersController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 07210af25b516..3cc560f037a5c 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -124,7 +124,7 @@ public function displayList() { $rangeFilter = $filter->clean($apiFilterInfo['registrationdate'], 'STRING'); - if (!array_key_exists($rangeFilter, $this->supportedRange)) + if (!in_array($rangeFilter, $this->supportedRange)) { // Send the error response $this->sendResponse('registrationdate', 400); @@ -137,7 +137,7 @@ public function displayList() { $rangeFilter = $filter->clean($apiFilterInfo['lastvisitdate'], 'STRING'); - if (!array_key_exists($rangeFilter, $this->supportedRange)) + if (!in_array($rangeFilter, $this->supportedRange)) { // Send the error response $this->sendResponse('lastvisitdate', 400); From d84347c44489de6fecbb3d89f26cf9375be727c1 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Thu, 26 Mar 2020 11:32:07 +0100 Subject: [PATCH 04/14] use Tobscure excepction --- .../src/Controller/UsersController.php | 38 ++++--------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 3cc560f037a5c..10c029b24aed3 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -14,8 +14,8 @@ use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\ApiController; -use Joomla\CMS\Response\JsonResponse; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; +use Tobscure\JsonApi\Exception\InvalidParameterException; /** * The users controller @@ -41,10 +41,10 @@ class UsersController extends ApiController protected $default_view = 'users'; /** - * The supported filter values for date range. + * The default view for the display method. * * @var array - * @since 4.0 + * @since 3.0 */ protected $supportedRange = [ @@ -127,7 +127,8 @@ public function displayList() if (!in_array($rangeFilter, $this->supportedRange)) { // Send the error response - $this->sendResponse('registrationdate', 400); + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationdate'); + throw new InvalidParameterException($error); } $this->modelState->set('filter.range', $rangeFilter); @@ -140,7 +141,8 @@ public function displayList() if (!in_array($rangeFilter, $this->supportedRange)) { // Send the error response - $this->sendResponse('lastvisitdate', 400); + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastvisitdate'); + throw new InvalidParameterException($error); } $this->modelState->set('filter.lastvisitrange', $rangeFilter); @@ -148,30 +150,4 @@ public function displayList() return parent::displayList(); } - - /** - * Send the given data as JSON response in the following format: - * - * {"success":true,"message":"ok","messages":null,"data":[{"type":"dir","name":"banners","path":"//"}]} - * - * @param string $field The wrong field - * @param integer $responseCode The response code - * - * @return void - * - * @since 4.0.0 - */ - private function sendResponse(string $field = null, int $responseCode = 200): void - { - // Set the correct content type - $this->app->setHeader('Content-Type', 'application/json'); - - // Set the status code for the response - http_response_code($responseCode); - - // Send the data - echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $field), true); - - $this->app->close(); - } } From 167391652c9d43bfafbd9ffeed6b154e4ce7b76f Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Thu, 26 Mar 2020 11:47:13 +0100 Subject: [PATCH 05/14] add code 400 --- api/components/com_users/src/Controller/UsersController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 10c029b24aed3..0a024085e94f0 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -128,7 +128,7 @@ public function displayList() { // Send the error response $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationdate'); - throw new InvalidParameterException($error); + throw new InvalidParameterException($error, 400); } $this->modelState->set('filter.range', $rangeFilter); @@ -142,7 +142,7 @@ public function displayList() { // Send the error response $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastvisitdate'); - throw new InvalidParameterException($error); + throw new InvalidParameterException($error, 400); } $this->modelState->set('filter.lastvisitrange', $rangeFilter); From 10270025a29f0ad2ba2d29f02cf46fdd42f005e8 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Thu, 26 Mar 2020 11:51:11 +0100 Subject: [PATCH 06/14] Update api/components/com_users/src/Controller/UsersController.php silly me cause is doubled Co-Authored-By: Quy --- api/components/com_users/src/Controller/UsersController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 0a024085e94f0..8f8930589e84f 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -52,7 +52,6 @@ class UsersController extends ApiController 'past_1month', 'past_3month', 'past_6month', - 'past_6month', 'past_year', 'post_year', 'today', From 2991d576ddad9da030a24052877f8eeed051f2c8 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 26 Mar 2020 13:11:44 +0000 Subject: [PATCH 07/14] Codestyle --- .../src/Controller/UsersController.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 8f8930589e84f..9e3cb484b4fe3 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -46,17 +46,16 @@ class UsersController extends ApiController * @var array * @since 3.0 */ - protected $supportedRange - = [ - 'past_week', - 'past_1month', - 'past_3month', - 'past_6month', - 'past_year', - 'post_year', - 'today', - 'never', - ]; + protected $supportedRange = [ + 'past_week', + 'past_1month', + 'past_3month', + 'past_6month', + 'past_year', + 'post_year', + 'today', + 'never', + ]; /** * Method to save a record. From 836ce92fd447d0e0766320f974df4b6619b928be Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 26 Mar 2020 13:12:07 +0000 Subject: [PATCH 08/14] Fix typo --- api/components/com_users/src/Controller/UsersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 9e3cb484b4fe3..e403259ccd909 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -52,7 +52,7 @@ class UsersController extends ApiController 'past_3month', 'past_6month', 'past_year', - 'post_year', + 'past_year', 'today', 'never', ]; From c007b1a275e4f130a116ab60d460cd53f0101361 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 26 Mar 2020 13:14:48 +0000 Subject: [PATCH 09/14] Use invalid field parameter --- api/components/com_users/src/Controller/UsersController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index e403259ccd909..a2d40f8dea0e9 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -126,7 +126,7 @@ public function displayList() { // Send the error response $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationdate'); - throw new InvalidParameterException($error, 400); + throw new InvalidParameterException($error, 400, null, 'registrationdate'); } $this->modelState->set('filter.range', $rangeFilter); @@ -140,7 +140,7 @@ public function displayList() { // Send the error response $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastvisitdate'); - throw new InvalidParameterException($error, 400); + throw new InvalidParameterException($error, 400, null, 'lastvisitdate'); } $this->modelState->set('filter.lastvisitrange', $rangeFilter); From 902bde95ac4822b08e4ca5682a93409b090c20c9 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Fri, 27 Mar 2020 07:26:44 +0100 Subject: [PATCH 10/14] Update api/components/com_users/src/Controller/UsersController.php thx Co-Authored-By: Quy --- api/components/com_users/src/Controller/UsersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index a2d40f8dea0e9..657bda3ee1b81 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -52,7 +52,7 @@ class UsersController extends ApiController 'past_3month', 'past_6month', 'past_year', - 'past_year', + 'post_year', 'today', 'never', ]; From 893d0512879514c3e6973bddc5cd70c990be0472 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Fri, 27 Mar 2020 18:05:24 +0100 Subject: [PATCH 11/14] since 4 --- api/components/com_users/src/Controller/UsersController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 657bda3ee1b81..5acea59269151 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -36,7 +36,7 @@ class UsersController extends ApiController * The default view for the display method. * * @var string - * @since 3.0 + * @since 4.0.0 */ protected $default_view = 'users'; @@ -44,7 +44,7 @@ class UsersController extends ApiController * The default view for the display method. * * @var array - * @since 3.0 + * @since 4.0.0 */ protected $supportedRange = [ 'past_week', From 720e5a8e30ce1d386d76cd06a68fdb52388fe7d9 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Sat, 11 Apr 2020 11:52:01 +0100 Subject: [PATCH 12/14] Refactor to use full date searches --- .../com_users/src/Model/UsersModel.php | 38 ++++++-- .../src/Controller/UsersController.php | 89 +++++++++++++------ 2 files changed, 92 insertions(+), 35 deletions(-) diff --git a/administrator/components/com_users/src/Model/UsersModel.php b/administrator/components/com_users/src/Model/UsersModel.php index 753885cb9ddc2..3913c38b2c622 100644 --- a/administrator/components/com_users/src/Model/UsersModel.php +++ b/administrator/components/com_users/src/Model/UsersModel.php @@ -378,13 +378,26 @@ protected function getListQuery() } } - // Add filter for registration time ranges select list + // Add filter for registration time ranges select list. UI Visitors get a range of predefined + // values. API users can do a full range based on ISO8601 $range = $this->getState('filter.range'); + $registrationStart = $this->getState('filter.registrationStart'); + $registrationEnd = $this->getState('filter.registrationEnd'); // Apply the range filter. - if ($range) + if ($range || ($registrationStart && $registrationEnd)) { - $dates = $this->buildDateRange($range); + if ($range) + { + $dates = $this->buildDateRange($range); + } + else + { + $dates = [ + 'dNow' => $registrationStart, + 'dStart' => $registrationEnd, + ]; + } if ($dates['dStart'] !== false) { @@ -406,13 +419,26 @@ protected function getListQuery() } } - // Add filter for last visit time ranges select list + // Add filter for last visit time ranges select list. UI Visitors get a range of predefined + // values. API users can do a full range based on ISO8601 $lastvisitrange = $this->getState('filter.lastvisitrange'); + $lastVisitStart = $this->getState('filter.lastVisitStart'); + $lastVisitEnd = $this->getState('filter.lastVisitEnd'); // Apply the range filter. - if ($lastvisitrange) + if ($lastvisitrange || ($lastVisitStart && $lastVisitEnd)) { - $dates = $this->buildDateRange($lastvisitrange); + if ($lastvisitrange) + { + $dates = $this->buildDateRange($lastvisitrange); + } + else + { + $dates = [ + 'dNow' => $lastVisitStart, + 'dStart' => $lastVisitEnd, + ]; + } if ($dates['dStart'] === false) { diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index 5acea59269151..a542be4ea5640 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -11,6 +11,7 @@ \defined('_JEXEC') or die; +use Joomla\CMS\Date\Date; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\ApiController; @@ -40,23 +41,6 @@ class UsersController extends ApiController */ protected $default_view = 'users'; - /** - * The default view for the display method. - * - * @var array - * @since 4.0.0 - */ - protected $supportedRange = [ - 'past_week', - 'past_1month', - 'past_3month', - 'past_6month', - 'past_year', - 'post_year', - 'today', - 'never', - ]; - /** * Method to save a record. * @@ -92,6 +76,7 @@ protected function save($recordKey = null) * @return static A BaseController object to support chaining. * * @since __DEPLOY_VERSION__ + * @throws InvalidParameterException */ public function displayList() { @@ -118,32 +103,78 @@ public function displayList() $this->modelState->set('filter.search', $filter->clean($apiFilterInfo['search'], 'STRING')); } - if (array_key_exists('registrationdate', $apiFilterInfo)) + if (array_key_exists('registrationDateStart', $apiFilterInfo)) + { + $registrationStartInput = $filter->clean($apiFilterInfo['registrationDateStart'], 'STRING'); + $registrationStartDate = Date::createFromFormat(\DateTime::RFC3339, $registrationStartInput); + + if (!$registrationStartDate) + { + // Send the error response + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationDateStart'); + + throw new InvalidParameterException($error, 400, null, 'registrationDateStart'); + } + + $this->modelState->set('filter.range', $registrationStartDate); + } + + if (array_key_exists('registrationDateEnd', $apiFilterInfo)) + { + $registrationEndInput = $filter->clean($apiFilterInfo['registrationDateEnd'], 'STRING'); + $registrationEndDate = Date::createFromFormat(\DateTime::RFC3339, $registrationEndInput); + + if (!$registrationEndDate) + { + // Send the error response + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationDateEnd'); + throw new InvalidParameterException($error, 400, null, 'registrationDateEnd'); + } + + $this->modelState->set('filter.range', $registrationEndDate); + } + elseif (array_key_exists('registrationDateStart', $apiFilterInfo) + && !array_key_exists('registrationDateEnd', $apiFilterInfo)) + { + // If no end date specified the end date is now + $this->modelState->set('filter.range', new Date); + } + + if (array_key_exists('lastVisitDateStart', $apiFilterInfo)) { - $rangeFilter = $filter->clean($apiFilterInfo['registrationdate'], 'STRING'); + $lastVisitStartInput = $filter->clean($apiFilterInfo['lastVisitDateStart'], 'STRING'); + $lastVisitStartDate = Date::createFromFormat(\DateTime::RFC3339, $lastVisitStartInput); - if (!in_array($rangeFilter, $this->supportedRange)) + if (!$lastVisitStartDate) { // Send the error response - $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'registrationdate'); - throw new InvalidParameterException($error, 400, null, 'registrationdate'); + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastVisitDateStart'); + throw new InvalidParameterException($error, 400, null, 'lastVisitDateStart'); } - $this->modelState->set('filter.range', $rangeFilter); + $this->modelState->set('filter.lastVisitStart', $lastVisitStartDate); } - if (array_key_exists('lastvisitdate', $apiFilterInfo)) + if (array_key_exists('lastVisitDateEnd', $apiFilterInfo)) { - $rangeFilter = $filter->clean($apiFilterInfo['lastvisitdate'], 'STRING'); + $lastVisitEndInput = $filter->clean($apiFilterInfo['lastVisitDateEnd'], 'STRING'); + $lastVisitEndDate = Date::createFromFormat(\DateTime::RFC3339, $lastVisitEndInput); - if (!in_array($rangeFilter, $this->supportedRange)) + if (!$lastVisitEndDate) { // Send the error response - $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastvisitdate'); - throw new InvalidParameterException($error, 400, null, 'lastvisitdate'); + $error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'lastVisitDateEnd'); + + throw new InvalidParameterException($error, 400, null, 'lastVisitDateEnd'); } - $this->modelState->set('filter.lastvisitrange', $rangeFilter); + $this->modelState->set('filter.lastVisitEnd', $lastVisitEndDate); + } + elseif (array_key_exists('lastVisitDateStart', $apiFilterInfo) + && !array_key_exists('lastVisitDateEnd', $apiFilterInfo)) + { + // If no end date specified the end date is now + $this->modelState->set('filter.lastVisitEnd', new Date); } return parent::displayList(); From df5d7917a31ed683d938eb6f30043484d8dc9410 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Sat, 18 Apr 2020 19:53:02 +0200 Subject: [PATCH 13/14] fix --- .../components/com_users/src/Model/UsersModel.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_users/src/Model/UsersModel.php b/administrator/components/com_users/src/Model/UsersModel.php index 3913c38b2c622..4a3baff6fe090 100644 --- a/administrator/components/com_users/src/Model/UsersModel.php +++ b/administrator/components/com_users/src/Model/UsersModel.php @@ -381,8 +381,8 @@ protected function getListQuery() // Add filter for registration time ranges select list. UI Visitors get a range of predefined // values. API users can do a full range based on ISO8601 $range = $this->getState('filter.range'); - $registrationStart = $this->getState('filter.registrationStart'); - $registrationEnd = $this->getState('filter.registrationEnd'); + $registrationStart = $this->getState('filter.registrationDateStart'); + $registrationEnd = $this->getState('filter.registrationDateEnd'); // Apply the range filter. if ($range || ($registrationStart && $registrationEnd)) @@ -394,8 +394,8 @@ protected function getListQuery() else { $dates = [ - 'dNow' => $registrationStart, - 'dStart' => $registrationEnd, + 'dNow' => $registrationEnd, + 'dStart' => $registrationStart, ]; } @@ -435,8 +435,8 @@ protected function getListQuery() else { $dates = [ - 'dNow' => $lastVisitStart, - 'dStart' => $lastVisitEnd, + 'dNow' => $lastVisitEnd, + 'dStart' => $lastVisitStart, ]; } From 8e1c0e58d23a788d5ee2fabe5b4231e999c47487 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Sat, 18 Apr 2020 19:53:49 +0200 Subject: [PATCH 14/14] fix --- api/components/com_users/src/Controller/UsersController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/components/com_users/src/Controller/UsersController.php b/api/components/com_users/src/Controller/UsersController.php index a542be4ea5640..0ef39d82e62d4 100644 --- a/api/components/com_users/src/Controller/UsersController.php +++ b/api/components/com_users/src/Controller/UsersController.php @@ -116,7 +116,7 @@ public function displayList() throw new InvalidParameterException($error, 400, null, 'registrationDateStart'); } - $this->modelState->set('filter.range', $registrationStartDate); + $this->modelState->set('filter.registrationDateStart', $registrationStartDate); } if (array_key_exists('registrationDateEnd', $apiFilterInfo)) @@ -131,13 +131,13 @@ public function displayList() throw new InvalidParameterException($error, 400, null, 'registrationDateEnd'); } - $this->modelState->set('filter.range', $registrationEndDate); + $this->modelState->set('filter.registrationDateEnd', $registrationEndDate); } elseif (array_key_exists('registrationDateStart', $apiFilterInfo) && !array_key_exists('registrationDateEnd', $apiFilterInfo)) { // If no end date specified the end date is now - $this->modelState->set('filter.range', new Date); + $this->modelState->set('filter.registrationDateEnd', new Date); } if (array_key_exists('lastVisitDateStart', $apiFilterInfo))