Update Files for handleRequest
Summary: Update Files application Test Plan: Upload a file, edit a file, view details, transforms, delete file Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13735
This commit is contained in:
@@ -2,23 +2,17 @@
|
|||||||
|
|
||||||
final class PhabricatorFileCommentController extends PhabricatorFileController {
|
final class PhabricatorFileCommentController extends PhabricatorFileController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = idx($data, 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
if (!$request->isFormPost()) {
|
if (!$request->isFormPost()) {
|
||||||
return new Aphront400Response();
|
return new Aphront400Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
@@ -37,7 +31,7 @@ final class PhabricatorFileCommentController extends PhabricatorFileController {
|
|||||||
->setContent($request->getStr('comment')));
|
->setContent($request->getStr('comment')));
|
||||||
|
|
||||||
$editor = id(new PhabricatorFileEditor())
|
$editor = id(new PhabricatorFileEditor())
|
||||||
->setActor($user)
|
->setActor($viewer)
|
||||||
->setContinueOnNoEffect($request->isContinueRequest())
|
->setContinueOnNoEffect($request->isContinueRequest())
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
->setIsPreview($is_preview);
|
->setIsPreview($is_preview);
|
||||||
@@ -56,7 +50,7 @@ final class PhabricatorFileCommentController extends PhabricatorFileController {
|
|||||||
|
|
||||||
if ($request->isAjax() && $is_preview) {
|
if ($request->isAjax() && $is_preview) {
|
||||||
return id(new PhabricatorApplicationTransactionResponse())
|
return id(new PhabricatorApplicationTransactionResponse())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->setTransactions($xactions)
|
->setTransactions($xactions)
|
||||||
->setIsPreview($is_preview);
|
->setIsPreview($is_preview);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
final class PhabricatorFileComposeController
|
final class PhabricatorFileComposeController
|
||||||
extends PhabricatorFileController {
|
extends PhabricatorFileController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $request->getViewer();
|
||||||
$viewer = $request->getUser();
|
|
||||||
|
|
||||||
$colors = array(
|
$colors = array(
|
||||||
'red' => pht('Verbillion'),
|
'red' => pht('Verbillion'),
|
||||||
|
|||||||
@@ -7,19 +7,15 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
|||||||
private $token;
|
private $token;
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
|
||||||
$this->phid = $data['phid'];
|
|
||||||
$this->key = $data['key'];
|
|
||||||
$this->token = idx($data, 'token');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldRequireLogin() {
|
public function shouldRequireLogin() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $request->getViewer();
|
||||||
$viewer = $this->getViewer();
|
$this->phid = $request->getURIData('phid');
|
||||||
|
$this->key = $request->getURIData('key');
|
||||||
|
$this->token = $request->getURIData('token');
|
||||||
|
|
||||||
$alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
|
$alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
|
||||||
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
||||||
|
|||||||
@@ -2,19 +2,13 @@
|
|||||||
|
|
||||||
final class PhabricatorFileDeleteController extends PhabricatorFileController {
|
final class PhabricatorFileDeleteController extends PhabricatorFileController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
@@ -25,8 +19,8 @@ final class PhabricatorFileDeleteController extends PhabricatorFileController {
|
|||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($user->getPHID() != $file->getAuthorPHID()) &&
|
if (($viewer->getPHID() != $file->getAuthorPHID()) &&
|
||||||
(!$user->getIsAdmin())) {
|
(!$viewer->getIsAdmin())) {
|
||||||
return new Aphront403Response();
|
return new Aphront403Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +30,7 @@ final class PhabricatorFileDeleteController extends PhabricatorFileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dialog = new AphrontDialogView();
|
$dialog = new AphrontDialogView();
|
||||||
$dialog->setUser($user);
|
$dialog->setUser($viewer);
|
||||||
$dialog->setTitle(pht('Really delete file?'));
|
$dialog->setTitle(pht('Really delete file?'));
|
||||||
$dialog->appendChild(hsprintf(
|
$dialog->appendChild(hsprintf(
|
||||||
'<p>%s</p>',
|
'<p>%s</p>',
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ final class PhabricatorFileDropUploadController
|
|||||||
/**
|
/**
|
||||||
* @phutil-external-symbol class PhabricatorStartup
|
* @phutil-external-symbol class PhabricatorStartup
|
||||||
*/
|
*/
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $request->getViewer();
|
||||||
$viewer = $request->getUser();
|
|
||||||
|
|
||||||
// NOTE: Throws if valid CSRF token is not present in the request.
|
// NOTE: Throws if valid CSRF token is not present in the request.
|
||||||
$request->validateCSRF();
|
$request->validateCSRF();
|
||||||
|
|||||||
@@ -2,19 +2,13 @@
|
|||||||
|
|
||||||
final class PhabricatorFileEditController extends PhabricatorFileController {
|
final class PhabricatorFileEditController extends PhabricatorFileController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
public function willProcessRequest(array $data) {
|
$id = $request->getURIData('id');
|
||||||
$this->id = $data['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$viewer = $request->getUser();
|
|
||||||
|
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
|||||||
@@ -2,26 +2,19 @@
|
|||||||
|
|
||||||
final class PhabricatorFileInfoController extends PhabricatorFileController {
|
final class PhabricatorFileInfoController extends PhabricatorFileController {
|
||||||
|
|
||||||
private $phid;
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
public function shouldAllowPublic() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$this->phid = idx($data, 'phid');
|
$viewer = $request->getViewer();
|
||||||
$this->id = idx($data, 'id');
|
$id = $request->getURIData('id');
|
||||||
}
|
$phid = $request->getURIData('phid');
|
||||||
|
|
||||||
public function processRequest() {
|
if ($phid) {
|
||||||
$request = $this->getRequest();
|
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
if ($this->phid) {
|
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($this->phid))
|
->withPHIDs(array($phid))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
@@ -30,8 +23,8 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
|
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
|
||||||
}
|
}
|
||||||
$file = id(new PhabricatorFileQuery())
|
$file = id(new PhabricatorFileQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
@@ -40,7 +33,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
$phid = $file->getPHID();
|
$phid = $file->getPHID();
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setPolicyObject($file)
|
->setPolicyObject($file)
|
||||||
->setHeader($file->getName());
|
->setHeader($file->getName());
|
||||||
|
|
||||||
@@ -87,7 +80,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildTransactionView(PhabricatorFile $file) {
|
private function buildTransactionView(PhabricatorFile $file) {
|
||||||
$user = $this->getRequest()->getUser();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$file,
|
$file,
|
||||||
@@ -99,10 +92,10 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
? pht('Add Comment')
|
? pht('Add Comment')
|
||||||
: pht('Question File Integrity');
|
: pht('Question File Integrity');
|
||||||
|
|
||||||
$draft = PhabricatorDraft::newFromUserAndKey($user, $file->getPHID());
|
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $file->getPHID());
|
||||||
|
|
||||||
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setObjectPHID($file->getPHID())
|
->setObjectPHID($file->getPHID())
|
||||||
->setDraft($draft)
|
->setDraft($draft)
|
||||||
->setHeaderText($add_comment_header)
|
->setHeaderText($add_comment_header)
|
||||||
@@ -116,8 +109,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(PhabricatorFile $file) {
|
private function buildActionView(PhabricatorFile $file) {
|
||||||
$request = $this->getRequest();
|
$viewer = $this->getViewer();
|
||||||
$viewer = $request->getUser();
|
|
||||||
|
|
||||||
$id = $file->getID();
|
$id = $file->getID();
|
||||||
|
|
||||||
@@ -184,7 +176,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
PhabricatorFile $file,
|
PhabricatorFile $file,
|
||||||
PhabricatorActionListView $actions) {
|
PhabricatorActionListView $actions) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
$properties = id(new PHUIPropertyListView());
|
$properties = id(new PHUIPropertyListView());
|
||||||
$properties->setActionList($actions);
|
$properties->setActionList($actions);
|
||||||
@@ -193,12 +185,12 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
if ($file->getAuthorPHID()) {
|
if ($file->getAuthorPHID()) {
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Author'),
|
pht('Author'),
|
||||||
$user->renderHandle($file->getAuthorPHID()));
|
$viewer->renderHandle($file->getAuthorPHID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Created'),
|
pht('Created'),
|
||||||
phabricator_datetime($file->getDateCreated(), $user));
|
phabricator_datetime($file->getDateCreated(), $viewer));
|
||||||
|
|
||||||
|
|
||||||
$finfo = id(new PHUIPropertyListView());
|
$finfo = id(new PHUIPropertyListView());
|
||||||
@@ -276,7 +268,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
|
|
||||||
$attached->addProperty(
|
$attached->addProperty(
|
||||||
pht('Attached To'),
|
pht('Attached To'),
|
||||||
$user->renderHandleList($phids));
|
$viewer->renderHandleList($phids));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($file->isViewableImage()) {
|
if ($file->isViewableImage()) {
|
||||||
@@ -330,7 +322,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
$box->addPropertyList($chunkinfo, pht('Chunks'));
|
$box->addPropertyList($chunkinfo, pht('Chunks'));
|
||||||
|
|
||||||
$chunks = id(new PhabricatorFileChunkQuery())
|
$chunks = id(new PhabricatorFileChunkQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withChunkHandles(array($file->getStorageHandle()))
|
->withChunkHandles(array($file->getStorageHandle()))
|
||||||
->execute();
|
->execute();
|
||||||
$chunks = msort($chunks, 'getByteStart');
|
$chunks = msort($chunks, 'getByteStart');
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
final class PhabricatorFileUploadDialogController
|
final class PhabricatorFileUploadDialogController
|
||||||
extends PhabricatorFileController {
|
extends PhabricatorFileController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $request->getViewer();
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
$dialog = id(new AphrontDialogView())
|
$dialog = id(new AphrontDialogView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setTitle(pht('Upload File'))
|
->setTitle(pht('Upload File'))
|
||||||
->appendChild(pht(
|
->appendChild(pht(
|
||||||
'To add files, drag and drop them into the comment text area.'))
|
'To add files, drag and drop them into the comment text area.'))
|
||||||
|
|||||||
Reference in New Issue
Block a user