diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php
index 0bc77e9..a6993ba 100644
--- a/Classes/Configuration/ExtensionConfiguration.php
+++ b/Classes/Configuration/ExtensionConfiguration.php
@@ -41,6 +41,7 @@ class ExtensionConfiguration
private static bool $forceDownload = false;
private static string $forceDownloadForExt = '';
private static bool $trackDownloads = false;
+ private static bool $linkDownloads = false;
private static bool $resumableDownload = true;
private static function init(): void
@@ -53,6 +54,7 @@ private static function init(): void
self::$forceDownload = (bool)$extensionConfig['force_download'];
self::$forceDownloadForExt = $extensionConfig['force_download_for_ext'];
self::$trackDownloads = (bool)$extensionConfig['track_downloads'];
+ self::$linkDownloads = isset($extensionConfig['link_downloads']) && $extensionConfig['link_downloads'];
self::$resumableDownload = isset($extensionConfig['resumable_download']) && $extensionConfig['resumable_download'];
}
}
@@ -90,6 +92,17 @@ public static function trackDownloads(): bool
return self::$trackDownloads;
}
+ /**
+ * Link downloads in TCA
+ *
+ * @return bool
+ */
+ public static function linkDownloads(): bool
+ {
+ self::init();
+ return self::$linkDownloads;
+ }
+
public static function resumableDownload(): bool
{
self::init();
diff --git a/Classes/EventListener/ModifyFileDumpEventListener.php b/Classes/EventListener/ModifyFileDumpEventListener.php
index 6f5998c..3a9c63e 100644
--- a/Classes/EventListener/ModifyFileDumpEventListener.php
+++ b/Classes/EventListener/ModifyFileDumpEventListener.php
@@ -39,6 +39,7 @@
use TYPO3\CMS\Core\Context\Exception\AspectPropertyNotFoundException;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\ReferenceIndex;
use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Resource\Event\ModifyFileDumpEvent;
@@ -146,13 +147,19 @@ private function checkFileAccess(ResourceInterface $file)
'file' => (int)$this->originalFile->getUid(),
];
- GeneralUtility::makeInstance(ConnectionPool::class)
- ->getConnectionForTable('tx_falsecuredownload_download')
- ->insert(
- 'tx_falsecuredownload_download',
- $columns,
- [Connection::PARAM_INT, Connection::PARAM_INT, Connection::PARAM_INT, Connection::PARAM_INT]
- );
+ $downloadConnection = GeneralUtility::makeInstance(ConnectionPool::class)
+ ->getConnectionForTable('tx_falsecuredownload_download');
+ $downloadConnection->insert(
+ 'tx_falsecuredownload_download',
+ $columns,
+ [Connection::PARAM_INT, Connection::PARAM_INT, Connection::PARAM_INT, Connection::PARAM_INT]
+ );
+
+ if (ExtensionConfiguration::linkDownloads()) {
+ $downloadUid = $downloadConnection->lastInsertId();
+ $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
+ $referenceIndex->updateRefIndexTable('tx_falsecuredownload_download', $downloadUid);
+ }
}
// Dump the precise requested file for File and ProcessedFile, but dump the referenced file for FileReference
diff --git a/Configuration/TCA/tx_falsecuredownload_download.php b/Configuration/TCA/tx_falsecuredownload_download.php
index 647da06..d5ac381 100644
--- a/Configuration/TCA/tx_falsecuredownload_download.php
+++ b/Configuration/TCA/tx_falsecuredownload_download.php
@@ -34,25 +34,34 @@
'exclude' => false,
'label' => 'LLL:EXT:fal_securedownload/Resources/Private/Language/locallang_db.xlf:file',
'config' => [
- 'type' => 'group',
- 'size' => 1,
- 'maxitems' => 1,
- 'minitems' => 1,
- 'allowed' => 'sys_file',
+ 'type' => 'passthrough',
],
],
'feuser' => [
'exclude' => false,
'label' => 'LLL:EXT:fal_securedownload/Resources/Private/Language/locallang_db.xlf:fe_user',
'config' => [
- 'type' => 'group',
- 'size' => 1,
- 'maxitems' => 1,
- 'minitems' => 1,
- 'allowed' => 'fe_users',
+ 'type' => 'passthrough',
],
- ],
+ ]
],
];
+if (\BeechIt\FalSecuredownload\Configuration\ExtensionConfiguration::linkDownloads()) {
+ $tca['columns']['file']['config'] = [
+ 'type' => 'group',
+ 'size' => 1,
+ 'maxitems' => 1,
+ 'minitems' => 1,
+ 'allowed' => 'sys_file',
+ ];
+ $tca['columns']['feuser']['config'] = [
+ 'type' => 'group',
+ 'size' => 1,
+ 'maxitems' => 1,
+ 'minitems' => 1,
+ 'allowed' => 'fe_users',
+ ];
+}
+
return $tca;
diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf
index 76b4362..49b6e56 100644
--- a/Resources/Private/Language/locallang_be.xlf
+++ b/Resources/Private/Language/locallang_be.xlf
@@ -43,6 +43,9 @@
+
+
+
diff --git a/ext_conf_template.txt b/ext_conf_template.txt
index c62c220..e5c93f6 100644
--- a/ext_conf_template.txt
+++ b/ext_conf_template.txt
@@ -15,3 +15,6 @@ resumable_download = 1
# cat=basic/enable/6; type=boolean; label=LLL:EXT:fal_securedownload/Resources/Private/Language/locallang_be.xlf:extmng.track_downloads
track_downloads = 0
+
+# cat=basic/enable/7; type=boolean; label=LLL:EXT:fal_securedownload/Resources/Private/Language/locallang_be.xlf:extmng.link_downloads
+link_downloads = 0