mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
49448a87c1
Summary: Ref T10747. Rough flow is: - Run a query. - Select a new "Export Events..." action. - This lets you define an "Export", which has a unique URL you can paste into Google Calendar or Calendar.app or whatever. Most of this does nothing yet but here's the boilerplate. Test Plan: Doesn't do anything yet. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16675
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorCalendarExportModeTransaction
|
|
extends PhabricatorCalendarExportTransactionType {
|
|
|
|
const TRANSACTIONTYPE = 'calendar.export.mode';
|
|
|
|
public function generateOldValue($object) {
|
|
return $object->getPolicyMode();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setPolicyMode($value);
|
|
}
|
|
|
|
public function getTitle() {
|
|
$old_value = $this->getOldValue();
|
|
$new_value = $this->getNewValue();
|
|
|
|
$old_name = PhabricatorCalendarExport::getPolicyModeName($old_value);
|
|
$new_name = PhabricatorCalendarExport::getPolicyModeName($new_value);
|
|
|
|
return pht(
|
|
'%s changed the policy mode for this export from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderValue($old_name),
|
|
$this->renderValue($new_name));
|
|
}
|
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
$errors = array();
|
|
|
|
$valid = PhabricatorCalendarExport::getPolicyModes();
|
|
$valid = array_fuse($valid);
|
|
|
|
foreach ($xactions as $xaction) {
|
|
$value = $xaction->getNewValue();
|
|
|
|
if (isset($valid[$value])) {
|
|
continue;
|
|
}
|
|
|
|
$errors[] = $this->newInvalidError(
|
|
pht(
|
|
'Mode "%s" is not a valid policy mode. Valid modes are: %s.',
|
|
$value,
|
|
implode(', ', $valid)),
|
|
$xaction);
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
}
|