Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/editor/PhrictionTransactionEditor.php
Show First 20 Lines • Show All 582 Lines • ▼ Show 20 Lines | foreach ($xactions as $xaction) { | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withSlugs(array($object->getSlug())) | ->withSlugs(array($object->getSlug())) | ||||
->needContent(true) | ->needContent(true) | ||||
->executeOne(); | ->executeOne(); | ||||
// Prevent overwrites and no-op moves. | // Prevent overwrites and no-op moves. | ||||
$exists = PhrictionDocumentStatus::STATUS_EXISTS; | $exists = PhrictionDocumentStatus::STATUS_EXISTS; | ||||
if ($target_document) { | if ($target_document) { | ||||
$message = null; | |||||
if ($target_document->getSlug() == $source_document->getSlug()) { | if ($target_document->getSlug() == $source_document->getSlug()) { | ||||
$message = pht( | $message = pht( | ||||
'You can not move a document to its existing location. '. | 'You can not move a document to its existing location. '. | ||||
'Choose a different location to move the document to.'); | 'Choose a different location to move the document to.'); | ||||
} else if ($target_document->getStatus() == $exists) { | } else if ($target_document->getStatus() == $exists) { | ||||
$message = pht( | $message = pht( | ||||
'You can not move this document there, because it would '. | 'You can not move this document there, because it would '. | ||||
'overwrite an existing document which is already at that '. | 'overwrite an existing document which is already at that '. | ||||
'location. Move or delete the existing document first.'); | 'location. Move or delete the existing document first.'); | ||||
} | } | ||||
if ($message !== null) { | |||||
$error = new PhabricatorApplicationTransactionValidationError( | $error = new PhabricatorApplicationTransactionValidationError( | ||||
$type, | $type, | ||||
pht('Invalid'), | pht('Invalid'), | ||||
$message, | $message, | ||||
$xaction); | $xaction); | ||||
$errors[] = $error; | $errors[] = $error; | ||||
} | } | ||||
} | |||||
break; | break; | ||||
case PhrictionTransaction::TYPE_DELETE: | case PhrictionTransaction::TYPE_DELETE: | ||||
switch ($object->getStatus()) { | switch ($object->getStatus()) { | ||||
case PhrictionDocumentStatus::STATUS_DELETED: | case PhrictionDocumentStatus::STATUS_DELETED: | ||||
if ($xaction->getMetadataValue('contentDelete')) { | if ($xaction->getMetadataValue('contentDelete')) { | ||||
$e_text = pht( | $e_text = pht( | ||||
'This document is already deleted. You must specify '. | 'This document is already deleted. You must specify '. | ||||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |