diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php index c4e4fed588..05c12aec27 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php @@ -3,19 +3,13 @@ final class PhabricatorSlowvoteCloseController extends PhabricatorSlowvoteController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $poll = id(new PhabricatorSlowvoteQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -42,7 +36,7 @@ final class PhabricatorSlowvoteCloseController ->setNewValue($new_status); id(new PhabricatorSlowvoteEditor()) - ->setActor($user) + ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php index 588f06b649..035eb577d8 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php @@ -3,23 +3,17 @@ final class PhabricatorSlowvoteCommentController extends PhabricatorSlowvoteController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); if (!$request->isFormPost()) { return new Aphront400Response(); } $poll = id(new PhabricatorSlowvoteQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->executeOne(); if (!$poll) { return new Aphront404Response(); @@ -38,7 +32,7 @@ final class PhabricatorSlowvoteCommentController ->setContent($request->getStr('comment'))); $editor = id(new PhabricatorSlowvoteEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect($request->isContinueRequest()) ->setContentSourceFromRequest($request) ->setIsPreview($is_preview); @@ -57,7 +51,7 @@ final class PhabricatorSlowvoteCommentController if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse()) - ->setViewer($user) + ->setViewer($viewer) ->setTransactions($xactions) ->setIsPreview($is_preview); } else { diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php index 44d9cec792..e497a50fbc 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -3,21 +3,14 @@ final class PhabricatorSlowvoteEditController extends PhabricatorSlowvoteController { - private $id; + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); - public function willProcessRequest(array $data) { - $this->id = idx($data, 'id'); - } - - public function processRequest() { - - $request = $this->getRequest(); - $user = $request->getUser(); - - if ($this->id) { + if ($id) { $poll = id(new PhabricatorSlowvoteQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -29,7 +22,7 @@ final class PhabricatorSlowvoteEditController } $is_new = false; } else { - $poll = PhabricatorSlowvotePoll::initializeNewPoll($user); + $poll = PhabricatorSlowvotePoll::initializeNewPoll($viewer); $is_new = true; } @@ -119,7 +112,7 @@ final class PhabricatorSlowvoteEditController ->setNewValue(array('=' => array_fuse($v_projects))); $editor = id(new PhabricatorSlowvoteEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); @@ -153,7 +146,7 @@ final class PhabricatorSlowvoteEditController 'protracted deliberation.')); $form = id(new AphrontFormView()) - ->setUser($user) + ->setUser($viewer) ->appendChild($instructions) ->appendChild( id(new AphrontFormTextAreaControl()) @@ -164,7 +157,7 @@ final class PhabricatorSlowvoteEditController ->setError($e_question)) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setUser($user) + ->setUser($viewer) ->setLabel(pht('Description')) ->setName('description') ->setValue($v_description)) @@ -232,7 +225,7 @@ final class PhabricatorSlowvoteEditController } $policies = id(new PhabricatorPolicyQuery()) - ->setViewer($user) + ->setViewer($viewer) ->setObject($poll) ->execute(); @@ -253,7 +246,7 @@ final class PhabricatorSlowvoteEditController $v_shuffle)) ->appendChild( id(new AphrontFormPolicyControl()) - ->setUser($user) + ->setUser($viewer) ->setName('viewPolicy') ->setPolicyObject($poll) ->setPolicies($policies) diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php index 8062fc4098..bbb96d4dc4 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteListController.php @@ -3,19 +3,15 @@ final class PhabricatorSlowvoteListController extends PhabricatorSlowvoteController { - private $queryKey; - public function shouldAllowPublic() { return true; } - public function willProcessRequest(array $data) { - $this->queryKey = idx($data, 'queryKey'); - } + public function handleRequest(AphrontRequest $request) { + $querykey = $request->getURIData('queryKey'); - public function processRequest() { $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($this->queryKey) + ->setQueryKey($querykey) ->setSearchEngine(new PhabricatorSlowvoteSearchEngine()) ->setNavigation($this->buildSideNavView()); diff --git a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php index 9bac0a6088..40980e5f41 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php @@ -3,19 +3,13 @@ final class PhabricatorSlowvotePollController extends PhabricatorSlowvoteController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $poll = id(new PhabricatorSlowvoteQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->needOptions(true) ->needChoices(true) ->needViewerChoices(true) @@ -26,7 +20,7 @@ final class PhabricatorSlowvotePollController $poll_view = id(new SlowvoteEmbedView()) ->setHeadless(true) - ->setUser($user) + ->setUser($viewer) ->setPoll($poll); if ($request->isAjax()) { @@ -44,7 +38,7 @@ final class PhabricatorSlowvotePollController $header = id(new PHUIHeaderView()) ->setHeader($poll->getQuestion()) - ->setUser($user) + ->setUser($viewer) ->setStatus($header_icon, $header_color, $header_name) ->setPolicyObject($poll); diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteVoteController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteVoteController.php index 6cfeae0ac0..2d630bffc1 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteVoteController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteVoteController.php @@ -3,19 +3,13 @@ final class PhabricatorSlowvoteVoteController extends PhabricatorSlowvoteController { - private $id; - - public function willProcessRequest(array $data) { - $this->id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $request->getViewer(); + $id = $request->getURIData('id'); $poll = id(new PhabricatorSlowvoteQuery()) - ->setViewer($user) - ->withIDs(array($this->id)) + ->setViewer($viewer) + ->withIDs(array($id)) ->needOptions(true) ->needViewerChoices(true) ->executeOne(); @@ -27,9 +21,9 @@ final class PhabricatorSlowvoteVoteController } $options = $poll->getOptions(); - $user_choices = $poll->getViewerChoices($user); + $viewer_choices = $poll->getViewerChoices($viewer); - $old_votes = mpull($user_choices, null, 'getOptionID'); + $old_votes = mpull($viewer_choices, null, 'getOptionID'); if ($request->isAjax()) { $vote = $request->getInt('vote'); @@ -50,12 +44,12 @@ final class PhabricatorSlowvoteVoteController } } - $this->updateVotes($user, $poll, $old_votes, $votes); + $this->updateVotes($viewer, $poll, $old_votes, $votes); $updated_choices = id(new PhabricatorSlowvoteChoice())->loadAllWhere( 'pollID = %d AND authorPHID = %s', $poll->getID(), - $user->getPHID()); + $viewer->getPHID()); $embed = id(new SlowvoteEmbedView()) ->setPoll($poll) @@ -76,12 +70,12 @@ final class PhabricatorSlowvoteVoteController $votes = $request->getArr('vote'); $votes = array_fuse($votes, $votes); - $this->updateVotes($user, $poll, $old_votes, $votes); + $this->updateVotes($viewer, $poll, $old_votes, $votes); return id(new AphrontRedirectResponse())->setURI('/V'.$poll->getID()); } - private function updateVotes($user, $poll, $old_votes, $votes) { + private function updateVotes($viewer, $poll, $old_votes, $votes) { if (!empty($votes) && count($votes) > 1 && $poll->getMethod() == PhabricatorSlowvotePoll::METHOD_PLURALITY) { return id(new Aphront400Response()); @@ -99,7 +93,7 @@ final class PhabricatorSlowvoteVoteController } id(new PhabricatorSlowvoteChoice()) - ->setAuthorPHID($user->getPHID()) + ->setAuthorPHID($viewer->getPHID()) ->setPollID($poll->getID()) ->setOptionID($vote) ->save();