@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Calendar event edit view should validate that start time preceeds end time

Summary: Closes T8023, Calendar event edit view should validate that start time preceeds end time .

Test Plan: Create Calendar event, add details, make end time be earlier than start time, try to save, get error, make sure all previously entered details are populated correctly.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8023

Differential Revision: https://secure.phabricator.com/D12656

+42 -18
+28
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
··· 175 175 return parent::applyCustomExternalTransaction($object, $xaction); 176 176 } 177 177 178 + protected function validateAllTransactions( 179 + PhabricatorLiskDAO $object, 180 + array $xactions) { 181 + $start_date_xaction = PhabricatorCalendarEventTransaction::TYPE_START_DATE; 182 + $end_date_xaction = PhabricatorCalendarEventTransaction::TYPE_END_DATE; 183 + $start_date = $object->getDateFrom(); 184 + $end_date = $object->getDateTo(); 185 + $errors = array(); 186 + 187 + foreach ($xactions as $xaction) { 188 + if ($xaction->getTransactionType() == $start_date_xaction) { 189 + $start_date = $xaction->getNewValue()->getEpoch(); 190 + } else if ($xaction->getTransactionType() == $end_date_xaction) { 191 + $end_date = $xaction->getNewValue()->getEpoch(); 192 + } 193 + } 194 + if ($start_date > $end_date) { 195 + $type = PhabricatorCalendarEventTransaction::TYPE_END_DATE; 196 + $errors[] = new PhabricatorApplicationTransactionValidationError( 197 + $type, 198 + pht('Invalid'), 199 + pht('End date must be after start date.'), 200 + null); 201 + } 202 + 203 + return $errors; 204 + } 205 + 178 206 protected function validateTransaction( 179 207 PhabricatorLiskDAO $object, 180 208 $type,
-3
src/applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php
··· 1 - <?php 2 - 3 - final class PhabricatorCalendarEventInvalidEpochException extends Exception {}
-4
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 42 42 } 43 43 44 44 public function save() { 45 - if ($this->getDateTo() < $this->getDateFrom()) { 46 - throw new PhabricatorCalendarEventInvalidEpochException(); 47 - } 48 - 49 45 if (!$this->mailKey) { 50 46 $this->mailKey = Filesystem::readRandomCharacters(20); 51 47 }
+7 -11
src/applications/people/conduit/UserAddStatusConduitAPIMethod.php
··· 50 50 $status = $request->getValue('status'); 51 51 $description = $request->getValue('description', ''); 52 52 53 - try { 54 - id(new PhabricatorCalendarEvent()) 55 - ->setUserPHID($user_phid) 56 - ->setDateFrom($from) 57 - ->setDateTo($to) 58 - ->setTextStatus($status) 59 - ->setDescription($description) 60 - ->save(); 61 - } catch (PhabricatorCalendarEventInvalidEpochException $e) { 62 - throw new ConduitException('ERR-BAD-EPOCH'); 63 - } 53 + id(new PhabricatorCalendarEvent()) 54 + ->setUserPHID($user_phid) 55 + ->setDateFrom($from) 56 + ->setDateTo($to) 57 + ->setTextStatus($status) 58 + ->setDescription($description) 59 + ->save(); 64 60 } 65 61 66 62 }
+7
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 639 639 $errors[] = $this->validateTransaction($object, $type, $type_xactions); 640 640 } 641 641 642 + $errors[] = $this->validateAllTransactions($object, $xactions); 642 643 $errors = array_mergev($errors); 643 644 644 645 $continue_on_missing = $this->getContinueOnMissingFields(); ··· 1822 1823 array $xactions) { 1823 1824 1824 1825 return clone $object; 1826 + } 1827 + 1828 + protected function validateAllTransactions( 1829 + PhabricatorLiskDAO $object, 1830 + array $xactions) { 1831 + return array(); 1825 1832 } 1826 1833 1827 1834 /**