mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
44f18cfb12
Summary: Updates Projects to use handleRequest Test Plan: New Project, Edit Project, Archive, Watch, Create Workboards, Import Workboards, Edit Column, New Column, Change Icon, Add/Remove Members Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D13829
76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorProjectMembersRemoveController
|
|
extends PhabricatorProjectController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $request->getViewer();
|
|
$id = $request->getURIData('id');
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($id))
|
|
->needMembers(true)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$project) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$member_phids = $project->getMemberPHIDs();
|
|
$remove_phid = $request->getStr('phid');
|
|
|
|
if (!in_array($remove_phid, $member_phids)) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$members_uri = $this->getApplicationURI('members/'.$project->getID().'/');
|
|
|
|
if ($request->isFormPost()) {
|
|
$member_spec = array();
|
|
$member_spec['-'] = array($remove_phid => $remove_phid);
|
|
|
|
$type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
|
->setMetadataValue('edge:type', $type_member)
|
|
->setNewValue($member_spec);
|
|
|
|
$editor = id(new PhabricatorProjectTransactionEditor($project))
|
|
->setActor($viewer)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect(true)
|
|
->setContinueOnMissingFields(true)
|
|
->applyTransactions($project, $xactions);
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI($members_uri);
|
|
}
|
|
|
|
$handle = id(new PhabricatorHandleQuery())
|
|
->setViewer($viewer)
|
|
->withPHIDs(array($remove_phid))
|
|
->executeOne();
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($viewer)
|
|
->setTitle(pht('Really Remove Member?'))
|
|
->appendParagraph(
|
|
pht(
|
|
'Really remove %s from the project %s?',
|
|
phutil_tag('strong', array(), $handle->getName()),
|
|
phutil_tag('strong', array(), $project->getName())))
|
|
->addCancelButton($members_uri)
|
|
->addSubmitButton(pht('Remove Project Member'));
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|