3 final class PhabricatorCalendarICSURIImportEngine
4 extends PhabricatorCalendarICSImportEngine
{
6 const ENGINETYPE
= 'icsuri';
8 public function getImportEngineName() {
9 return pht('Import .ics URI');
12 public function getImportEngineTypeName() {
13 return pht('.ics URI');
16 public function getImportEngineHint() {
17 return pht('Import or subscribe to a calendar in .ics format by URI.');
20 public function supportsTriggers(PhabricatorCalendarImport
$import) {
24 public function appendImportProperties(
25 PhabricatorUser
$viewer,
26 PhabricatorCalendarImport
$import,
27 PHUIPropertyListView
$properties) {
29 $uri_key = PhabricatorCalendarImportICSURITransaction
::PARAMKEY_URI
;
30 $uri = $import->getParameter($uri_key);
32 // Since the URI may contain a secret hash, don't show it to users who
33 // can not edit the import.
34 $can_edit = PhabricatorPolicyFilter
::hasCapability(
37 PhabricatorPolicyCapability
::CAN_EDIT
);
39 $uri_display = phutil_tag('em', array(), pht('Restricted'));
40 } else if (!PhabricatorEnv
::isValidRemoteURIForLink($uri)) {
43 $uri_display = phutil_tag(
48 'rel' => 'noreferrer',
53 $properties->addProperty(pht('Source URI'), $uri_display);
56 public function newEditEngineFields(
57 PhabricatorEditEngine
$engine,
58 PhabricatorCalendarImport
$import) {
61 if ($engine->getIsCreate()) {
62 $fields[] = id(new PhabricatorTextEditField())
64 ->setLabel(pht('URI'))
65 ->setDescription(pht('URI to import.'))
67 PhabricatorCalendarImportICSURITransaction
::TRANSACTIONTYPE
)
68 ->setConduitDescription(pht('URI to import.'))
69 ->setConduitTypeDescription(pht('New URI.'));
75 public function getDisplayName(PhabricatorCalendarImport
$import) {
76 return pht('ICS URI');
79 public function importEventsFromSource(
80 PhabricatorUser
$viewer,
81 PhabricatorCalendarImport
$import,
84 $uri_key = PhabricatorCalendarImportICSURITransaction
::PARAMKEY_URI
;
85 $uri = $import->getParameter($uri_key);
87 PhabricatorSystemActionEngine
::willTakeAction(
88 array($viewer->getPHID()),
89 new PhabricatorFilesOutboundRequestAction(),
92 $file = PhabricatorFile
::newFromFileDownload(
95 'viewPolicy' => PhabricatorPolicies
::POLICY_NOONE
,
96 'authorPHID' => $import->getAuthorPHID(),
100 $import->newLogMessage(
101 PhabricatorCalendarImportFetchLogType
::LOGTYPE
,
103 'file.phid' => $file->getPHID(),
106 $data = $file->loadFileData();
108 if ($should_queue && $this->shouldQueueDataImport($data)) {
109 return $this->queueDataImport($import, $data);
112 return $this->importICSData($viewer, $import, $data);
115 public function canDisable(
116 PhabricatorUser
$viewer,
117 PhabricatorCalendarImport
$import) {