mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +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:
parent
20d6c7a048
commit
8dd4d5cfe5
5 changed files with 21 additions and 31 deletions
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -3,20 +3,36 @@
|
|||
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))
|
||||
->executeOne();
|
||||
|
||||
if (!$file) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
|
||||
}
|
||||
$file = id(new PhabricatorFileQuery())
|
||||
->setViewer($user)
|
||||
->withPHIDs(array($this->phid))
|
||||
->withIDs(array($this->id))
|
||||
->executeOne();
|
||||
|
||||
if (!$file) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
|
@ -495,7 +495,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
|||
}
|
||||
|
||||
public function getInfoURI() {
|
||||
return '/file/info/'.$this->getPHID().'/';
|
||||
return '/'.$this->getMonogram();
|
||||
}
|
||||
|
||||
public function getBestURI() {
|
||||
|
|
Loading…
Reference in a new issue