1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00

adding a warning upon 'creating' a new document on an existing page

Summary: don't remember what I changed except for add that intermediate dialog

Test Plan:
{F35155}

Ugly, ain't it?

you can edit instead, or admit that it was a mistake to take on Phriction's existing documents

Reviewers: epriestley, chad, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2686

Differential Revision: https://secure.phabricator.com/D5295
This commit is contained in:
Anh Nhan Nguyen 2013-03-13 07:39:46 -07:00 committed by epriestley
parent 855e085c6f
commit 4b6c81a23c

View file

@ -12,9 +12,32 @@ final class PhrictionNewController extends PhrictionController {
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
if ($request->isFormPost()) {
$uri = '/phriction/edit/?slug='.$slug;
return id(new AphrontRedirectResponse())
->setURI($uri);
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
$prompt = $request->getStr('prompt', 'no');
$document_exists = $document && $document->getStatus() ==
PhrictionDocumentStatus::STATUS_EXISTS;
if ($document_exists && $prompt == 'no') {
$dialog = new AphrontDialogView();
$dialog->setSubmitURI('/phriction/new/')
->setTitle(pht('Edit Existing Document?'))
->setUser($user)
->appendChild(pht(
'The document %s already exists. Do you want to edit it instead?',
hsprintf('<tt>%s</tt>', $slug)))
->addHiddenInput('slug', $slug)
->addHiddenInput('prompt', 'yes')
->addCancelButton('/w/')
->addSubmitButton(pht('Edit Document'));
return id(new AphrontDialogResponse())->setDialog($dialog);
} else {
$uri = '/phriction/edit/?slug='.$slug;
return id(new AphrontRedirectResponse())
->setURI($uri);
}
}
if ($slug == '/') {