Summary: Ref T13077. Ref T13197. See PHI840. - In the "History > Diff/Compare" view, the button language wasn't draft-aware. - Revise language to avoid the word "Revert", since this can be ambiguous. - "Edit this page, starting with an older version of the text" is now "Edit Older|Current|Draft Version X". - "Mark this older version of the page as the current published version" is now "Publish Older Version". - Let the user edit the current published version, too, since this is a reasonable operation if there are drafts. Test Plan: Navigated the history diff view, saw better button and action text. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13197, T13077 Differential Revision: https://secure.phabricator.com/D19668
87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
final class PhrictionPublishController
|
|
extends PhrictionController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $request->getViewer();
|
|
$id = $request->getURIData('documentID');
|
|
$content_id = $request->getURIData('contentID');
|
|
|
|
$document = id(new PhrictionDocumentQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($id))
|
|
->needContent(true)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
))
|
|
->executeOne();
|
|
if (!$document) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$document_uri = $document->getURI();
|
|
|
|
$content = id(new PhrictionContentQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($content_id))
|
|
->executeOne();
|
|
if (!$content) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if ($content->getPHID() == $document->getContentPHID()) {
|
|
return $this->newDialog()
|
|
->setTitle(pht('Already Published'))
|
|
->appendChild(
|
|
pht(
|
|
'This version of the document is already the published '.
|
|
'version.'))
|
|
->addCancelButton($document_uri);
|
|
}
|
|
|
|
$content_uri = $document_uri.'?v='.$content->getVersion();
|
|
|
|
if ($request->isFormPost()) {
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PhrictionTransaction())
|
|
->setTransactionType(
|
|
PhrictionDocumentPublishTransaction::TRANSACTIONTYPE)
|
|
->setNewValue($content->getPHID());
|
|
|
|
id(new PhrictionTransactionEditor())
|
|
->setActor($viewer)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect(true)
|
|
->setContinueOnMissingFields(true)
|
|
->applyTransactions($document, $xactions);
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($document_uri);
|
|
}
|
|
|
|
if ($content->getVersion() < $document->getContent()->getVersion()) {
|
|
$title = pht('Publish Older Version?');
|
|
$body = pht(
|
|
'Revert the published version of this document to an older '.
|
|
'version?');
|
|
$button = pht('Revert');
|
|
} else {
|
|
$title = pht('Publish Draft?');
|
|
$body = pht(
|
|
'Update the published version of this document to this newer '.
|
|
'version?');
|
|
$button = pht('Publish');
|
|
}
|
|
|
|
return $this->newDialog()
|
|
->setTitle($title)
|
|
->appendChild($body)
|
|
->addSubmitButton($button)
|
|
->addCancelButton($content_uri);
|
|
}
|
|
|
|
}
|