From 1253e56352a9a8498e48f9a1a5f81aa7e78db85f Mon Sep 17 00:00:00 2001 From: Anh Nhan Nguyen Date: Thu, 21 Mar 2013 09:09:30 -0700 Subject: [PATCH] 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 --- .../controller/PhrictionDeleteController.php | 8 +++--- .../controller/PhrictionMoveController.php | 25 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) 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 @@ -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'); } 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 @@ -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); }