Improved editing of old polls
authorAlexander Ebert <ebert@woltlab.com>
Tue, 31 Dec 2013 11:13:16 +0000 (12:13 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 31 Dec 2013 11:13:16 +0000 (12:13 +0100)
wcfsetup/install/files/lib/system/poll/PollManager.class.php

index 1f6b8c305feb607fec9c026f376f374d194f86ab..a72d31ff7e70118b8e79bd2f91ad9190b357b436 100644 (file)
@@ -204,9 +204,18 @@ class PollManager extends SingletonFactory {
                        return;
                }
                
-               // end time is in the past
-               if ($this->pollData['endTime'] != 0 && $this->pollData['endTime'] <= TIME_NOW && ($this->poll === null || $this->poll->endTime != $this->pollData['endTime'])) {
-                       throw new UserInputException('pollEndTime', 'notValid');
+               if ($this->pollData['endTime'] && $this->pollData['endTime'] <= TIME_NOW) {
+                       if ($this->poll === null) {
+                               // end time is in the past
+                               throw new UserInputException('pollEndTime', 'notValid');
+                       }
+                       else {
+                               // check if the difference to the stored time is less than 60 minutes (editing an old poll)
+                               $difference = abs($this->poll->endTime - $this->pollData['endTime']);
+                               if ($difference > 3599) {
+                                       throw new UserInputException('pollEndTime', 'notValid');
+                               }
+                       }
                }
                
                // no options given