@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.

Add basic Herald support to Calendar

Summary: Fixes T7939. This doesn't get too fancy, but allows you to write Herald rules against Calendar events.

Test Plan:
- Wrote an "add red flag to events with party in the name" rule.
- Created a "mundane meeting", didn't get flagged.
- Created a "cool party", got flagged.
- Ran rules from the Herald test console.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7939

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

+131 -1
+8
src/__phutil_library_map__.php
··· 2044 2044 'PhabricatorCalendarEventEndDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php', 2045 2045 'PhabricatorCalendarEventFrequencyTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php', 2046 2046 'PhabricatorCalendarEventFulltextEngine' => 'applications/calendar/search/PhabricatorCalendarEventFulltextEngine.php', 2047 + 'PhabricatorCalendarEventHeraldAdapter' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php', 2048 + 'PhabricatorCalendarEventHeraldField' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldField.php', 2049 + 'PhabricatorCalendarEventHeraldFieldGroup' => 'applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php', 2047 2050 'PhabricatorCalendarEventHostPolicyRule' => 'applications/calendar/policyrule/PhabricatorCalendarEventHostPolicyRule.php', 2048 2051 'PhabricatorCalendarEventHostTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventHostTransaction.php', 2049 2052 'PhabricatorCalendarEventIconTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventIconTransaction.php', ··· 2054 2057 'PhabricatorCalendarEventJoinController' => 'applications/calendar/controller/PhabricatorCalendarEventJoinController.php', 2055 2058 'PhabricatorCalendarEventListController' => 'applications/calendar/controller/PhabricatorCalendarEventListController.php', 2056 2059 'PhabricatorCalendarEventMailReceiver' => 'applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php', 2060 + 'PhabricatorCalendarEventNameHeraldField' => 'applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php', 2057 2061 'PhabricatorCalendarEventNameTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventNameTransaction.php', 2058 2062 'PhabricatorCalendarEventPHIDType' => 'applications/calendar/phid/PhabricatorCalendarEventPHIDType.php', 2059 2063 'PhabricatorCalendarEventQuery' => 'applications/calendar/query/PhabricatorCalendarEventQuery.php', ··· 6757 6761 'PhabricatorCalendarEventEndDateTransaction' => 'PhabricatorCalendarEventDateTransaction', 6758 6762 'PhabricatorCalendarEventFrequencyTransaction' => 'PhabricatorCalendarEventTransactionType', 6759 6763 'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine', 6764 + 'PhabricatorCalendarEventHeraldAdapter' => 'HeraldAdapter', 6765 + 'PhabricatorCalendarEventHeraldField' => 'HeraldField', 6766 + 'PhabricatorCalendarEventHeraldFieldGroup' => 'HeraldFieldGroup', 6760 6767 'PhabricatorCalendarEventHostPolicyRule' => 'PhabricatorPolicyRule', 6761 6768 'PhabricatorCalendarEventHostTransaction' => 'PhabricatorCalendarEventTransactionType', 6762 6769 'PhabricatorCalendarEventIconTransaction' => 'PhabricatorCalendarEventTransactionType', ··· 6770 6777 'PhabricatorCalendarEventJoinController' => 'PhabricatorCalendarController', 6771 6778 'PhabricatorCalendarEventListController' => 'PhabricatorCalendarController', 6772 6779 'PhabricatorCalendarEventMailReceiver' => 'PhabricatorObjectMailReceiver', 6780 + 'PhabricatorCalendarEventNameHeraldField' => 'PhabricatorCalendarEventHeraldField', 6773 6781 'PhabricatorCalendarEventNameTransaction' => 'PhabricatorCalendarEventTransactionType', 6774 6782 'PhabricatorCalendarEventPHIDType' => 'PhabricatorPHIDType', 6775 6783 'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+14
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
··· 289 289 return $body; 290 290 } 291 291 292 + protected function shouldApplyHeraldRules( 293 + PhabricatorLiskDAO $object, 294 + array $xactions) { 295 + return true; 296 + } 297 + 298 + protected function buildHeraldAdapter( 299 + PhabricatorLiskDAO $object, 300 + array $xactions) { 301 + 302 + return id(new PhabricatorCalendarEventHeraldAdapter()) 303 + ->setObject($object); 304 + } 305 + 292 306 293 307 }
+56
src/applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarEventHeraldAdapter extends HeraldAdapter { 4 + 5 + private $object; 6 + 7 + public function getAdapterApplicationClass() { 8 + return 'PhabricatorCalendarApplication'; 9 + } 10 + 11 + public function getAdapterContentDescription() { 12 + return pht('React to events being created or updated.'); 13 + } 14 + 15 + protected function newObject() { 16 + return new PhabricatorCalendarEvent(); 17 + } 18 + 19 + public function isTestAdapterForObject($object) { 20 + return ($object instanceof PhabricatorCalendarEvent); 21 + } 22 + 23 + public function getAdapterTestDescription() { 24 + return pht( 25 + 'Test rules which run when an event is created or updated.'); 26 + } 27 + 28 + public function setObject($object) { 29 + $this->object = $object; 30 + return $this; 31 + } 32 + 33 + public function getObject() { 34 + return $this->object; 35 + } 36 + 37 + public function getAdapterContentName() { 38 + return pht('Calendar Events'); 39 + } 40 + 41 + public function supportsRuleType($rule_type) { 42 + switch ($rule_type) { 43 + case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: 44 + case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 45 + return true; 46 + case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: 47 + default: 48 + return false; 49 + } 50 + } 51 + 52 + public function getHeraldName() { 53 + return $this->getObject()->getMonogram(); 54 + } 55 + 56 + }
+13
src/applications/calendar/herald/PhabricatorCalendarEventHeraldField.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorCalendarEventHeraldField extends HeraldField { 4 + 5 + public function supportsObject($object) { 6 + return ($object instanceof PhabricatorCalendarEvent); 7 + } 8 + 9 + public function getFieldGroupKey() { 10 + return PhabricatorCalendarEventHeraldFieldGroup::FIELDGROUPKEY; 11 + } 12 + 13 + }
+16
src/applications/calendar/herald/PhabricatorCalendarEventHeraldFieldGroup.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarEventHeraldFieldGroup 4 + extends HeraldFieldGroup { 5 + 6 + const FIELDGROUPKEY = 'calendar.event'; 7 + 8 + public function getGroupLabel() { 9 + return pht('Event Fields'); 10 + } 11 + 12 + protected function getGroupOrder() { 13 + return 1000; 14 + } 15 + 16 + }
+20
src/applications/calendar/herald/PhabricatorCalendarEventNameHeraldField.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarEventNameHeraldField 4 + extends PhabricatorCalendarEventHeraldField { 5 + 6 + const FIELDCONST = 'calendar.event.name'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Name'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $object->getName(); 14 + } 15 + 16 + protected function getHeraldFieldStandardType() { 17 + return self::STANDARD_TEXT; 18 + } 19 + 20 + }
+4 -1
src/applications/herald/adapter/HeraldAdapter.php
··· 768 768 ); 769 769 } 770 770 771 - abstract protected function initializeNewAdapter(); 771 + protected function initializeNewAdapter() { 772 + $this->setObject($this->newObject()); 773 + return $this; 774 + } 772 775 773 776 /** 774 777 * Does this adapter's event fire only once?