[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorProjectMembersRemoveController 4 extends PhabricatorProjectController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 $project = id(new PhabricatorProjectQuery()) 17 ->setViewer($viewer) 18 ->withIDs(array($this->id)) 19 ->needMembers(true) 20 ->requireCapabilities( 21 array( 22 PhabricatorPolicyCapability::CAN_VIEW, 23 PhabricatorPolicyCapability::CAN_EDIT, 24 )) 25 ->executeOne(); 26 if (!$project) { 27 return new Aphront404Response(); 28 } 29 30 $member_phids = $project->getMemberPHIDs(); 31 $remove_phid = $request->getStr('phid'); 32 33 if (!in_array($remove_phid, $member_phids)) { 34 return new Aphront404Response(); 35 } 36 37 $members_uri = $this->getApplicationURI('members/'.$project->getID().'/'); 38 39 if ($request->isFormPost()) { 40 $member_spec = array(); 41 $member_spec['-'] = array($remove_phid => $remove_phid); 42 43 $type_member = PhabricatorEdgeConfig::TYPE_PROJ_MEMBER; 44 45 $xactions = array(); 46 47 $xactions[] = id(new PhabricatorProjectTransaction()) 48 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 49 ->setMetadataValue('edge:type', $type_member) 50 ->setNewValue($member_spec); 51 52 $editor = id(new PhabricatorProjectTransactionEditor($project)) 53 ->setActor($viewer) 54 ->setContentSourceFromRequest($request) 55 ->setContinueOnNoEffect(true) 56 ->setContinueOnMissingFields(true) 57 ->applyTransactions($project, $xactions); 58 59 return id(new AphrontRedirectResponse()) 60 ->setURI($members_uri); 61 } 62 63 $handle = id(new PhabricatorHandleQuery()) 64 ->setViewer($viewer) 65 ->withPHIDs(array($remove_phid)) 66 ->executeOne(); 67 68 $dialog = id(new AphrontDialogView()) 69 ->setUser($viewer) 70 ->setTitle(pht('Really Remove Member?')) 71 ->appendParagraph( 72 pht( 73 'Really remove %s from the project %s?', 74 phutil_tag('strong', array(), $handle->getName()), 75 phutil_tag('strong', array(), $project->getName()))) 76 ->addCancelButton($members_uri) 77 ->addSubmitButton(pht('Remove Project Member')); 78 79 return id(new AphrontDialogResponse())->setDialog($dialog); 80 } 81 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |