Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionDeleteController.php
<?php | <?php | ||||
/** | |||||
* @group phriction | |||||
*/ | |||||
final class PhrictionDeleteController extends PhrictionController { | final class PhrictionDeleteController extends PhrictionController { | ||||
private $id; | private $id; | ||||
public function willProcessRequest(array $data) { | public function willProcessRequest(array $data) { | ||||
$this->id = $data['id']; | $this->id = $data['id']; | ||||
} | } | ||||
public function processRequest() { | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$user = $request->getUser(); | $user = $request->getUser(); | ||||
$document = id(new PhrictionDocument())->load($this->id); | $document = id(new PhrictionDocumentQuery()) | ||||
->setViewer($user) | |||||
->withIDs(array($this->id)) | |||||
->requireCapabilities( | |||||
array( | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
)) | |||||
->executeOne(); | |||||
if (!$document) { | if (!$document) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$e_text = null; | $e_text = null; | ||||
$disallowed_states = array( | $disallowed_states = array( | ||||
PhrictionDocumentStatus::STATUS_DELETED => true, // Silly | PhrictionDocumentStatus::STATUS_DELETED => true, // Silly | ||||
PhrictionDocumentStatus::STATUS_MOVED => true, // Makes no sense | PhrictionDocumentStatus::STATUS_MOVED => true, // Makes no sense | ||||
Show All 36 Lines |