1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Optimizations to Phriction's Move and Delete Controllers

Summary: Refs T2868

Test Plan: verified expected behaviours still apply (means everything works).

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5402
This commit is contained in:
Anh Nhan Nguyen 2013-03-21 09:09:30 -07:00 committed by epriestley
parent 9a515171f4
commit 1253e56352
2 changed files with 14 additions and 19 deletions

View file

@ -23,11 +23,11 @@ final class PhrictionDeleteController extends PhrictionController {
$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');
}

View file

@ -48,24 +48,19 @@ final class PhrictionMoveController
$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);
}