Page MenuHomePhorge

D25475.1737787643.diff
No OneTemporary

D25475.1737787643.diff

diff --git a/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
--- a/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
@@ -33,6 +33,15 @@
$object->setProperty('cover.filePHID', $file->getPHID());
$object->setProperty('cover.thumbnailPHID', $xform->getPHID());
+
+ // Connect the Transform to the original file.
+ // In this way the user can change the permissions of the original File
+ // and this Transform is reflecting these.
+ $xtransformed = id(new PhabricatorTransformedFile())
+ ->setOriginalPHID($file_phid)
+ ->setTransformedPHID($xform->getPHID())
+ ->setTransform($xform_key)
+ ->save();
}
public function getTitle() {
diff --git a/src/applications/project/controller/PhabricatorProjectCoverController.php b/src/applications/project/controller/PhabricatorProjectCoverController.php
--- a/src/applications/project/controller/PhabricatorProjectCoverController.php
+++ b/src/applications/project/controller/PhabricatorProjectCoverController.php
@@ -35,10 +35,43 @@
$xactions = array();
+ // Set the Image Cover.
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskCoverImageTransaction::TRANSACTIONTYPE)
->setNewValue($file->getPHID());
+ // Attach the Cover Image to the Task.
+ // Base case: handling a new file (supported):
+ // If you are the author of the new File, that File is probably private
+ // as default, so, you attach, to make it visible to Task participants.
+ // Future case: already-existing file (currently unsupported):
+ // If you are the author of an already-existing file, that may be
+ // already attached to this Object.
+ // This is currently not supported from the UX but may be supported
+ // later, checking for potential errors related to double-attach.
+ // Unknown future cases:
+ // A non-author may want to attach a semi-private already-existing file
+ // to make it somehow "more visible" than before without authorization
+ // from the original author.
+ // It is probably quite foolish to try to prevent this kind of things,
+ // since, if you can see something, indeed you can copy-pasta that.
+ // Anyway, since this use-case is unknown,
+ // we are a bit strict, requiring to be the author of that file,
+ // before sharing that as Task cover image.
+ // If you want to support "non-authors", join the Task.
+ // https://we.phorge.it/T15163
+ if ($file->getAuthorPHID() === $viewer->getPHID()) {
+ $template = $object->getApplicationTransactionTemplate();
+ $attach_mode = PhabricatorFileAttachment::MODE_ATTACH;
+ $xactions[] = id(clone $template)
+ ->setTransactionType(PhabricatorTransactions::TYPE_FILE)
+ ->setIgnoreOnNoEffect(true)
+ ->setNewValue(
+ array(
+ $file_phid => $attach_mode,
+ ));
+ }
+
$editor = id(new ManiphestTransactionEditor())
->setActor($viewer)
->setContinueOnMissingFields(true)

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 25, 06:47 (5 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1148620
Default Alt Text
D25475.1737787643.diff (3 KB)

Event Timeline