Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893676
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/phriction/controller/PhrictionDeleteController.php b/src/applications/phriction/controller/PhrictionDeleteController.php
index e48dff69fd..649a5a0849 100644
--- a/src/applications/phriction/controller/PhrictionDeleteController.php
+++ b/src/applications/phriction/controller/PhrictionDeleteController.php
@@ -1,63 +1,63 @@
<?php
/**
* @group phriction
*/
final class PhrictionDeleteController extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$e_text = null;
$disallowed_states = array(
- PhrictionDocumentStatus::STATUS_DELETED, // Stupid
- PhrictionDocumentStatus::STATUS_MOVED, // Makes no sense
- PhrictionDocumentStatus::STATUS_STUB, // How could they?
+ PhrictionDocumentStatus::STATUS_DELETED => true, // Silly
+ PhrictionDocumentStatus::STATUS_MOVED => true, // Makes no sense
+ PhrictionDocumentStatus::STATUS_STUB => true, // How could they?
);
- if (in_array($document->getStatus(), $disallowed_states)) {
+ if (isset($disallowed_states[$document->getStatus()])) {
$e_text = pht('An already moved or deleted document can not be deleted');
}
$document_uri = PhrictionDocument::getSlugURI($document->getSlug());
if (!$e_text && $request->isFormPost()) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
->setActor($user)
->delete();
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
if ($e_text) {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Can not delete document!'))
->appendChild($e_text)
->addCancelButton($document_uri);
} else {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Delete document?'))
->appendChild(
pht('Really delete this document? You can recover it later by '.
'reverting to a previous version.'))
->addSubmitButton(pht('Delete'))
->addCancelButton($document_uri);
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
diff --git a/src/applications/phriction/controller/PhrictionMoveController.php b/src/applications/phriction/controller/PhrictionMoveController.php
index 613eaccee3..93981b7b22 100644
--- a/src/applications/phriction/controller/PhrictionMoveController.php
+++ b/src/applications/phriction/controller/PhrictionMoveController.php
@@ -1,157 +1,152 @@
<?php
/**
* @group phriction
*/
final class PhrictionMoveController
extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($this->id) {
$document = id(new PhrictionDocument())->load($this->id);
} else {
$slug = PhabricatorSlug::normalize(
$request->getStr('slug'));
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
}
if (!$document) {
return new Aphront404Response();
}
if (!isset($slug)) {
$slug = $document->getSlug();
}
$target_slug = PhabricatorSlug::normalize(
$request->getStr('new-slug', $slug));
$submit_uri = $request->getRequestURI()->getPath();
$cancel_uri = PhrictionDocument::getSlugURI($slug);
$errors = array();
$error_view = null;
$e_url = null;
- $e_block = false;
$disallowed_statuses = array(
- PhrictionDocumentStatus::STATUS_DELETED, // Stupid
- PhrictionDocumentStatus::STATUS_MOVED, // Plain stupid
- PhrictionDocumentStatus::STATUS_STUB, // Utterly stupid
+ PhrictionDocumentStatus::STATUS_DELETED => true, // Silly
+ PhrictionDocumentStatus::STATUS_MOVED => true, // Plain silly
+ PhrictionDocumentStatus::STATUS_STUB => true, // Utterly silly
);
- if (in_array($document->getStatus(), $disallowed_statuses)) {
- $error_view = new AphrontErrorView();
- $error_view->setSeverity(AphrontErrorView::SEVERITY_ERROR);
- $error_view->appendChild(pht('An already moved or deleted document '.
- 'can not be moved again.'));
-
- $error_dialog = new AphrontDialogView();
- $error_dialog->setUser($user);
- $error_dialog->setTitle("");
- $error_dialog->appendChild($error_view);
- $error_dialog->addCancelButton($cancel_uri, pht('I understand'));
+ if (isset($disallowed_statuses[$document->getStatus()])) {
+ $error_dialog = id(new AphrontDialogView())
+ ->setUser($user)
+ ->setTitle("Can not move page!")
+ ->appendChild(pht('An already moved or deleted document '.
+ 'can not be moved again.'))
+ ->addCancelButton($cancel_uri);
return id(new AphrontDialogResponse())->setDialog($error_dialog);
}
$content = id(new PhrictionContent())->load($document->getContentID());
if ($request->isFormPost() && !count($errors)) {
if (!count($errors)) { // First check if the target document exists
$target_document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$target_slug);
// Considering to overwrite existing docs? Nuke this!
if ($target_document && $target_document->getStatus() ==
PhrictionDocumentStatus::STATUS_EXISTS) {
$errors[] = pht('Can not overwrite existing target document.');
$e_url = pht('Already exists.');
}
}
if (!count($errors)) { // I like to move it, move it!
$from_editor = id(PhrictionDocumentEditor::newForSlug($slug))
->setActor($user)
->setTitle($content->getTitle())
->setContent($content->getContent())
->setDescription($content->getDescription());
$target_editor = id(PhrictionDocumentEditor::newForSlug(
$target_slug))
->setActor($user)
->setTitle($content->getTitle())
->setContent($content->getContent())
->setDescription($content->getDescription());
// Move it!
$target_editor->moveHere($document->getID(), $document->getPHID());
// Retrieve the target doc directly from the editor
// No need to load it per Sql again
$target_document = $target_editor->getDocument();
$from_editor->moveAway($target_document->getID());
$redir_uri = PhrictionDocument::getSlugURI($target_document->getSlug());
return id(new AphrontRedirectResponse())->setURI($redir_uri);
}
}
if ($errors) {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Form Errors'))
->setErrors($errors);
}
$descr_caption = $is_serious ? pht('A reason for the move.') :
pht('You better give a good reason for this.');
$form = id(new AphrontFormLayoutView())
->setUser($user)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Title'))
->setValue($content->getTitle()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('New URI'))
->setValue($target_slug)
->setError($e_url)
->setName('new-slug')
->setCaption(pht('The new location of the document.')))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Edit Notes'))
->setValue($content->getDescription())
->setError(null)
->setName('description')
->setCaption($descr_caption));
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Move Document'))
->appendChild($form)
->setSubmitURI($submit_uri)
->addSubmitButton(pht('Move Document'))
->addCancelButton($cancel_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 18:51 (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127584
Default Alt Text
(8 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment