@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

Prepare for event imports in Calendar

Summary:
Ref T10747. Adds a bunch of stuff so we can keep track of which events we've imported from external sources.

This doesn't do anything yet: you can't actually import anything.

Test Plan:
- Ran `bin/storage upgrade`.
- Clicked "Imports", saw an empty wasteland.
- Created/edited events.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

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

+596 -4
+15
resources/sql/autopatches/20161012.cal.01.import.sql
··· 1 + CREATE TABLE {$NAMESPACE}_calendar.calendar_import ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARBINARY(64) NOT NULL, 4 + name LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, 5 + authorPHID VARBINARY(64) NOT NULL, 6 + viewPolicy VARBINARY(64) NOT NULL, 7 + editPolicy VARBINARY(64) NOT NULL, 8 + engineType VARCHAR(64) NOT NULL, 9 + parameters LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, 10 + isDisabled BOOL NOT NULL, 11 + dateCreated INT UNSIGNED NOT NULL, 12 + dateModified INT UNSIGNED NOT NULL, 13 + UNIQUE KEY `key_phid` (phid), 14 + KEY `key_author` (authorPHID) 15 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+19
resources/sql/autopatches/20161012.cal.02.importxaction.sql
··· 1 + CREATE TABLE {$NAMESPACE}_calendar.calendar_importtransaction ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARBINARY(64) NOT NULL, 4 + authorPHID VARBINARY(64) NOT NULL, 5 + objectPHID VARBINARY(64) NOT NULL, 6 + viewPolicy VARBINARY(64) NOT NULL, 7 + editPolicy VARBINARY(64) NOT NULL, 8 + commentPHID VARBINARY(64) DEFAULT NULL, 9 + commentVersion INT UNSIGNED NOT NULL, 10 + transactionType VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, 11 + oldValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 12 + newValue LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 13 + contentSource LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 14 + metadata LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, 15 + dateCreated INT UNSIGNED NOT NULL, 16 + dateModified INT UNSIGNED NOT NULL, 17 + UNIQUE KEY `key_phid` (`phid`), 18 + KEY `key_object` (`objectPHID`) 19 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+11
resources/sql/autopatches/20161012.cal.03.eventimport.sql
··· 1 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 2 + ADD importAuthorPHID VARBINARY(64); 3 + 4 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 5 + ADD importSourcePHID VARBINARY(64); 6 + 7 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 8 + ADD importUIDIndex BINARY(12); 9 + 10 + ALTER TABLE {$NAMESPACE}_calendar.calendar_event 11 + ADD importUID LONGTEXT COLLATE {$COLLATE_TEXT};
+22
src/__phutil_library_map__.php
··· 2100 2100 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 2101 2101 'PhabricatorCalendarICSWriter' => 'applications/calendar/util/PhabricatorCalendarICSWriter.php', 2102 2102 'PhabricatorCalendarIconSet' => 'applications/calendar/icon/PhabricatorCalendarIconSet.php', 2103 + 'PhabricatorCalendarImport' => 'applications/calendar/storage/PhabricatorCalendarImport.php', 2104 + 'PhabricatorCalendarImportEditor' => 'applications/calendar/editor/PhabricatorCalendarImportEditor.php', 2105 + 'PhabricatorCalendarImportListController' => 'applications/calendar/controller/PhabricatorCalendarImportListController.php', 2106 + 'PhabricatorCalendarImportPHIDType' => 'applications/calendar/phid/PhabricatorCalendarImportPHIDType.php', 2107 + 'PhabricatorCalendarImportQuery' => 'applications/calendar/query/PhabricatorCalendarImportQuery.php', 2108 + 'PhabricatorCalendarImportSearchEngine' => 'applications/calendar/query/PhabricatorCalendarImportSearchEngine.php', 2109 + 'PhabricatorCalendarImportTransaction' => 'applications/calendar/storage/PhabricatorCalendarImportTransaction.php', 2110 + 'PhabricatorCalendarImportTransactionQuery' => 'applications/calendar/query/PhabricatorCalendarImportTransactionQuery.php', 2103 2111 'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php', 2104 2112 'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php', 2105 2113 'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php', ··· 6789 6797 'PhabricatorCalendarEvent' => array( 6790 6798 'PhabricatorCalendarDAO', 6791 6799 'PhabricatorPolicyInterface', 6800 + 'PhabricatorExtendedPolicyInterface', 6792 6801 'PhabricatorProjectInterface', 6793 6802 'PhabricatorMarkupInterface', 6794 6803 'PhabricatorApplicationTransactionInterface', ··· 6879 6888 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 6880 6889 'PhabricatorCalendarICSWriter' => 'Phobject', 6881 6890 'PhabricatorCalendarIconSet' => 'PhabricatorIconSet', 6891 + 'PhabricatorCalendarImport' => array( 6892 + 'PhabricatorCalendarDAO', 6893 + 'PhabricatorPolicyInterface', 6894 + 'PhabricatorApplicationTransactionInterface', 6895 + 'PhabricatorDestructibleInterface', 6896 + ), 6897 + 'PhabricatorCalendarImportEditor' => 'PhabricatorApplicationTransactionEditor', 6898 + 'PhabricatorCalendarImportListController' => 'PhabricatorCalendarController', 6899 + 'PhabricatorCalendarImportPHIDType' => 'PhabricatorPHIDType', 6900 + 'PhabricatorCalendarImportQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6901 + 'PhabricatorCalendarImportSearchEngine' => 'PhabricatorApplicationSearchEngine', 6902 + 'PhabricatorCalendarImportTransaction' => 'PhabricatorModularTransaction', 6903 + 'PhabricatorCalendarImportTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6882 6904 'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule', 6883 6905 'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 6884 6906 'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec',
+10 -1
src/applications/calendar/application/PhabricatorCalendarApplication.php
··· 73 73 => 'PhabricatorCalendarExportICSController', 74 74 'disable/(?P<id>[1-9]\d*)/' 75 75 => 'PhabricatorCalendarExportDisableController', 76 - 76 + ), 77 + 'import/' => array( 78 + $this->getQueryRoutePattern() 79 + => 'PhabricatorCalendarImportListController', 80 + $this->getEditRoutePattern('edit/') 81 + => 'PhabricatorCalendarImportEditController', 82 + '(?P<id>[1-9]\d*)/' 83 + => 'PhabricatorCalendarImportViewController', 84 + 'disable/(?P<id>[1-9]\d*)/' 85 + => 'PhabricatorCalendarImportDisableController', 77 86 ), 78 87 ), 79 88 );
+4
src/applications/calendar/controller/PhabricatorCalendarEventListController.php
··· 44 44 ->setName(pht('Import/Export')); 45 45 46 46 $items[] = id(new PHUIListItemView()) 47 + ->setName('Imports') 48 + ->setHref('/calendar/import/'); 49 + 50 + $items[] = id(new PHUIListItemView()) 47 51 ->setName('Exports') 48 52 ->setHref('/calendar/export/'); 49 53
+12
src/applications/calendar/controller/PhabricatorCalendarImportListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportListController 4 + extends PhabricatorCalendarController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + return id(new PhabricatorCalendarImportSearchEngine()) 8 + ->setController($this) 9 + ->buildResponse(); 10 + } 11 + 12 + }
+18
src/applications/calendar/editor/PhabricatorCalendarImportEditor.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportEditor 4 + extends PhabricatorApplicationTransactionEditor { 5 + 6 + public function getEditorApplicationClass() { 7 + return 'PhabricatorCalendarApplication'; 8 + } 9 + 10 + public function getEditorObjectsDescription() { 11 + return pht('Calendar Imports'); 12 + } 13 + 14 + public function getCreateObjectTitle($author, $object) { 15 + return pht('%s created this import.', $author); 16 + } 17 + 18 + }
+50
src/applications/calendar/phid/PhabricatorCalendarImportPHIDType.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportPHIDType extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'CIMP'; 6 + 7 + public function getTypeName() { 8 + return pht('Calendar Import'); 9 + } 10 + 11 + public function newObject() { 12 + return new PhabricatorCalendarImport(); 13 + } 14 + 15 + public function getPHIDTypeApplicationClass() { 16 + return 'PhabricatorCalendarApplication'; 17 + } 18 + 19 + protected function buildQueryForObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorCalendarImportQuery()) 24 + ->withPHIDs($phids); 25 + } 26 + 27 + public function loadHandles( 28 + PhabricatorHandleQuery $query, 29 + array $handles, 30 + array $objects) { 31 + 32 + foreach ($handles as $phid => $handle) { 33 + $import = $objects[$phid]; 34 + 35 + $id = $import->getID(); 36 + $name = $import->getName(); 37 + $uri = $import->getURI(); 38 + 39 + $handle 40 + ->setName($name) 41 + ->setFullName(pht('Calendar Import %s: %s', $id, $name)) 42 + ->setURI($uri); 43 + 44 + if ($import->getIsDisabled()) { 45 + $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); 46 + } 47 + } 48 + } 49 + 50 + }
+49 -1
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
··· 14 14 private $instanceSequencePairs; 15 15 private $isStub; 16 16 private $parentEventPHIDs; 17 + private $importSourcePHIDs; 17 18 18 19 private $generateGhosts = false; 19 20 ··· 74 75 75 76 public function withParentEventPHIDs(array $parent_phids) { 76 77 $this->parentEventPHIDs = $parent_phids; 78 + return $this; 79 + } 80 + 81 + public function withImportSourcePHIDs(array $import_phids) { 82 + $this->importSourcePHIDs = $import_phids; 77 83 return $this; 78 84 } 79 85 ··· 411 417 $this->parentEventPHIDs); 412 418 } 413 419 420 + if ($this->importSourcePHIDs !== null) { 421 + $where[] = qsprintf( 422 + $conn, 423 + 'event.importSourcePHID IN (%Ls)', 424 + $this->importSourcePHIDs); 425 + } 426 + 414 427 return $where; 415 428 } 416 429 ··· 440 453 $viewer = $this->getViewer(); 441 454 442 455 $events = $this->getEventsInRange($events); 456 + 457 + $import_phids = array(); 458 + foreach ($events as $event) { 459 + $import_phid = $event->getImportSourcePHID(); 460 + if ($import_phid !== null) { 461 + $import_phids[$import_phid] = $import_phid; 462 + } 463 + } 464 + 465 + if ($import_phids) { 466 + $imports = id(new PhabricatorCalendarImportQuery()) 467 + ->setParentQuery($this) 468 + ->setViewer($viewer) 469 + ->withPHIDs($import_phids) 470 + ->execute(); 471 + $sources = mpull($sources, null, 'getPHID'); 472 + } else { 473 + $sources = array(); 474 + } 475 + 476 + foreach ($events as $key => $event) { 477 + $import_phid = $event->getImportSourcePHID(); 478 + if ($import_phid === null) { 479 + $event->attachImportSource(null); 480 + continue; 481 + } 482 + 483 + $import = idx($imports, $import_phid); 484 + if (!$import) { 485 + unset($events[$key]); 486 + $this->didRejectResult($event); 487 + continue; 488 + } 489 + 490 + $event->attachImportSource($import); 491 + } 443 492 444 493 $phids = array(); 445 494 ··· 560 609 561 610 return $raw_limit; 562 611 } 563 - 564 612 565 613 }
+81
src/applications/calendar/query/PhabricatorCalendarImportQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + private $authorPHIDs; 9 + private $isDisabled; 10 + 11 + public function withIDs(array $ids) { 12 + $this->ids = $ids; 13 + return $this; 14 + } 15 + 16 + public function withPHIDs(array $phids) { 17 + $this->phids = $phids; 18 + return $this; 19 + } 20 + 21 + public function withAuthorPHIDs(array $phids) { 22 + $this->authorPHIDs = $phids; 23 + return $this; 24 + } 25 + 26 + public function withIsDisabled($is_disabled) { 27 + $this->isDisabled = $is_disabled; 28 + return $this; 29 + } 30 + 31 + public function newResultObject() { 32 + return new PhabricatorCalendarImport(); 33 + } 34 + 35 + protected function loadPage() { 36 + return $this->loadStandardPage($this->newResultObject()); 37 + } 38 + 39 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 40 + $where = parent::buildWhereClauseParts($conn); 41 + 42 + if ($this->ids !== null) { 43 + $where[] = qsprintf( 44 + $conn, 45 + 'import.id IN (%Ld)', 46 + $this->ids); 47 + } 48 + 49 + if ($this->phids !== null) { 50 + $where[] = qsprintf( 51 + $conn, 52 + 'import.phid IN (%Ls)', 53 + $this->phids); 54 + } 55 + 56 + if ($this->authorPHIDs !== null) { 57 + $where[] = qsprintf( 58 + $conn, 59 + 'import.authorPHID IN (%Ls)', 60 + $this->authorPHIDs); 61 + } 62 + 63 + if ($this->isDisabled !== null) { 64 + $where[] = qsprintf( 65 + $conn, 66 + 'import.isDisabled = %d', 67 + (int)$this->isDisabled); 68 + } 69 + 70 + return $where; 71 + } 72 + 73 + protected function getPrimaryTableAlias() { 74 + return 'import'; 75 + } 76 + 77 + public function getQueryApplicationClass() { 78 + return 'PhabricatorCalendarApplication'; 79 + } 80 + 81 + }
+81
src/applications/calendar/query/PhabricatorCalendarImportSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Calendar Imports'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorCalendarApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new PhabricatorCalendarImportQuery(); 16 + } 17 + 18 + protected function buildCustomSearchFields() { 19 + return array(); 20 + } 21 + 22 + protected function buildQueryFromParameters(array $map) { 23 + $query = $this->newQuery(); 24 + 25 + return $query; 26 + } 27 + 28 + protected function getURI($path) { 29 + return '/calendar/import/'.$path; 30 + } 31 + 32 + protected function getBuiltinQueryNames() { 33 + $names = array( 34 + 'all' => pht('All Imports'), 35 + ); 36 + 37 + return $names; 38 + } 39 + 40 + public function buildSavedQueryFromBuiltin($query_key) { 41 + $query = $this->newSavedQuery(); 42 + $query->setQueryKey($query_key); 43 + 44 + switch ($query_key) { 45 + case 'all': 46 + return $query; 47 + } 48 + 49 + return parent::buildSavedQueryFromBuiltin($query_key); 50 + } 51 + 52 + protected function renderResultList( 53 + array $imports, 54 + PhabricatorSavedQuery $query, 55 + array $handles) { 56 + 57 + assert_instances_of($imports, 'PhabricatorCalendarImport'); 58 + $viewer = $this->requireViewer(); 59 + 60 + $list = new PHUIObjectItemListView(); 61 + foreach ($imports as $import) { 62 + $item = id(new PHUIObjectItemView()) 63 + ->setViewer($viewer) 64 + ->setObjectName(pht('Import %d', $import->getID())) 65 + ->setHeader($import->getName()) 66 + ->setHref($import->getURI()); 67 + 68 + if ($import->getIsDisabled()) { 69 + $item->setDisabled(true); 70 + } 71 + 72 + $list->addItem($item); 73 + } 74 + 75 + $result = new PhabricatorApplicationSearchResultView(); 76 + $result->setObjectList($list); 77 + $result->setNoDataString(pht('No imports found.')); 78 + 79 + return $result; 80 + } 81 + }
+10
src/applications/calendar/query/PhabricatorCalendarImportTransactionQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportTransactionQuery 4 + extends PhabricatorApplicationTransactionQuery { 5 + 6 + public function getTemplateApplicationTransaction() { 7 + return new PhabricatorCalendarImportTransaction(); 8 + } 9 + 10 + }
+69 -1
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 3 3 final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO 4 4 implements 5 5 PhabricatorPolicyInterface, 6 + PhabricatorExtendedPolicyInterface, 6 7 PhabricatorProjectInterface, 7 8 PhabricatorMarkupInterface, 8 9 PhabricatorApplicationTransactionInterface, ··· 40 41 protected $utcInstanceEpoch; 41 42 protected $parameters = array(); 42 43 44 + protected $importAuthorPHID; 45 + protected $importSourcePHID; 46 + protected $importUIDIndex; 47 + protected $importUID; 48 + 43 49 private $parentEvent = self::ATTACHABLE; 44 50 private $invitees = self::ATTACHABLE; 51 + private $importSource = self::ATTACHABLE; 45 52 46 53 private $viewerTimezone; 47 54 ··· 90 97 ->setAllDayDateTo(0) 91 98 ->setStartDateTime($datetime_start) 92 99 ->setEndDateTime($datetime_end) 100 + ->attachImportSource(null) 93 101 ->applyViewerTimezone($actor); 94 102 } 95 103 ··· 306 314 $this->mailKey = Filesystem::readRandomCharacters(20); 307 315 } 308 316 317 + $import_uid = $this->getImportUID(); 318 + if ($import_uid !== null) { 319 + $index = PhabricatorHash::digestForIndex($import_uid); 320 + } else { 321 + $index = null; 322 + } 323 + $this->setImportUIDIndex($index); 324 + 309 325 $this->updateUTCEpochs(); 310 326 311 327 return parent::save(); ··· 343 359 'utcInitialEpoch' => 'epoch', 344 360 'utcUntilEpoch' => 'epoch?', 345 361 'utcInstanceEpoch' => 'epoch?', 362 + 363 + 'importAuthorPHID' => 'phid?', 364 + 'importSourcePHID' => 'phid?', 365 + 'importUIDIndex' => 'bytes12?', 366 + 'importUID' => 'text?', 346 367 347 368 // TODO: DEPRECATED. 348 369 'allDayDateFrom' => 'epoch', ··· 885 906 return $set; 886 907 } 887 908 909 + public function getImportSource() { 910 + return $this->assertAttached($this->importSource); 911 + } 912 + 913 + public function attachImportSource( 914 + PhabricatorCalendarImport $import = null) { 915 + $this->importSource = $import; 916 + return $this; 917 + } 918 + 919 + 888 920 /* -( Markup Interface )--------------------------------------------------- */ 889 921 890 922 ··· 947 979 case PhabricatorPolicyCapability::CAN_VIEW: 948 980 return $this->getViewPolicy(); 949 981 case PhabricatorPolicyCapability::CAN_EDIT: 950 - return $this->getEditPolicy(); 982 + if ($this->getImportSource()) { 983 + return PhabricatorPolicy::POLICY_NOONE; 984 + } else { 985 + return $this->getEditPolicy(); 986 + } 951 987 } 952 988 } 953 989 954 990 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 991 + if ($this->getImportSource()) { 992 + return false; 993 + } 994 + 955 995 // The host of an event can always view and edit it. 956 996 $user_phid = $this->getHostPHID(); 957 997 if ($user_phid) { ··· 974 1014 } 975 1015 976 1016 public function describeAutomaticCapability($capability) { 1017 + if ($this->getImportSource()) { 1018 + return pht( 1019 + 'Events imported from external sources can not be edited in '. 1020 + 'Phabricator.'); 1021 + } 1022 + 977 1023 return pht( 978 1024 'The host of an event can always view and edit it. Users who are '. 979 1025 'invited to an event can always view it.'); 1026 + } 1027 + 1028 + 1029 + /* -( PhabricatorExtendedPolicyInterface )--------------------------------- */ 1030 + 1031 + 1032 + public function getExtendedPolicy($capability, PhabricatorUser $viewer) { 1033 + $extended = array(); 1034 + 1035 + switch ($capability) { 1036 + case PhabricatorPolicyCapability::CAN_VIEW: 1037 + $import_source = $this->getImportSource(); 1038 + if ($import_source) { 1039 + $extended[] = array( 1040 + $import_source, 1041 + PhabricatorPolicyCapability::CAN_VIEW, 1042 + ); 1043 + } 1044 + break; 1045 + } 1046 + 1047 + return $extended; 980 1048 } 981 1049 982 1050
+126
src/applications/calendar/storage/PhabricatorCalendarImport.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImport 4 + extends PhabricatorCalendarDAO 5 + implements 6 + PhabricatorPolicyInterface, 7 + PhabricatorApplicationTransactionInterface, 8 + PhabricatorDestructibleInterface { 9 + 10 + protected $name; 11 + protected $authorPHID; 12 + protected $viewPolicy; 13 + protected $editPolicy; 14 + protected $engineType; 15 + protected $parameters = array(); 16 + protected $isDisabled = 0; 17 + 18 + private $engine = self::ATTACHABLE; 19 + 20 + public static function initializeNewCalendarImport(PhabricatorUser $actor) { 21 + return id(new self()) 22 + ->setAuthorPHID($actor->getPHID()) 23 + ->setViewPolicy($actor->getPHID()) 24 + ->setEditPolicy($actor->getPHID()) 25 + ->setIsDisabled(0); 26 + } 27 + 28 + protected function getConfiguration() { 29 + return array( 30 + self::CONFIG_AUX_PHID => true, 31 + self::CONFIG_SERIALIZATION => array( 32 + 'parameters' => self::SERIALIZATION_JSON, 33 + ), 34 + self::CONFIG_COLUMN_SCHEMA => array( 35 + 'name' => 'text', 36 + 'engineType' => 'text64', 37 + 'isDisabled' => 'bool', 38 + ), 39 + self::CONFIG_KEY_SCHEMA => array( 40 + 'key_author' => array( 41 + 'columns' => array('authorPHID'), 42 + ), 43 + ), 44 + ) + parent::getConfiguration(); 45 + } 46 + 47 + public function getPHIDType() { 48 + return PhabricatorCalendarImportPHIDType::TYPECONST; 49 + } 50 + 51 + public function getURI() { 52 + $id = $this->getID(); 53 + return "/calendar/import/{$id}/"; 54 + } 55 + 56 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 57 + 58 + 59 + public function getCapabilities() { 60 + return array( 61 + PhabricatorPolicyCapability::CAN_VIEW, 62 + PhabricatorPolicyCapability::CAN_EDIT, 63 + ); 64 + } 65 + 66 + public function getPolicy($capability) { 67 + switch ($capability) { 68 + case PhabricatorPolicyCapability::CAN_VIEW: 69 + return $this->getViewPolicy(); 70 + case PhabricatorPolicyCapability::CAN_EDIT: 71 + return $this->getEditPolicy(); 72 + } 73 + } 74 + 75 + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 76 + return false; 77 + } 78 + 79 + public function describeAutomaticCapability($capability) { 80 + return null; 81 + } 82 + 83 + 84 + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 85 + 86 + 87 + public function getApplicationTransactionEditor() { 88 + return new PhabricatorCalendarImportEditor(); 89 + } 90 + 91 + public function getApplicationTransactionObject() { 92 + return $this; 93 + } 94 + 95 + public function getApplicationTransactionTemplate() { 96 + return new PhabricatorCalendarImportTransaction(); 97 + } 98 + 99 + public function willRenderTimeline( 100 + PhabricatorApplicationTransactionView $timeline, 101 + AphrontRequest $request) { 102 + return $timeline; 103 + } 104 + 105 + 106 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 107 + 108 + 109 + public function destroyObjectPermanently( 110 + PhabricatorDestructionEngine $engine) { 111 + $viewer = $engine->getViewer(); 112 + 113 + $this->openTransaction(); 114 + 115 + $events = id(new PhabricatorCalendarEventQuery()) 116 + ->withImportSourcePHIDs(array($this->getPHID())) 117 + ->execute(); 118 + foreach ($events as $event) { 119 + $engine->destroyObject($event); 120 + } 121 + 122 + $this->delete(); 123 + $this->saveTransaction(); 124 + } 125 + 126 + }
+18
src/applications/calendar/storage/PhabricatorCalendarImportTransaction.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportTransaction 4 + extends PhabricatorModularTransaction { 5 + 6 + public function getApplicationName() { 7 + return 'calendar'; 8 + } 9 + 10 + public function getApplicationTransactionType() { 11 + return PhabricatorCalendarImportPHIDType::TYPECONST; 12 + } 13 + 14 + public function getBaseTransactionClass() { 15 + return 'PhabricatorCalendarImportTransactionType'; 16 + } 17 + 18 + }
+1 -1
src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
··· 187 187 return array($this->getAuthorPHID()); 188 188 } 189 189 190 - /* -( PhabricatorDestructableInterface )----------------------------------- */ 190 + /* -( PhabricatorDestructibleInterface )----------------------------------- */ 191 191 192 192 public function destroyObjectPermanently( 193 193 PhabricatorDestructionEngine $engine) {