[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PassphraseCredentialDestroyController 4 extends PassphraseController { 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 $credential = id(new PassphraseCredentialQuery()) 17 ->setViewer($viewer) 18 ->withIDs(array($this->id)) 19 ->requireCapabilities( 20 array( 21 PhabricatorPolicyCapability::CAN_VIEW, 22 PhabricatorPolicyCapability::CAN_EDIT, 23 )) 24 ->executeOne(); 25 if (!$credential) { 26 return new Aphront404Response(); 27 } 28 29 $type = PassphraseCredentialType::getTypeByConstant( 30 $credential->getCredentialType()); 31 if (!$type) { 32 throw new Exception(pht('Credential has invalid type "%s"!', $type)); 33 } 34 35 $view_uri = '/K'.$credential->getID(); 36 37 if ($request->isFormPost()) { 38 39 $xactions = array(); 40 $xactions[] = id(new PassphraseCredentialTransaction()) 41 ->setTransactionType(PassphraseCredentialTransaction::TYPE_DESTROY) 42 ->setNewValue(1); 43 44 $editor = id(new PassphraseCredentialTransactionEditor()) 45 ->setActor($viewer) 46 ->setContinueOnMissingFields(true) 47 ->setContentSourceFromRequest($request) 48 ->applyTransactions($credential, $xactions); 49 50 return id(new AphrontRedirectResponse())->setURI($view_uri); 51 } 52 53 return $this->newDialog() 54 ->setUser($viewer) 55 ->setTitle(pht('Really destroy credential?')) 56 ->appendChild( 57 pht( 58 'This credential will be deactivated and the secret will be '. 59 'unrecoverably destroyed. Anything relying on this credential '. 60 'will cease to function. This operation can not be undone.')) 61 ->addSubmitButton(pht('Destroy Credential')) 62 ->addCancelButton($view_uri); 63 } 64 65 }
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 |