Provide an attached-to-visible-object policy exception for files

Summary:
Ref T603. This uses the existing edges (from Conpherence) to record that a file is attached to an object, and uses those edges to create a policy exception: if you can view an attached object, you can view a file.

I'm going to combine this with restrictive defaults to satisfy the other half of the equation (that files you attach to a conpherence usually shouldn't be public by default).

Test Plan:
  - Loaded `/files/`.
  - Uploaded a file to a Conpherence, looked at it in Files, saw the attachment.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7182
This commit is contained in:
epriestley
2013-10-01 08:43:34 -07:00
parent fc57995330
commit 472be5e26e
3 changed files with 105 additions and 3 deletions

View File

@@ -27,7 +27,11 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
->withObjectPHIDs(array($phid))
->execute();
$this->loadHandles(array($file->getAuthorPHID()));
$handle_phids = array_merge(
array($file->getAuthorPHID()),
$file->getObjectPHIDs());
$this->loadHandles($handle_phids);
$header = id(new PHUIHeaderView())
->setHeader($file->getName());
@@ -207,6 +211,15 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
}
}
$phids = $file->getObjectPHIDs();
if ($phids) {
$view->addSectionHeader(pht('Attached'));
$view->addProperty(
pht('Attached To'),
$this->renderHandlesForPHIDs($phids));
}
if ($file->isViewableImage()) {
$image = phutil_tag(