Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionEditController.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public function processRequest() { | ||||
require_celerity_resource('phriction-document-css'); | require_celerity_resource('phriction-document-css'); | ||||
$e_title = true; | $e_title = true; | ||||
$notes = null; | $notes = null; | ||||
$errors = array(); | $errors = array(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$overwrite = $request->getBool('overwrite'); | |||||
if (!$overwrite) { | |||||
$edit_version = $request->getStr('contentVersion'); | |||||
$current_version = $content->getVersion(); | |||||
if ($edit_version != $current_version) { | |||||
$dialog = $this->newDialog() | |||||
->setTitle(pht('Edit Conflict!')) | |||||
->appendParagraph( | |||||
pht( | |||||
'Another user made changes to this document after you began '. | |||||
'editing it. Do you want to overwrite their changes?')) | |||||
->appendParagraph( | |||||
pht( | |||||
'If you choose to overwrite their changes, you should review '. | |||||
'the document edit history to see what you overwrote, and '. | |||||
'then make another edit to merge the changes if necessary.')) | |||||
->addSubmitButton(pht('Overwrite Changes')) | |||||
->addCancelButton($request->getRequestURI()); | |||||
$dialog->addHiddenInput('overwrite', 'true'); | |||||
foreach ($request->getPassthroughRequestData() as $key => $value) { | |||||
$dialog->addHiddenInput($key, $value); | |||||
} | |||||
return $dialog; | |||||
} | |||||
} | |||||
$title = $request->getStr('title'); | $title = $request->getStr('title'); | ||||
$notes = $request->getStr('description'); | $notes = $request->getStr('description'); | ||||
if (!strlen($title)) { | if (!strlen($title)) { | ||||
$e_title = pht('Required'); | $e_title = pht('Required'); | ||||
$errors[] = pht('Document title is required.'); | $errors[] = pht('Document title is required.'); | ||||
} else { | } else { | ||||
$e_title = null; | $e_title = null; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | public function processRequest() { | ||||
} | } | ||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->setAction($request->getRequestURI()->getPath()) | ->setAction($request->getRequestURI()->getPath()) | ||||
->addHiddenInput('slug', $document->getSlug()) | ->addHiddenInput('slug', $document->getSlug()) | ||||
->addHiddenInput('nodraft', $request->getBool('nodraft')) | ->addHiddenInput('nodraft', $request->getBool('nodraft')) | ||||
->addHiddenInput('contentVersion', $content->getVersion()) | |||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormTextControl()) | id(new AphrontFormTextControl()) | ||||
->setLabel(pht('Title')) | ->setLabel(pht('Title')) | ||||
->setValue($content->getTitle()) | ->setValue($content->getTitle()) | ||||
->setError($e_title) | ->setError($e_title) | ||||
->setName('title')) | ->setName('title')) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormStaticControl()) | id(new AphrontFormStaticControl()) | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |