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 {
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$phid = $request->getStr('filePHID');
$replaces_phid = $request->getStr('replacesPHID');

View file

@ -2,18 +2,12 @@
final class PholioInlineController extends PholioController {
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();
$viewer = $request->getUser();
if ($this->id) {
$inline = id(new PholioTransactionComment())->load($this->id);
if ($id) {
$inline = id(new PholioTransactionComment())->load($id);
if (!$inline) {
return new Aphront404Response();

View file

@ -2,19 +2,13 @@
final class PholioInlineListController extends PholioController {
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');
$image = id(new PholioImageQuery())
->setViewer($user)
->withIDs(array($this->id))
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$image) {
return new Aphront404Response();
@ -23,8 +17,8 @@ final class PholioInlineListController extends PholioController {
$inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'imageid = %d AND (transactionphid IS NOT NULL
OR (authorphid = %s AND transactionphid IS NULL))',
$this->id,
$user->getPHID());
$id,
$viewer->getPHID());
$author_phids = mpull($inline_comments, 'getAuthorPHID');
$authors = $this->loadViewerHandles($author_phids);

View file

@ -2,23 +2,17 @@
final class PholioMockCommentController extends PholioController {
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();
}
$mock = id(new PholioMockQuery())
->setViewer($user)
->withIDs(array($this->id))
->setViewer($viewer)
->withIDs(array($id))
->needImages(true)
->executeOne();
@ -38,7 +32,7 @@ final class PholioMockCommentController extends PholioController {
$inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)',
$user->getPHID(),
$viewer->getPHID(),
mpull($mock->getImages(), 'getID'));
if (!$inline_comments || strlen($comment)) {
@ -56,7 +50,7 @@ final class PholioMockCommentController extends PholioController {
}
$editor = id(new PholioMockEditor())
->setActor($user)
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect($request->isContinueRequest())
->setIsPreview($is_preview);
@ -78,7 +72,7 @@ final class PholioMockCommentController extends PholioController {
->setMock($mock);
return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user)
->setViewer($viewer)
->setTransactions($xactions)
->setTransactionView($xaction_view)
->setIsPreview($is_preview);

View file

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

View file

@ -2,19 +2,15 @@
final class PholioMockListController extends PholioController {
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 PholioMockSearchEngine())
->setNavigation($this->buildSideNavView());

View file

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