Page MenuHomePhabricator

D10130.id24357.diff
No OneTemporary

D10130.id24357.diff

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
@@ -4,7 +4,7 @@
public function processRequest() {
$request = $this->getRequest();
- $user = $request->getUser();
+ $viewer = $request->getUser();
$e_file = true;
$errors = array();
@@ -17,7 +17,8 @@
idx($_FILES, 'file'),
array(
'name' => $request->getStr('name'),
- 'authorPHID' => $user->getPHID(),
+ 'authorPHID' => $viewer->getPHID(),
+ 'viewPolicy' => $request->getStr('viewPolicy'),
'isExplicitUpload' => true,
));
}
@@ -27,6 +28,8 @@
}
}
+ $file = new PhabricatorFile();
+
$support_id = celerity_generate_unique_node_id();
$instructions = id(new AphrontFormMarkupControl())
->setControlID($support_id)
@@ -38,8 +41,13 @@
'You can also upload files by dragging and dropping them from your '.
'desktop onto this page or the Phabricator home page.')));
+ $policies = id(new PhabricatorPolicyQuery())
+ ->setViewer($viewer)
+ ->setObject($file)
+ ->execute();
+
$form = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
@@ -51,8 +59,14 @@
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
- ->setValue($request->getStr('name'))
- ->setCaption(pht('Optional file display name.')))
+ ->setValue($request->getStr('name')))
+ ->appendChild(
+ id(new AphrontFormPolicyControl())
+ ->setUser($viewer)
+ ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
+ ->setPolicyObject($file)
+ ->setPolicies($policies)
+ ->setName('viewPolicy'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Upload'))
@@ -65,7 +79,7 @@
$title = pht('Upload File');
$global_upload = id(new PhabricatorGlobalUploadTargetView())
- ->setUser($user)
+ ->setUser($viewer)
->setShowIfSupportedID($support_id);
$form_box = id(new PHUIObjectBoxView())

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 9, 8:04 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7737675
Default Alt Text
D10130.id24357.diff (2 KB)

Event Timeline