Skip to content

Commit

Permalink
!!![FEATURE] Define where to save linklistener, shortener and utm-gen…
Browse files Browse the repository at this point in the history
…erator records via User TSConfig now

Before this commit, there was a general setting in ext_conf_template.txt file for linklistenr records. And this accidentally was also used for shortener and utm-generator records in LUXenterprise. Now with the introduction of multiclient support, we want to store those records on different pages - depending on the backend user that is working with those tables.
Summary: While the setting in ext_conf_template.txt file was removed, now a User TSConfig setting should be added to be_groups (or be_user) when those records should not be stored on root page (where editors normaly don't have access) like:
tx_lux {
   defaultPage {
      tx_lux_domain_model_linklistener = 1
      tx_luxenterprise_domain_model_shortener = 2
      tx_luxenterprise_domain_model_utmgenerator_uri = 3
   }
}
  • Loading branch information
einpraegsam committed Mar 1, 2024
1 parent 51e0129 commit b12709f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
24 changes: 24 additions & 0 deletions Classes/Utility/BackendUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use In2code\Lux\Domain\Model\Transfer\FilterDto;
use Throwable;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Property\PropertyMapper;

Expand Down Expand Up @@ -36,6 +37,20 @@ public static function isAdministrator(): bool
return false;
}

/**
* @param string $path
* @return int|string|array
*/
public static function getUserTsConfigByPath(string $path)
{
try {
return ArrayUtility::getValueByPath(self::getUserTsConfig(), $path);
} catch (Throwable $exception) {
unset($exception);
}
return '';
}

public static function saveValueToSession(string $key, string $action, string $controller, array $data): void
{
self::getBackendUserAuthentication()->setAndSaveSessionData($key . $action . $controller . '_lux', $data);
Expand Down Expand Up @@ -72,6 +87,15 @@ public static function getSessionValue(string $key, string $action, string $cont
return [];
}

protected static function getUserTsConfig(): array
{
$backendUserAuthentication = self::getBackendUserAuthentication();
if ($backendUserAuthentication !== null) {
return $backendUserAuthentication->getTSConfig();
}
return [];
}

public static function getBackendUserAuthentication(): ?BackendUserAuthentication
{
return $GLOBALS['BE_USER'] ?? null;
Expand Down
11 changes: 0 additions & 11 deletions Classes/Utility/ConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ public static function getCategoryScoringLinkListenerClick(): int
return (int)$extensionConfig['categoryScoringLinkListenerClick'];
}

/**
* @return int
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
public static function getPidLinkClickRedords(): int
{
$extensionConfig = self::getExtensionConfiguration();
return (int)$extensionConfig['pidLinkClickRedords'];
}

/**
* @return bool
* @throws ExtensionConfigurationExtensionNotConfiguredException
Expand Down
32 changes: 26 additions & 6 deletions Classes/ViewHelpers/Backend/UriNewViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
namespace In2code\Lux\ViewHelpers\Backend;

use In2code\Lux\Domain\Service\Uri\NewRecord;
use In2code\Lux\Utility\ConfigurationUtility;
use In2code\Lux\Utility\BackendUtility;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

Expand All @@ -24,16 +22,38 @@ public function initializeArguments()
/**
* @return string
* @throws RouteNotFoundException
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
public function render(): string
{
$newRecord = GeneralUtility::makeInstance(NewRecord::class, $this->renderingContext);
return $newRecord->get(
$this->arguments['tableName'],
ConfigurationUtility::getPidLinkClickRedords(),
$this->getPageIdentifierForTable($this->arguments['tableName']),
(bool)$this->arguments['addReturnUrl']
);
}

/**
* Get page identifier from user tsconfig
*
* Example configuration in be_groups could be:
* tx_lux {
* defaultPage {
* tx_lux_domain_model_linklistener = 1
* tx_luxenterprise_domain_model_shortener = 2
* tx_luxenterprise_domain_model_utmgenerator_uri = 3
* }
* }
*
* @param string $tableName
* @return int
*/
protected function getPageIdentifierForTable(string $tableName): int
{
$configuration = BackendUtility::getUserTsConfigByPath('tx_lux./defaultPage.');
if (array_key_exists($tableName, $configuration)) {
return (int)$configuration[$tableName];
}
return 0;
}
}
3 changes: 0 additions & 3 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ categoryScoringAddDownload = 20
# cat=basic//050; type=number; label= Add on click on Link Listener: Add a value to the category scoring if a lead clicks a Link Listener link
categoryScoringLinkListenerClick = 20

# cat=basic//060; type=number; label= Where to save LinkListener records: Define a page where the link listener records should be saved - relevant for editor rights
pidLinkClickRedords = 0



# cat=module/enable/100; type=boolean; label= Disable analysis module: Turn off the analysis backend-module if you don't need it.
Expand Down

0 comments on commit b12709f

Please sign in to comment.