Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14041486
D10888.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10888.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -725,6 +725,7 @@
'FileReplyHandler' => 'applications/files/mail/FileReplyHandler.php',
'FileUploadConduitAPIMethod' => 'applications/files/conduit/FileUploadConduitAPIMethod.php',
'FileUploadHashConduitAPIMethod' => 'applications/files/conduit/FileUploadHashConduitAPIMethod.php',
+ 'FilesDefaultViewCapability' => 'applications/files/capability/FilesDefaultViewCapability.php',
'FlagConduitAPIMethod' => 'applications/flag/conduit/FlagConduitAPIMethod.php',
'FlagDeleteConduitAPIMethod' => 'applications/flag/conduit/FlagDeleteConduitAPIMethod.php',
'FlagEditConduitAPIMethod' => 'applications/flag/conduit/FlagEditConduitAPIMethod.php',
@@ -3726,6 +3727,7 @@
'FileReplyHandler' => 'PhabricatorMailReplyHandler',
'FileUploadConduitAPIMethod' => 'FileConduitAPIMethod',
'FileUploadHashConduitAPIMethod' => 'FileConduitAPIMethod',
+ 'FilesDefaultViewCapability' => 'PhabricatorPolicyCapability',
'FlagConduitAPIMethod' => 'ConduitAPIMethod',
'FlagDeleteConduitAPIMethod' => 'FlagConduitAPIMethod',
'FlagEditConduitAPIMethod' => 'FlagConduitAPIMethod',
diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php
--- a/src/applications/files/application/PhabricatorFilesApplication.php
+++ b/src/applications/files/application/PhabricatorFilesApplication.php
@@ -11,7 +11,7 @@
}
public function getShortDescription() {
- return 'Store and Share Files';
+ return pht('Store and Share Files');
}
public function getIconName() {
@@ -40,6 +40,15 @@
);
}
+ protected function getCustomCapabilities() {
+ return array(
+ FilesDefaultViewCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default view policy for newly created files.'),
+ ),
+ );
+ }
+
public function getRoutes() {
return array(
'/F(?P<id>[1-9]\d*)' => 'PhabricatorFileInfoController',
diff --git a/src/applications/files/capability/FilesDefaultViewCapability.php b/src/applications/files/capability/FilesDefaultViewCapability.php
new file mode 100644
--- /dev/null
+++ b/src/applications/files/capability/FilesDefaultViewCapability.php
@@ -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;
+ }
+
+}
diff --git a/src/applications/files/controller/PhabricatorFileUploadController.php b/src/applications/files/controller/PhabricatorFileUploadController.php
--- a/src/applications/files/controller/PhabricatorFileUploadController.php
+++ b/src/applications/files/controller/PhabricatorFileUploadController.php
@@ -6,7 +6,7 @@
$request = $this->getRequest();
$viewer = $request->getUser();
- $file = new PhabricatorFile();
+ $file = PhabricatorFile::initializeNewFile();
$e_file = true;
$errors = array();
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -53,7 +53,16 @@
private $originalFile = self::ATTACHABLE;
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())
+ ->setViewPolicy($view_policy)
->attachOriginalFile(null)
->attachObjects(array())
->attachObjectPHIDs(array());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 12, 7:03 PM (6 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6710684
Default Alt Text
D10888.diff (3 KB)
Attached To
Mode
D10888: Add default policy to Files application
Attached
Detach File
Event Timeline
Log In to Comment