1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Files - make file info page public

Summary: and for bonus, finesse some URIs a tad. Fixes T5922.

Test Plan: viewed F1 logged out and it worked! viewed the ugly URI for F1 and got redirected to the pretty URI.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5922

Differential Revision: https://secure.phabricator.com/D10309
This commit is contained in:
Bob Trahan 2014-08-20 13:18:21 -07:00
parent 20d6c7a048
commit 8dd4d5cfe5
5 changed files with 21 additions and 31 deletions

View file

@ -1557,7 +1557,6 @@ phutil_register_library_map(array(
'PhabricatorFileListController' => 'applications/files/controller/PhabricatorFileListController.php',
'PhabricatorFileQuery' => 'applications/files/query/PhabricatorFileQuery.php',
'PhabricatorFileSearchEngine' => 'applications/files/query/PhabricatorFileSearchEngine.php',
'PhabricatorFileShortcutController' => 'applications/files/controller/PhabricatorFileShortcutController.php',
'PhabricatorFileStorageBlob' => 'applications/files/storage/PhabricatorFileStorageBlob.php',
'PhabricatorFileStorageConfigurationException' => 'applications/files/exception/PhabricatorFileStorageConfigurationException.php',
'PhabricatorFileStorageEngine' => 'applications/files/engine/PhabricatorFileStorageEngine.php',
@ -4406,7 +4405,6 @@ phutil_register_library_map(array(
'PhabricatorFileListController' => 'PhabricatorFileController',
'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorFileSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorFileShortcutController' => 'PhabricatorFileController',
'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO',
'PhabricatorFileStorageConfigurationException' => 'Exception',
'PhabricatorFileTemporaryGarbageCollector' => 'PhabricatorGarbageCollector',

View file

@ -42,7 +42,7 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
public function getRoutes() {
return array(
'/F(?P<id>[1-9]\d*)' => 'PhabricatorFileShortcutController',
'/F(?P<id>[1-9]\d*)' => 'PhabricatorFileInfoController',
'/file/' => array(
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorFileListController',
'upload/' => 'PhabricatorFileUploadController',

View file

@ -3,15 +3,22 @@
final class PhabricatorFileInfoController extends PhabricatorFileController {
private $phid;
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
$this->phid = idx($data, 'phid');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($this->phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($user)
->withPHIDs(array($this->phid))
@ -20,6 +27,15 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
if (!$file) {
return new Aphront404Response();
}
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
}
$file = id(new PhabricatorFileQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$file) {
return new Aphront404Response();
}
$phid = $file->getPHID();
$xactions = id(new PhabricatorFileTransactionQuery())

View file

@ -1,24 +0,0 @@
<?php
final class PhabricatorFileShortcutController
extends PhabricatorFileController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$file = id(new PhabricatorFileQuery())
->setViewer($this->getRequest()->getUser())
->withIDs(array($this->id))
->executeOne();
if (!$file) {
return new Aphront404Response();
}
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
}
}

View file

@ -495,7 +495,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
}
public function getInfoURI() {
return '/file/info/'.$this->getPHID().'/';
return '/'.$this->getMonogram();
}
public function getBestURI() {