@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow users to set an explicit visibility for manual file uploads at creation time

Summary: Ref T4589. Depends on D10129. In addition to letting users change the visibility policy for files, also allow them to choose a policy explicitly when a file is uploaded.

Test Plan: Uploaded several files using the plain old uploader, saw appropriate visibility policies applied.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4589

Differential Revision: https://secure.phabricator.com/D10130

+24 -6
+24 -6
src/applications/files/controller/PhabricatorFileUploadController.php
··· 4 4 5 5 public function processRequest() { 6 6 $request = $this->getRequest(); 7 - $user = $request->getUser(); 7 + $viewer = $request->getUser(); 8 + 9 + $file = new PhabricatorFile(); 8 10 9 11 $e_file = true; 10 12 $errors = array(); 11 13 if ($request->isFormPost()) { 14 + $view_policy = $request->getStr('viewPolicy'); 15 + 12 16 if (!$request->getFileExists('file')) { 13 17 $e_file = pht('Required'); 14 18 $errors[] = pht('You must select a file to upload.'); ··· 17 21 idx($_FILES, 'file'), 18 22 array( 19 23 'name' => $request->getStr('name'), 20 - 'authorPHID' => $user->getPHID(), 24 + 'authorPHID' => $viewer->getPHID(), 25 + 'viewPolicy' => $view_policy, 21 26 'isExplicitUpload' => true, 22 27 )); 23 28 } ··· 25 30 if (!$errors) { 26 31 return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); 27 32 } 33 + 34 + $file->setViewPolicy($view_policy); 28 35 } 29 36 30 37 $support_id = celerity_generate_unique_node_id(); ··· 38 45 'You can also upload files by dragging and dropping them from your '. 39 46 'desktop onto this page or the Phabricator home page.'))); 40 47 48 + $policies = id(new PhabricatorPolicyQuery()) 49 + ->setViewer($viewer) 50 + ->setObject($file) 51 + ->execute(); 52 + 41 53 $form = id(new AphrontFormView()) 42 - ->setUser($user) 54 + ->setUser($viewer) 43 55 ->setEncType('multipart/form-data') 44 56 ->appendChild( 45 57 id(new AphrontFormFileControl()) ··· 51 63 id(new AphrontFormTextControl()) 52 64 ->setLabel(pht('Name')) 53 65 ->setName('name') 54 - ->setValue($request->getStr('name')) 55 - ->setCaption(pht('Optional file display name.'))) 66 + ->setValue($request->getStr('name'))) 67 + ->appendChild( 68 + id(new AphrontFormPolicyControl()) 69 + ->setUser($viewer) 70 + ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) 71 + ->setPolicyObject($file) 72 + ->setPolicies($policies) 73 + ->setName('viewPolicy')) 56 74 ->appendChild( 57 75 id(new AphrontFormSubmitControl()) 58 76 ->setValue(pht('Upload')) ··· 65 83 $title = pht('Upload File'); 66 84 67 85 $global_upload = id(new PhabricatorGlobalUploadTargetView()) 68 - ->setUser($user) 86 + ->setUser($viewer) 69 87 ->setShowIfSupportedID($support_id); 70 88 71 89 $form_box = id(new PHUIObjectBoxView())