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 {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$flag = id(new PhabricatorFlag())->load($this->id);
$flag = id(new PhabricatorFlag())->load($id);
if (!$flag) {
return new Aphront404Response();
}
if ($flag->getOwnerPHID() != $user->getPHID()) {
if ($flag->getOwnerPHID() != $viewer->getPHID()) {
return new Aphront400Response();
}

View file

@ -2,19 +2,12 @@
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())
->setViewer($user)
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
@ -22,14 +15,14 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController {
return new Aphront404Response();
}
$flag = PhabricatorFlagQuery::loadUserFlag($user, $phid);
$flag = PhabricatorFlagQuery::loadUserFlag($viewer, $phid);
if (!$flag) {
$flag = new PhabricatorFlag();
$flag->setOwnerPHID($user->getPHID());
$flag->setOwnerPHID($viewer->getPHID());
$flag->setType($handle->getType());
$flag->setObjectPHID($handle->getPHID());
$flag->setReasonPHID($user->getPHID());
$flag->setReasonPHID($viewer->getPHID());
}
if ($request->isDialogFormPost()) {
@ -43,7 +36,7 @@ final class PhabricatorFlagEditController extends PhabricatorFlagController {
$type_name = $handle->getTypeName();
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setUser($viewer);
$dialog->setTitle(pht('Flag %s', $type_name));

View file

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