1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +01:00

Update Flag for handleRequest

Summary: Updates Flag app for handleRequest

Test Plan: Flag, Unflag, list flags, remove flag

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13757
This commit is contained in:
Chad Little 2015-07-29 17:00:31 -07:00
parent a66be3fa28
commit cdf03b0f7a
3 changed files with 17 additions and 32 deletions

View file

@ -2,22 +2,17 @@
final class PhabricatorFlagDeleteController extends PhabricatorFlagController { final class PhabricatorFlagDeleteController extends PhabricatorFlagController {
private $id;
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $request->getViewer();
} $id = $request->getURIData('id');
public function processRequest() { $flag = id(new PhabricatorFlag())->load($id);
$request = $this->getRequest();
$user = $request->getUser();
$flag = id(new PhabricatorFlag())->load($this->id);
if (!$flag) { if (!$flag) {
return new Aphront404Response(); return new Aphront404Response();
} }
if ($flag->getOwnerPHID() != $user->getPHID()) { if ($flag->getOwnerPHID() != $viewer->getPHID()) {
return new Aphront400Response(); return new Aphront400Response();
} }

View file

@ -2,19 +2,12 @@
final class PhabricatorFlagEditController extends PhabricatorFlagController { final class PhabricatorFlagEditController extends PhabricatorFlagController {
private $phid; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$phid = $request->getURIData('phid');
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$phid = $this->phid;
$handle = id(new PhabricatorHandleQuery()) $handle = id(new PhabricatorHandleQuery())
->setViewer($user) ->setViewer($viewer)
->withPHIDs(array($phid)) ->withPHIDs(array($phid))
->executeOne(); ->executeOne();
@ -22,14 +15,14 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController {
return new Aphront404Response(); return new Aphront404Response();
} }
$flag = PhabricatorFlagQuery::loadUserFlag($user, $phid); $flag = PhabricatorFlagQuery::loadUserFlag($viewer, $phid);
if (!$flag) { if (!$flag) {
$flag = new PhabricatorFlag(); $flag = new PhabricatorFlag();
$flag->setOwnerPHID($user->getPHID()); $flag->setOwnerPHID($viewer->getPHID());
$flag->setType($handle->getType()); $flag->setType($handle->getType());
$flag->setObjectPHID($handle->getPHID()); $flag->setObjectPHID($handle->getPHID());
$flag->setReasonPHID($user->getPHID()); $flag->setReasonPHID($viewer->getPHID());
} }
if ($request->isDialogFormPost()) { if ($request->isDialogFormPost()) {
@ -43,7 +36,7 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController {
$type_name = $handle->getTypeName(); $type_name = $handle->getTypeName();
$dialog = new AphrontDialogView(); $dialog = new AphrontDialogView();
$dialog->setUser($user); $dialog->setUser($viewer);
$dialog->setTitle(pht('Flag %s', $type_name)); $dialog->setTitle(pht('Flag %s', $type_name));

View file

@ -2,19 +2,16 @@
final class PhabricatorFlagListController extends PhabricatorFlagController { final class PhabricatorFlagListController extends PhabricatorFlagController {
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'); $viewer = $request->getViewer();
} $querykey = $request->getURIData('queryKey');
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($querykey)
->setSearchEngine(new PhabricatorFlagSearchEngine()) ->setSearchEngine(new PhabricatorFlagSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());