Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
index c37ba6c944..4fde813223 100644
--- a/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
@@ -1,110 +1,110 @@
<?php
final class PhabricatorCalendarICSFileImportEngine
extends PhabricatorCalendarICSImportEngine {
const ENGINETYPE = 'icsfile';
public function getImportEngineName() {
return pht('Import .ics File');
}
public function getImportEngineTypeName() {
return pht('.ics File');
}
public function getImportEngineHint() {
return pht('Import an event in ".ics" (iCalendar) format.');
}
public function supportsTriggers(PhabricatorCalendarImport $import) {
return false;
}
public function appendImportProperties(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import,
PHUIPropertyListView $properties) {
$phid_key = PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE;
$file_phid = $import->getParameter($phid_key);
$properties->addProperty(
pht('Source File'),
$viewer->renderHandle($file_phid));
}
public function newEditEngineFields(
PhabricatorEditEngine $engine,
PhabricatorCalendarImport $import) {
$fields = array();
if ($engine->getIsCreate()) {
$fields[] = id(new PhabricatorFileEditField())
->setKey('icsFilePHID')
->setLabel(pht('ICS File'))
->setDescription(pht('ICS file to import.'))
->setTransactionType(
PhabricatorCalendarImportICSFileTransaction::TRANSACTIONTYPE)
->setConduitDescription(pht('File PHID to import.'))
->setConduitTypeDescription(pht('File PHID.'));
}
return $fields;
}
public function getDisplayName(PhabricatorCalendarImport $import) {
$filename_key = PhabricatorCalendarImportICSFileTransaction::PARAMKEY_NAME;
$filename = $import->getParameter($filename_key);
- if (strlen($filename)) {
+ if (phutil_nonempty_string($filename)) {
return pht('ICS File "%s"', $filename);
} else {
return pht('ICS File');
}
}
public function importEventsFromSource(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import,
$should_queue) {
$phid_key = PhabricatorCalendarImportICSFileTransaction::PARAMKEY_FILE;
$file_phid = $import->getParameter($phid_key);
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($file_phid))
->executeOne();
if (!$file) {
throw new Exception(
pht(
'Unable to load file ("%s") for import.',
$file_phid));
}
$data = $file->loadFileData();
if ($should_queue && $this->shouldQueueDataImport($data)) {
return $this->queueDataImport($import, $data);
}
return $this->importICSData($viewer, $import, $data);
}
public function canDisable(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import) {
return false;
}
public function explainCanDisable(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import) {
return pht(
'You can not disable import of an ICS file because the entire import '.
'occurs immediately when you upload the file. There is no further '.
'activity to disable.');
}
}
diff --git a/src/applications/calendar/xaction/PhabricatorCalendarImportICSFileTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarImportICSFileTransaction.php
index 26a968d13d..51abdd8cad 100644
--- a/src/applications/calendar/xaction/PhabricatorCalendarImportICSFileTransaction.php
+++ b/src/applications/calendar/xaction/PhabricatorCalendarImportICSFileTransaction.php
@@ -1,80 +1,80 @@
<?php
final class PhabricatorCalendarImportICSFileTransaction
extends PhabricatorCalendarImportTransactionType {
const TRANSACTIONTYPE = 'calendar.import.ics.file';
const PARAMKEY_FILE = 'ics.filePHID';
const PARAMKEY_NAME = 'ics.fileName';
public function generateOldValue($object) {
return $object->getParameter(self::PARAMKEY_FILE);
}
public function applyInternalEffects($object, $value) {
$object->setParameter(self::PARAMKEY_FILE, $value);
$viewer = $this->getActor();
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($value))
->executeOne();
if ($file) {
$object->setParameter(self::PARAMKEY_NAME, $file->getName());
}
}
public function getTitle() {
return pht(
'%s imported an ICS file.',
$this->renderAuthor());
}
public function validateTransactions($object, array $xactions) {
$viewer = $this->getActor();
$errors = array();
$ics_type = PhabricatorCalendarICSFileImportEngine::ENGINETYPE;
$import_type = $object->getEngine()->getImportEngineType();
if ($import_type != $ics_type) {
if (!$xactions) {
return $errors;
}
$errors[] = $this->newInvalidError(
pht(
'You can not attach an ICS file to an import type other than '.
'an ICS import (type is "%s").',
$import_type));
return $errors;
}
$new_value = $object->getParameter(self::PARAMKEY_FILE);
foreach ($xactions as $xaction) {
$new_value = $xaction->getNewValue();
- if (!strlen($new_value)) {
+ if (!phutil_nonempty_string($new_value)) {
continue;
}
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($new_value))
->executeOne();
if (!$file) {
$errors[] = $this->newInvalidError(
pht(
'File PHID "%s" is not valid or not visible.',
$new_value),
$xaction);
}
}
if (!$new_value) {
$errors[] = $this->newRequiredError(
pht('You must select an ".ics" file to import.'));
}
return $errors;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 17:55 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127177
Default Alt Text
(6 KB)

Event Timeline