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,42 @@ $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 this, and omit this check, 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) + ->setNewValue( + array( + $file_phid => $attach_mode, + )); + } + $editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setContinueOnMissingFields(true)