1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 21:32:43 +01:00

Update Pholio for handleRequest

Summary: Run through and update Pholio

Test Plan: New Mock, Edit Mock, Inline Comment, Normal Comment, replace mock, view lists.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13774
This commit is contained in:
Chad Little 2015-08-01 15:39:29 -07:00
parent deb20d6dae
commit e5bf2ac373
7 changed files with 67 additions and 102 deletions

View file

@ -2,9 +2,8 @@
final class PholioImageUploadController extends PholioController { final class PholioImageUploadController extends PholioController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest(); $viewer = $request->getViewer();
$viewer = $request->getUser();
$phid = $request->getStr('filePHID'); $phid = $request->getStr('filePHID');
$replaces_phid = $request->getStr('replacesPHID'); $replaces_phid = $request->getStr('replacesPHID');

View file

@ -2,18 +2,12 @@
final class PholioInlineController extends PholioController { final class PholioInlineController extends PholioController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) { if ($id) {
$this->id = idx($data, 'id'); $inline = id(new PholioTransactionComment())->load($id);
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if ($this->id) {
$inline = id(new PholioTransactionComment())->load($this->id);
if (!$inline) { if (!$inline) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -2,19 +2,13 @@
final class PholioInlineListController extends PholioController { final class PholioInlineListController extends PholioController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$image = id(new PholioImageQuery()) $image = id(new PholioImageQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$image) { if (!$image) {
return new Aphront404Response(); return new Aphront404Response();
@ -23,8 +17,8 @@ final class PholioInlineListController extends PholioController {
$inline_comments = id(new PholioTransactionComment())->loadAllWhere( $inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'imageid = %d AND (transactionphid IS NOT NULL 'imageid = %d AND (transactionphid IS NOT NULL
OR (authorphid = %s AND transactionphid IS NULL))', OR (authorphid = %s AND transactionphid IS NULL))',
$this->id, $id,
$user->getPHID()); $viewer->getPHID());
$author_phids = mpull($inline_comments, 'getAuthorPHID'); $author_phids = mpull($inline_comments, 'getAuthorPHID');
$authors = $this->loadViewerHandles($author_phids); $authors = $this->loadViewerHandles($author_phids);

View file

@ -2,23 +2,17 @@
final class PholioMockCommentController extends PholioController { final class PholioMockCommentController extends PholioController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if (!$request->isFormPost()) { if (!$request->isFormPost()) {
return new Aphront400Response(); return new Aphront400Response();
} }
$mock = id(new PholioMockQuery()) $mock = id(new PholioMockQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needImages(true) ->needImages(true)
->executeOne(); ->executeOne();
@ -38,7 +32,7 @@ final class PholioMockCommentController extends PholioController {
$inline_comments = id(new PholioTransactionComment())->loadAllWhere( $inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)', 'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)',
$user->getPHID(), $viewer->getPHID(),
mpull($mock->getImages(), 'getID')); mpull($mock->getImages(), 'getID'));
if (!$inline_comments || strlen($comment)) { if (!$inline_comments || strlen($comment)) {
@ -56,7 +50,7 @@ final class PholioMockCommentController extends PholioController {
} }
$editor = id(new PholioMockEditor()) $editor = id(new PholioMockEditor())
->setActor($user) ->setActor($viewer)
->setContentSourceFromRequest($request) ->setContentSourceFromRequest($request)
->setContinueOnNoEffect($request->isContinueRequest()) ->setContinueOnNoEffect($request->isContinueRequest())
->setIsPreview($is_preview); ->setIsPreview($is_preview);
@ -78,7 +72,7 @@ final class PholioMockCommentController extends PholioController {
->setMock($mock); ->setMock($mock);
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setTransactionView($xaction_view) ->setTransactionView($xaction_view)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -2,26 +2,20 @@
final class PholioMockEditController extends PholioController { final class PholioMockEditController extends PholioController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) { if ($id) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$mock = id(new PholioMockQuery()) $mock = id(new PholioMockQuery())
->setViewer($user) ->setViewer($viewer)
->needImages(true) ->needImages(true)
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_EDIT,
)) ))
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$mock) { if (!$mock) {
@ -35,7 +29,7 @@ final class PholioMockEditController extends PholioController {
$files = mpull($mock_images, 'getFile'); $files = mpull($mock_images, 'getFile');
$mock_images = mpull($mock_images, null, 'getFilePHID'); $mock_images = mpull($mock_images, null, 'getFilePHID');
} else { } else {
$mock = PholioMock::initializeNewMock($user); $mock = PholioMock::initializeNewMock($viewer);
$title = pht('Create Mock'); $title = pht('Create Mock');
@ -104,7 +98,7 @@ final class PholioMockEditController extends PholioController {
$file_phids = $request->getArr('file_phids'); $file_phids = $request->getArr('file_phids');
if ($file_phids) { if ($file_phids) {
$files = id(new PhabricatorFileQuery()) $files = id(new PhabricatorFileQuery())
->setViewer($user) ->setViewer($viewer)
->withPHIDs($file_phids) ->withPHIDs($file_phids)
->execute(); ->execute();
$files = mpull($files, null, 'getPHID'); $files = mpull($files, null, 'getPHID');
@ -219,7 +213,7 @@ final class PholioMockEditController extends PholioController {
$editor = id(new PholioMockEditor()) $editor = id(new PholioMockEditor())
->setContentSourceFromRequest($request) ->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true) ->setContinueOnNoEffect(true)
->setActor($user); ->setActor($viewer);
$xactions = $editor->applyTransactions($mock, $xactions); $xactions = $editor->applyTransactions($mock, $xactions);
@ -230,9 +224,9 @@ final class PholioMockEditController extends PholioController {
} }
} }
if ($this->id) { if ($id) {
$submit = id(new AphrontFormSubmitControl()) $submit = id(new AphrontFormSubmitControl())
->addCancelButton('/M'.$this->id) ->addCancelButton('/M'.$id)
->setValue(pht('Save')); ->setValue(pht('Save'));
} else { } else {
$submit = id(new AphrontFormSubmitControl()) $submit = id(new AphrontFormSubmitControl())
@ -241,7 +235,7 @@ final class PholioMockEditController extends PholioController {
} }
$policies = id(new PhabricatorPolicyQuery()) $policies = id(new PhabricatorPolicyQuery())
->setViewer($user) ->setViewer($viewer)
->setObject($mock) ->setObject($mock)
->execute(); ->execute();
@ -257,7 +251,7 @@ final class PholioMockEditController extends PholioController {
} }
foreach ($display_mock_images as $mock_image) { foreach ($display_mock_images as $mock_image) {
$image_elements[] = id(new PholioUploadedImageView()) $image_elements[] = id(new PholioUploadedImageView())
->setUser($user) ->setUser($viewer)
->setImage($mock_image) ->setImage($mock_image)
->setReplacesPHID($mock_image->getFilePHID()); ->setReplacesPHID($mock_image->getFilePHID());
} }
@ -308,7 +302,7 @@ final class PholioMockEditController extends PholioController {
require_celerity_resource('pholio-edit-css'); require_celerity_resource('pholio-edit-css');
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($viewer)
->appendChild($order_control) ->appendChild($order_control)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
@ -321,9 +315,9 @@ final class PholioMockEditController extends PholioController {
->setName('description') ->setName('description')
->setValue($v_desc) ->setValue($v_desc)
->setLabel(pht('Description')) ->setLabel(pht('Description'))
->setUser($user)); ->setUser($viewer));
if ($this->id) { if ($id) {
$form->appendChild( $form->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel(pht('Status')) ->setLabel(pht('Status'))
@ -346,11 +340,11 @@ final class PholioMockEditController extends PholioController {
->setLabel(pht('Subscribers')) ->setLabel(pht('Subscribers'))
->setName('cc') ->setName('cc')
->setValue($v_cc) ->setValue($v_cc)
->setUser($user) ->setUser($viewer)
->setDatasource(new PhabricatorMetaMTAMailableDatasource())) ->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
->appendChild( ->appendChild(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setUser($user) ->setUser($viewer)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW) ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicyObject($mock) ->setPolicyObject($mock)
->setPolicies($policies) ->setPolicies($policies)
@ -358,7 +352,7 @@ final class PholioMockEditController extends PholioController {
->setName('can_view')) ->setName('can_view'))
->appendChild( ->appendChild(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setUser($user) ->setUser($viewer)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicyObject($mock) ->setPolicyObject($mock)
->setPolicies($policies) ->setPolicies($policies)

View file

@ -2,19 +2,15 @@
final class PholioMockListController extends PholioController { final class PholioMockListController extends PholioController {
private $queryKey;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->queryKey = idx($data, 'queryKey'); $querykey = $request->getURIData('queryKey');
}
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($querykey)
->setSearchEngine(new PholioMockSearchEngine()) ->setSearchEngine(new PholioMockSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());

View file

@ -2,8 +2,6 @@
final class PholioMockViewController extends PholioController { final class PholioMockViewController extends PholioController {
private $id;
private $imageID;
private $maniphestTaskPHIDs = array(); private $maniphestTaskPHIDs = array();
private function setManiphestTaskPHIDs($maniphest_task_phids) { private function setManiphestTaskPHIDs($maniphest_task_phids) {
@ -18,18 +16,14 @@ final class PholioMockViewController extends PholioController {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $request->getViewer();
$this->imageID = idx($data, 'imageID'); $id = $request->getURIData('id');
} $image_id = $request->getURIData('imageID');
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$mock = id(new PholioMockQuery()) $mock = id(new PholioMockQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needImages(true) ->needImages(true)
->needInlineComments(true) ->needInlineComments(true)
->executeOne(); ->executeOne();
@ -44,7 +38,7 @@ final class PholioMockViewController extends PholioController {
$this->setManiphestTaskPHIDs($phids); $this->setManiphestTaskPHIDs($phids);
$engine = id(new PhabricatorMarkupEngine()) $engine = id(new PhabricatorMarkupEngine())
->setViewer($user); ->setViewer($viewer);
$engine->addObject($mock, PholioMock::MARKUP_FIELD_DESCRIPTION); $engine->addObject($mock, PholioMock::MARKUP_FIELD_DESCRIPTION);
$title = $mock->getName(); $title = $mock->getName();
@ -61,7 +55,7 @@ final class PholioMockViewController extends PholioController {
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader($title) ->setHeader($title)
->setUser($user) ->setUser($viewer)
->setStatus($header_icon, $header_color, $header_name) ->setStatus($header_icon, $header_color, $header_name)
->setPolicyObject($mock); ->setPolicyObject($mock);
@ -81,9 +75,9 @@ final class PholioMockViewController extends PholioController {
$mock_view = id(new PholioMockImagesView()) $mock_view = id(new PholioMockImagesView())
->setRequestURI($request->getRequestURI()) ->setRequestURI($request->getRequestURI())
->setCommentFormID($comment_form_id) ->setCommentFormID($comment_form_id)
->setUser($user) ->setUser($viewer)
->setMock($mock) ->setMock($mock)
->setImageID($this->imageID); ->setImageID($image_id);
$this->addExtraQuicksandConfig( $this->addExtraQuicksandConfig(
array('mockViewConfig' => $mock_view->getBehaviorConfig())); array('mockViewConfig' => $mock_view->getBehaviorConfig()));
@ -101,7 +95,7 @@ final class PholioMockViewController extends PholioController {
->addPropertyList($properties); ->addPropertyList($properties);
$thumb_grid = id(new PholioMockThumbGridView()) $thumb_grid = id(new PholioMockThumbGridView())
->setUser($user) ->setUser($viewer)
->setMock($mock); ->setMock($mock);
$content = array( $content = array(
@ -122,15 +116,15 @@ final class PholioMockViewController extends PholioController {
} }
private function buildActionView(PholioMock $mock) { private function buildActionView(PholioMock $mock) {
$user = $this->getRequest()->getUser(); $viewer = $this->getViewer();
$actions = id(new PhabricatorActionListView()) $actions = id(new PhabricatorActionListView())
->setUser($user) ->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI()) ->setObjectURI($this->getRequest()->getRequestURI())
->setObject($mock); ->setObject($mock);
$can_edit = PhabricatorPolicyFilter::hasCapability( $can_edit = PhabricatorPolicyFilter::hasCapability(
$user, $viewer,
$mock, $mock,
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
@ -147,7 +141,7 @@ final class PholioMockViewController extends PholioController {
->setIcon('fa-anchor') ->setIcon('fa-anchor')
->setName(pht('Edit Maniphest Tasks')) ->setName(pht('Edit Maniphest Tasks'))
->setHref("/search/attach/{$mock->getPHID()}/TASK/edge/") ->setHref("/search/attach/{$mock->getPHID()}/TASK/edge/")
->setDisabled(!$user->isLoggedIn()) ->setDisabled(!$viewer->isLoggedIn())
->setWorkflow(true)); ->setWorkflow(true));
return $actions; return $actions;
@ -158,25 +152,25 @@ final class PholioMockViewController extends PholioController {
PhabricatorMarkupEngine $engine, PhabricatorMarkupEngine $engine,
PhabricatorActionListView $actions) { PhabricatorActionListView $actions) {
$user = $this->getRequest()->getUser(); $viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView()) $properties = id(new PHUIPropertyListView())
->setUser($user) ->setUser($viewer)
->setObject($mock) ->setObject($mock)
->setActionList($actions); ->setActionList($actions);
$properties->addProperty( $properties->addProperty(
pht('Author'), pht('Author'),
$user->renderHandle($mock->getAuthorPHID())); $viewer->renderHandle($mock->getAuthorPHID()));
$properties->addProperty( $properties->addProperty(
pht('Created'), pht('Created'),
phabricator_datetime($mock->getDateCreated(), $user)); phabricator_datetime($mock->getDateCreated(), $viewer));
if ($this->getManiphestTaskPHIDs()) { if ($this->getManiphestTaskPHIDs()) {
$properties->addProperty( $properties->addProperty(
pht('Maniphest Tasks'), pht('Maniphest Tasks'),
$user->renderHandleList($this->getManiphestTaskPHIDs())); $viewer->renderHandleList($this->getManiphestTaskPHIDs()));
} }
$properties->invokeWillRenderEvent(); $properties->invokeWillRenderEvent();
@ -192,9 +186,9 @@ final class PholioMockViewController extends PholioController {
} }
private function buildAddCommentView(PholioMock $mock, $comment_form_id) { private function buildAddCommentView(PholioMock $mock, $comment_form_id) {
$user = $this->getRequest()->getUser(); $viewer = $this->getViewer();
$draft = PhabricatorDraft::newFromUserAndKey($user, $mock->getPHID()); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $mock->getPHID());
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$title = $is_serious $title = $is_serious
@ -202,7 +196,7 @@ final class PholioMockViewController extends PholioController {
: pht('History Beckons'); : pht('History Beckons');
$form = id(new PhabricatorApplicationTransactionCommentView()) $form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($user) ->setUser($viewer)
->setObjectPHID($mock->getPHID()) ->setObjectPHID($mock->getPHID())
->setFormID($comment_form_id) ->setFormID($comment_form_id)
->setDraft($draft) ->setDraft($draft)