[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorFileDeleteController extends PhabricatorFileController { 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 $file = id(new PhabricatorFileQuery()) 16 ->setViewer($user) 17 ->withIDs(array($this->id)) 18 ->requireCapabilities( 19 array( 20 PhabricatorPolicyCapability::CAN_VIEW, 21 PhabricatorPolicyCapability::CAN_EDIT, 22 )) 23 ->executeOne(); 24 if (!$file) { 25 return new Aphront404Response(); 26 } 27 28 if (($user->getPHID() != $file->getAuthorPHID()) && 29 (!$user->getIsAdmin())) { 30 return new Aphront403Response(); 31 } 32 33 if ($request->isFormPost()) { 34 $file->delete(); 35 return id(new AphrontRedirectResponse())->setURI('/file/'); 36 } 37 38 $dialog = new AphrontDialogView(); 39 $dialog->setUser($user); 40 $dialog->setTitle('Really delete file?'); 41 $dialog->appendChild(hsprintf( 42 "<p>Permanently delete '%s'? This action can not be undone.</p>", 43 $file->getName())); 44 $dialog->addSubmitButton('Delete'); 45 $dialog->addCancelButton($file->getInfoURI()); 46 47 return id(new AphrontDialogResponse())->setDialog($dialog); 48 } 49 }
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 |