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