mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Add default policy to Files application
Summary: **WIP** This adds default capability to the Files application Test Plan: Set default to public, go to Files page, see public preset. Upload File. Doesn't work. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6564 Differential Revision: https://secure.phabricator.com/D10888
This commit is contained in:
parent
31c09b7d6a
commit
1a8d87699c
5 changed files with 38 additions and 2 deletions
|
@ -725,6 +725,7 @@ phutil_register_library_map(array(
|
||||||
'FileReplyHandler' => 'applications/files/mail/FileReplyHandler.php',
|
'FileReplyHandler' => 'applications/files/mail/FileReplyHandler.php',
|
||||||
'FileUploadConduitAPIMethod' => 'applications/files/conduit/FileUploadConduitAPIMethod.php',
|
'FileUploadConduitAPIMethod' => 'applications/files/conduit/FileUploadConduitAPIMethod.php',
|
||||||
'FileUploadHashConduitAPIMethod' => 'applications/files/conduit/FileUploadHashConduitAPIMethod.php',
|
'FileUploadHashConduitAPIMethod' => 'applications/files/conduit/FileUploadHashConduitAPIMethod.php',
|
||||||
|
'FilesDefaultViewCapability' => 'applications/files/capability/FilesDefaultViewCapability.php',
|
||||||
'FlagConduitAPIMethod' => 'applications/flag/conduit/FlagConduitAPIMethod.php',
|
'FlagConduitAPIMethod' => 'applications/flag/conduit/FlagConduitAPIMethod.php',
|
||||||
'FlagDeleteConduitAPIMethod' => 'applications/flag/conduit/FlagDeleteConduitAPIMethod.php',
|
'FlagDeleteConduitAPIMethod' => 'applications/flag/conduit/FlagDeleteConduitAPIMethod.php',
|
||||||
'FlagEditConduitAPIMethod' => 'applications/flag/conduit/FlagEditConduitAPIMethod.php',
|
'FlagEditConduitAPIMethod' => 'applications/flag/conduit/FlagEditConduitAPIMethod.php',
|
||||||
|
@ -3726,6 +3727,7 @@ phutil_register_library_map(array(
|
||||||
'FileReplyHandler' => 'PhabricatorMailReplyHandler',
|
'FileReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||||
'FileUploadConduitAPIMethod' => 'FileConduitAPIMethod',
|
'FileUploadConduitAPIMethod' => 'FileConduitAPIMethod',
|
||||||
'FileUploadHashConduitAPIMethod' => 'FileConduitAPIMethod',
|
'FileUploadHashConduitAPIMethod' => 'FileConduitAPIMethod',
|
||||||
|
'FilesDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||||
'FlagConduitAPIMethod' => 'ConduitAPIMethod',
|
'FlagConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'FlagDeleteConduitAPIMethod' => 'FlagConduitAPIMethod',
|
'FlagDeleteConduitAPIMethod' => 'FlagConduitAPIMethod',
|
||||||
'FlagEditConduitAPIMethod' => 'FlagConduitAPIMethod',
|
'FlagEditConduitAPIMethod' => 'FlagConduitAPIMethod',
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShortDescription() {
|
public function getShortDescription() {
|
||||||
return 'Store and Share Files';
|
return pht('Store and Share Files');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIconName() {
|
public function getIconName() {
|
||||||
|
@ -40,6 +40,15 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getCustomCapabilities() {
|
||||||
|
return array(
|
||||||
|
FilesDefaultViewCapability::CAPABILITY => array(
|
||||||
|
'caption' => pht(
|
||||||
|
'Default view policy for newly created files.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
'/F(?P<id>[1-9]\d*)' => 'PhabricatorFileInfoController',
|
'/F(?P<id>[1-9]\d*)' => 'PhabricatorFileInfoController',
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class FilesDefaultViewCapability
|
||||||
|
extends PhabricatorPolicyCapability {
|
||||||
|
|
||||||
|
const CAPABILITY = 'files.default.view';
|
||||||
|
|
||||||
|
public function getCapabilityName() {
|
||||||
|
return pht('Default View Policy');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowPublicPolicySetting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ final class PhabricatorFileUploadController extends PhabricatorFileController {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$viewer = $request->getUser();
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
$file = new PhabricatorFile();
|
$file = PhabricatorFile::initializeNewFile();
|
||||||
|
|
||||||
$e_file = true;
|
$e_file = true;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
|
@ -53,7 +53,16 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
private $originalFile = self::ATTACHABLE;
|
private $originalFile = self::ATTACHABLE;
|
||||||
|
|
||||||
public static function initializeNewFile() {
|
public static function initializeNewFile() {
|
||||||
|
$app = id(new PhabricatorApplicationQuery())
|
||||||
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||||
|
->withClasses(array('PhabricatorFilesApplication'))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
$view_policy = $app->getPolicy(
|
||||||
|
FilesDefaultViewCapability::CAPABILITY);
|
||||||
|
|
||||||
return id(new PhabricatorFile())
|
return id(new PhabricatorFile())
|
||||||
|
->setViewPolicy($view_policy)
|
||||||
->attachOriginalFile(null)
|
->attachOriginalFile(null)
|
||||||
->attachObjects(array())
|
->attachObjects(array())
|
||||||
->attachObjectPHIDs(array());
|
->attachObjectPHIDs(array());
|
||||||
|
|
Loading…
Reference in a new issue