Allow the registration date to be open-ended
authorAlexander Ebert <ebert@woltlab.com>
Tue, 9 Apr 2024 14:21:18 +0000 (16:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 9 Apr 2024 14:21:18 +0000 (16:21 +0200)
See https://www.woltlab.com/community/thread/305650/

wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php

index 3d0cfefafec5c67ef945d2f375771d8e90f108d0..ed2eeae471503d74071ecd55f17f07a6af716ad8 100644 (file)
@@ -82,28 +82,34 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme
     public function checkUser(Condition $condition, User $user)
     {
         /** @noinspection PhpUndefinedFieldInspection */
-        $registrationDateStart = \DateTime::createFromFormat(
-            'Y-m-d',
-            $condition->registrationDateStart,
-            new \DateTimeZone(TIMEZONE)
-        );
-        if ($registrationDateStart !== false) {
-            $registrationDateStart->setTime(0, 0, 0);
-            if ($user->registrationDate < $registrationDateStart->getTimestamp()) {
-                return false;
+        $dateStart = $condition->registrationDateStart;
+        if ($dateStart !== null) {
+            $registrationDateStart = \DateTime::createFromFormat(
+                'Y-m-d',
+                $dateStart,
+                new \DateTimeZone(TIMEZONE)
+            );
+            if ($registrationDateStart !== false) {
+                $registrationDateStart->setTime(0, 0, 0);
+                if ($user->registrationDate < $registrationDateStart->getTimestamp()) {
+                    return false;
+                }
             }
         }
 
         /** @noinspection PhpUndefinedFieldInspection */
-        $registrationDateEnd = \DateTime::createFromFormat(
-            'Y-m-d',
-            $condition->registrationDateEnd,
-            new \DateTimeZone(TIMEZONE)
-        );
-        if ($registrationDateEnd !== false) {
-            $registrationDateEnd->setTime(23, 59, 59);
-            if ($user->registrationDate >= $registrationDateEnd->getTimestamp()) {
-                return false;
+        $dateEnd = $condition->registrationDateEnd;
+        if ($dateEnd !== null) {
+            $registrationDateEnd = \DateTime::createFromFormat(
+                'Y-m-d',
+                $dateEnd,
+                new \DateTimeZone(TIMEZONE)
+            );
+            if ($registrationDateEnd !== false) {
+                $registrationDateEnd->setTime(23, 59, 59);
+                if ($user->registrationDate >= $registrationDateEnd->getTimestamp()) {
+                    return false;
+                }
             }
         }