Page MenuHomestyx hydra

No OneTemporary

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
@@ -1,71 +1,65 @@
<?php
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,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$poll) {
return new Aphront404Response();
}
$close_uri = '/V'.$poll->getID();
if ($request->isFormPost()) {
if ($poll->getIsClosed()) {
$new_status = 0;
} else {
$new_status = 1;
}
$xactions = array();
$xactions[] = id(new PhabricatorSlowvoteTransaction())
->setTransactionType(PhabricatorSlowvoteTransaction::TYPE_CLOSE)
->setNewValue($new_status);
id(new PhabricatorSlowvoteEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->applyTransactions($poll, $xactions);
return id(new AphrontRedirectResponse())->setURI($close_uri);
}
if ($poll->getIsClosed()) {
$title = pht('Reopen Poll');
$content = pht('Are you sure you want to reopen the poll?');
$submit = pht('Reopen');
} else {
$title = pht('Close Poll');
$content = pht('Are you sure you want to close the poll?');
$submit = pht('Close');
}
return $this->newDialog()
->setTitle($title)
->appendChild($content)
->addSubmitButton($submit)
->addCancelButton($close_uri);
}
}
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
@@ -1,69 +1,63 @@
<?php
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();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = '/V'.$poll->getID();
$xactions = array();
$xactions[] = id(new PhabricatorSlowvoteTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment(
id(new PhabricatorSlowvoteTransactionComment())
->setContent($request->getStr('comment')));
$editor = id(new PhabricatorSlowvoteEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContinueOnNoEffect($request->isContinueRequest())
->setContentSourceFromRequest($request)
->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($poll, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())
->setCancelURI($view_uri)
->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())
- ->setViewer($user)
+ ->setViewer($viewer)
->setTransactions($xactions)
->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())
->setURI($view_uri);
}
}
}
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
@@ -1,285 +1,278 @@
<?php
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,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$poll) {
return new Aphront404Response();
}
$is_new = false;
} else {
- $poll = PhabricatorSlowvotePoll::initializeNewPoll($user);
+ $poll = PhabricatorSlowvotePoll::initializeNewPoll($viewer);
$is_new = true;
}
if ($is_new) {
$v_projects = array();
} else {
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$poll->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects);
}
$e_question = true;
$e_response = true;
$errors = array();
$v_question = $poll->getQuestion();
$v_description = $poll->getDescription();
$v_responses = $poll->getResponseVisibility();
$v_shuffle = $poll->getShuffle();
$v_space = $poll->getSpacePHID();
$responses = $request->getArr('response');
if ($request->isFormPost()) {
$v_question = $request->getStr('question');
$v_description = $request->getStr('description');
$v_responses = (int)$request->getInt('responses');
$v_shuffle = (int)$request->getBool('shuffle');
$v_view_policy = $request->getStr('viewPolicy');
$v_projects = $request->getArr('projects');
$v_space = $request->getStr('spacePHID');
if ($is_new) {
$poll->setMethod($request->getInt('method'));
}
if (!strlen($v_question)) {
$e_question = pht('Required');
$errors[] = pht('You must ask a poll question.');
} else {
$e_question = null;
}
if ($is_new) {
$responses = array_filter($responses);
if (empty($responses)) {
$errors[] = pht('You must offer at least one response.');
$e_response = pht('Required');
} else {
$e_response = null;
}
}
$xactions = array();
$template = id(new PhabricatorSlowvoteTransaction());
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorSlowvoteTransaction::TYPE_QUESTION)
->setNewValue($v_question);
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION)
->setNewValue($v_description);
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorSlowvoteTransaction::TYPE_RESPONSES)
->setNewValue($v_responses);
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorSlowvoteTransaction::TYPE_SHUFFLE)
->setNewValue($v_shuffle);
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($v_view_policy);
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
->setNewValue($v_space);
if (empty($errors)) {
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorSlowvoteTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $proj_edge_type)
->setNewValue(array('=' => array_fuse($v_projects)));
$editor = id(new PhabricatorSlowvoteEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request);
$xactions = $editor->applyTransactions($poll, $xactions);
if ($is_new) {
$poll->save();
foreach ($responses as $response) {
$option = new PhabricatorSlowvoteOption();
$option->setName($response);
$option->setPollID($poll->getID());
$option->save();
}
}
return id(new AphrontRedirectResponse())
->setURI('/V'.$poll->getID());
} else {
$poll->setViewPolicy($v_view_policy);
}
}
$instructions =
phutil_tag(
'p',
array(
'class' => 'aphront-form-instructions',
),
pht('Resolve issues and build consensus through '.
'protracted deliberation.'));
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendChild($instructions)
->appendChild(
id(new AphrontFormTextAreaControl())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
->setLabel(pht('Question'))
->setName('question')
->setValue($v_question)
->setError($e_question))
->appendChild(
id(new PhabricatorRemarkupControl())
- ->setUser($user)
+ ->setUser($viewer)
->setLabel(pht('Description'))
->setName('description')
->setValue($v_description))
->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
->setName('projects')
->setValue($v_projects)
->setDatasource(new PhabricatorProjectDatasource()));
if ($is_new) {
for ($ii = 0; $ii < 10; $ii++) {
$n = ($ii + 1);
$response = id(new AphrontFormTextControl())
->setLabel(pht('Response %d', $n))
->setName('response[]')
->setValue(idx($responses, $ii, ''));
if ($ii == 0) {
$response->setError($e_response);
}
$form->appendChild($response);
}
}
$poll_type_options = array(
PhabricatorSlowvotePoll::METHOD_PLURALITY =>
pht('Plurality (Single Choice)'),
PhabricatorSlowvotePoll::METHOD_APPROVAL =>
pht('Approval (Multiple Choice)'),
);
$response_type_options = array(
PhabricatorSlowvotePoll::RESPONSES_VISIBLE
=> pht('Allow anyone to see the responses'),
PhabricatorSlowvotePoll::RESPONSES_VOTERS
=> pht('Require a vote to see the responses'),
PhabricatorSlowvotePoll::RESPONSES_OWNER
=> pht('Only I can see the responses'),
);
if ($is_new) {
$form->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Vote Type'))
->setName('method')
->setValue($poll->getMethod())
->setOptions($poll_type_options));
} else {
$form->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Vote Type'))
->setValue(idx($poll_type_options, $poll->getMethod())));
}
if ($is_new) {
$title = pht('Create Slowvote');
$button = pht('Create');
$cancel_uri = $this->getApplicationURI();
} else {
$title = pht('Edit %s', 'V'.$poll->getID());
$button = pht('Save Changes');
$cancel_uri = '/V'.$poll->getID();
}
$policies = id(new PhabricatorPolicyQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->setObject($poll)
->execute();
$form
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Responses'))
->setName('responses')
->setValue($v_responses)
->setOptions($response_type_options))
->appendChild(
id(new AphrontFormCheckboxControl())
->setLabel(pht('Shuffle'))
->addCheckbox(
'shuffle',
1,
pht('Show choices in random order.'),
$v_shuffle))
->appendChild(
id(new AphrontFormPolicyControl())
- ->setUser($user)
+ ->setUser($viewer)
->setName('viewPolicy')
->setPolicyObject($poll)
->setPolicies($policies)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setSpacePHID($v_space))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($button)
->addCancelButton($cancel_uri));
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addTextCrumb($title);
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$form_box,
),
array(
'title' => $title,
));
}
}
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
@@ -1,25 +1,21 @@
<?php
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());
return $this->delegateToController($controller);
}
}
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
@@ -1,160 +1,154 @@
<?php
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)
->executeOne();
if (!$poll) {
return new Aphront404Response();
}
$poll_view = id(new SlowvoteEmbedView())
->setHeadless(true)
- ->setUser($user)
+ ->setUser($viewer)
->setPoll($poll);
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())
->setContent(
array(
'pollID' => $poll->getID(),
'contentHTML' => $poll_view->render(),
));
}
$header_icon = $poll->getIsClosed() ? 'fa-ban' : 'fa-circle-o';
$header_name = $poll->getIsClosed() ? pht('Closed') : pht('Open');
$header_color = $poll->getIsClosed() ? 'dark' : 'bluegrey';
$header = id(new PHUIHeaderView())
->setHeader($poll->getQuestion())
- ->setUser($user)
+ ->setUser($viewer)
->setStatus($header_icon, $header_color, $header_name)
->setPolicyObject($poll);
$actions = $this->buildActionView($poll);
$properties = $this->buildPropertyView($poll, $actions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb('V'.$poll->getID());
$timeline = $this->buildTransactionTimeline(
$poll,
new PhabricatorSlowvoteTransactionQuery());
$add_comment = $this->buildCommentForm($poll);
$object_box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
return $this->buildApplicationPage(
array(
$crumbs,
$object_box,
$poll_view,
$timeline,
$add_comment,
),
array(
'title' => 'V'.$poll->getID().' '.$poll->getQuestion(),
'pageObjects' => array($poll->getPHID()),
));
}
private function buildActionView(PhabricatorSlowvotePoll $poll) {
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($poll);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$poll,
PhabricatorPolicyCapability::CAN_EDIT);
$is_closed = $poll->getIsClosed();
$close_poll_text = $is_closed ? pht('Reopen Poll') : pht('Close Poll');
$close_poll_icon = $is_closed ? 'fa-play-circle-o' : 'fa-ban';
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Poll'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI('edit/'.$poll->getID().'/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$view->addAction(
id(new PhabricatorActionView())
->setName($close_poll_text)
->setIcon($close_poll_icon)
->setHref($this->getApplicationURI('close/'.$poll->getID().'/'))
->setDisabled(!$can_edit)
->setWorkflow(true));
return $view;
}
private function buildPropertyView(
PhabricatorSlowvotePoll $poll,
PhabricatorActionListView $actions) {
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($poll)
->setActionList($actions);
$view->invokeWillRenderEvent();
if (strlen($poll->getDescription())) {
$view->addTextContent(
$output = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent(
$poll->getDescription()),
'default',
$viewer));
}
return $view;
}
private function buildCommentForm(PhabricatorSlowvotePoll $poll) {
$viewer = $this->getRequest()->getUser();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious
? pht('Add Comment')
: pht('Enter Deliberations');
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $poll->getPHID());
return id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($poll->getPHID())
->setDraft($draft)
->setHeaderText($add_comment_header)
->setAction($this->getApplicationURI('/comment/'.$poll->getID().'/'))
->setSubmitButtonName(pht('Add Comment'));
}
}
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
@@ -1,109 +1,103 @@
<?php
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();
if (!$poll) {
return new Aphront404Response();
}
if ($poll->getIsClosed()) {
return new Aphront400Response();
}
$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');
$votes = array_keys($old_votes);
$votes = array_fuse($votes, $votes);
if ($poll->getMethod() == PhabricatorSlowvotePoll::METHOD_PLURALITY) {
if (idx($votes, $vote, false)) {
$votes = array();
} else {
$votes = array($vote);
}
} else {
if (idx($votes, $vote, false)) {
unset($votes[$vote]);
} else {
$votes[$vote] = $vote;
}
}
- $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)
->setOptions($options)
->setViewerChoices($updated_choices);
return id(new AphrontAjaxResponse())
->setContent(array(
'pollID' => $poll->getID(),
'contentHTML' => $embed->render(),
));
}
if (!$request->isFormPost()) {
return id(new Aphront404Response());
}
$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());
}
foreach ($old_votes as $old_vote) {
if (!idx($votes, $old_vote->getOptionID(), false)) {
$old_vote->delete();
}
}
foreach ($votes as $vote) {
if (idx($old_votes, $vote, false)) {
continue;
}
id(new PhabricatorSlowvoteChoice())
- ->setAuthorPHID($user->getPHID())
+ ->setAuthorPHID($viewer->getPHID())
->setPollID($poll->getID())
->setOptionID($vote)
->save();
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 6:17 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140701
Default Alt Text
(24 KB)

Event Timeline