1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +01:00

Update Tokens for handleRequest

Summary: Update callsites

Test Plan: View tokens leaders and givens. Gave a new token to a task.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13678
This commit is contained in:
Chad Little 2015-07-22 13:30:13 -07:00
parent 0bbcd3888c
commit 44d5dff832
3 changed files with 23 additions and 31 deletions

View file

@ -2,27 +2,21 @@
final class PhabricatorTokenGiveController extends PhabricatorTokenController {
private $phid;
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$phid = $request->getURIData('phid');
$handle = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs(array($this->phid))
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
if (!$handle->isComplete()) {
return new Aphront404Response();
}
$current = id(new PhabricatorTokenGivenQuery())
->setViewer($user)
->withAuthorPHIDs(array($user->getPHID()))
->setViewer($viewer)
->withAuthorPHIDs(array($viewer->getPHID()))
->withObjectPHIDs(array($handle->getPHID()))
->execute();
@ -39,7 +33,7 @@ final class PhabricatorTokenGiveController extends PhabricatorTokenController {
$content_source = PhabricatorContentSource::newFromRequest($request);
$editor = id(new PhabricatorTokenGivenEditor())
->setActor($user)
->setActor($viewer)
->setContentSource($content_source);
if ($is_give) {
$token_phid = $request->getStr('tokenPHID');
@ -57,17 +51,17 @@ final class PhabricatorTokenGiveController extends PhabricatorTokenController {
$dialog = $this->buildRescindTokenDialog(head($current));
}
$dialog->setUser($user);
$dialog->setUser($viewer);
$dialog->addCancelButton($done_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
private function buildGiveTokenDialog() {
$user = $this->getRequest()->getUser();
$viewer = $this->getViewer();
$tokens = id(new PhabricatorTokenQuery())
->setViewer($user)
->setViewer($viewer)
->execute();
$buttons = array();

View file

@ -6,24 +6,23 @@ final class PhabricatorTokenGivenController extends PhabricatorTokenController {
return true;
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$tokens_given = id(new PhabricatorTokenGivenQuery())
->setViewer($user)
->setViewer($viewer)
->executeWithCursorPager($pager);
$handles = array();
if ($tokens_given) {
$object_phids = mpull($tokens_given, 'getObjectPHID');
$user_phids = mpull($tokens_given, 'getAuthorPHID');
$handle_phids = array_merge($object_phids, $user_phids);
$viewer_phids = mpull($tokens_given, 'getAuthorPHID');
$handle_phids = array_merge($object_phids, $viewer_phids);
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs($handle_phids)
->execute();
}
@ -32,7 +31,7 @@ final class PhabricatorTokenGivenController extends PhabricatorTokenController {
if ($tokens_given) {
$token_phids = mpull($tokens_given, 'getTokenPHID');
$tokens = id(new PhabricatorTokenQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs($token_phids)
->execute();
$tokens = mpull($tokens, null, 'getPHID');
@ -53,7 +52,7 @@ final class PhabricatorTokenGivenController extends PhabricatorTokenController {
pht(
'Given by %s on %s',
$handles[$token_given->getAuthorPHID()]->renderLink(),
phabricator_date($token_given->getDateCreated(), $user)));
phabricator_date($token_given->getDateCreated(), $viewer)));
$list->addItem($item);
}

View file

@ -7,16 +7,15 @@ final class PhabricatorTokenLeaderController
return true;
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$pager = new PHUIPagerView();
$pager->setURI($request->getRequestURI(), 'page');
$pager->setOffset($request->getInt('page'));
$query = id(new PhabricatorTokenReceiverQuery());
$objects = $query->setViewer($user)->executeWithOffsetPager($pager);
$objects = $query->setViewer($viewer)->executeWithOffsetPager($pager);
$counts = $query->getTokenCounts();
$handles = array();
@ -24,7 +23,7 @@ final class PhabricatorTokenLeaderController
if ($counts) {
$phids = mpull($objects, 'getPHID');
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs($phids)
->execute();
}