[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhamePostDeleteController extends PhameController { 4 5 private $id; 6 7 public function willProcessRequest(array $data) { 8 $this->id = $data['id']; 9 } 10 11 public function processRequest() { 12 $request = $this->getRequest(); 13 $user = $request->getUser(); 14 15 $post = id(new PhamePostQuery()) 16 ->setViewer($user) 17 ->withIDs(array($this->id)) 18 ->requireCapabilities( 19 array( 20 PhabricatorPolicyCapability::CAN_EDIT, 21 )) 22 ->executeOne(); 23 if (!$post) { 24 return new Aphront404Response(); 25 } 26 27 if ($request->isFormPost()) { 28 $post->delete(); 29 return id(new AphrontRedirectResponse()) 30 ->setURI('/phame/post/'); 31 } 32 33 $cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); 34 35 $dialog = id(new AphrontDialogView()) 36 ->setUser($user) 37 ->setTitle(pht('Delete Post?')) 38 ->appendChild( 39 pht( 40 'Really delete the post "%s"? It will be gone forever.', 41 $post->getTitle())) 42 ->addSubmitButton(pht('Delete')) 43 ->addCancelButton($cancel_uri); 44 45 return id(new AphrontDialogResponse())->setDialog($dialog); 46 } 47 48 }
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 |