diff --git a/extensions/karma/Classes/Domain/Model/LedgerEntry.php b/extensions/karma/Classes/Domain/Model/LedgerEntry.php index c793672920667b171386cd9f1c5b684bcf4b7982..c20ae3c45f95312cbe2ecbd7fcd3d96cf47c75fe 100644 --- a/extensions/karma/Classes/Domain/Model/LedgerEntry.php +++ b/extensions/karma/Classes/Domain/Model/LedgerEntry.php @@ -62,12 +62,22 @@ class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity protected $mutableValue; /** - * The entry karma source + * The entry karma source code * * @var string */ protected $karmaSource; + /** + * @var string + */ + protected $issuer; + + /** + * @var string + */ + protected $issuerAction; + /** * Set to the related campaign if the entry is generated through a campaign * @@ -214,6 +224,47 @@ class LedgerEntry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $this->karmaSource = $karmaSource; } + /** + * Get the issuer code + * + * @return string + */ + public function getIssuer() + { + return $this->issuer; + } + + /** + * Set the issuer code + * + * @param string $issuer + */ + public function setIssuer(string $issuer) + { + $this->issuer = $issuer; + } + + /** + * Get the issuer action code + * + * @return string + */ + public function getIssuerAction() + { + return $this->issuerAction; + } + + /** + * Set the issuer action code + * + * @param string $issuerAction + */ + public function setIssuerAction(string $issuerAction) + { + $this->issuerAction = $issuerAction; + } + + /** * Get the entry campaign that generated this entry, or null if no campaign * diff --git a/extensions/karma/Classes/Service/KarmaService.php b/extensions/karma/Classes/Service/KarmaService.php index 18b7065bb9d951af1643a00e4d9c9ff1664ad26f..e99d077e8fdf717f94a6cbb06979c55356169c2f 100644 --- a/extensions/karma/Classes/Service/KarmaService.php +++ b/extensions/karma/Classes/Service/KarmaService.php @@ -129,9 +129,10 @@ class KarmaService implements \TYPO3\CMS\Core\SingletonInterface * @param int $karmaValue to add to the user * @param ExtbaseFrontendUser $frontendUser to add the value to * @param string $karmaSource for the karma value - * @param Campaign $campaign for the value (optional) + * @param string $karmaIssuer code + * @param string $karmaIssuerAction code */ - public function addKarmaToUser(int $karmaValue, ExtbaseFrontendUser $frontendUser, string $karmaSource, Campaign $campaign = null) + public function addKarmaToUser(int $karmaValue, ExtbaseFrontendUser $frontendUser, string $karmaSource, string $karmaIssuer, string $karmaIssuerAction) { $frontendUser = $this->ensureCorrectFrontendUserSubclass($frontendUser); @@ -141,9 +142,8 @@ class KarmaService implements \TYPO3\CMS\Core\SingletonInterface $ledgerEntry->setMutableValue($karmaValue); $ledgerEntry->setUser($frontendUser); $ledgerEntry->setKarmaSource($karmaSource); - if ($campaign !== null) { - $ledgerEntry->setCampaign($campaign); - } + $ledgerEntry->setIssuer($karmaIssuer); + $ledgerEntry->setIssuerAction($karmaIssuerAction); $this->ledgerEntryRepository->add($ledgerEntry); diff --git a/extensions/karma/Classes/Utility/UserProfileChangeKarmaIssuerUtility.php b/extensions/karma/Classes/Utility/UserProfileChangeKarmaIssuerUtility.php index 599b5b7d69bdc03b0d88c40c58f4538347fc520e..4eff04fa36b616151418a46f6111ac0c28a56eae 100644 --- a/extensions/karma/Classes/Utility/UserProfileChangeKarmaIssuerUtility.php +++ b/extensions/karma/Classes/Utility/UserProfileChangeKarmaIssuerUtility.php @@ -35,6 +35,8 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; class UserProfileChangeKarmaIssuerUtility { + public const ISSUER_CODE = 'userProfileChange'; + /** * @var \T3o\Karma\Service\KarmaService */ @@ -100,7 +102,7 @@ class UserProfileChangeKarmaIssuerUtility */ public function newUserWasCreated(ExtbaseFrontendUser $frontendUser) { - $issuerActionSettings = $this->settings['issuers']['userProfileChange']['newUserWasCreated']; + $issuerActionSettings = $this->settings['issuers'][self::ISSUER_CODE][__FUNCTION__]; $karmaSourceCode = $issuerActionSettings['sourceCode']; if ($karmaSourceCode === '') { @@ -110,7 +112,9 @@ class UserProfileChangeKarmaIssuerUtility $this->karmaService->addKarmaToUser( $issuerActionSettings['valueEarned'], $frontendUser, - $issuerActionSettings['sourceCode'] + $issuerActionSettings['sourceCode'], + self::ISSUER_CODE, + __FUNCTION__ ); } } diff --git a/extensions/karma/Configuration/TCA/tx_karma_domain_model_ledgerentry.php b/extensions/karma/Configuration/TCA/tx_karma_domain_model_ledgerentry.php index d798f408523dd5cba9bdeabc62f0e9469596cde0..443dbdaa4b9ea12d3a5f8cb423ba5e7fc1d39239 100644 --- a/extensions/karma/Configuration/TCA/tx_karma_domain_model_ledgerentry.php +++ b/extensions/karma/Configuration/TCA/tx_karma_domain_model_ledgerentry.php @@ -84,8 +84,27 @@ $tx_karma_domain_model_ledgerentry = [ 'type' => 'input', 'size' => 16, 'max' => 16, - 'eval' => 'trim', - 'default' => 0, + 'eval' => 'trim' + ] + ], + 'issuer' => [ + 'exclude' => true, + 'label' => $ll . 'tx_karma_domain_model_ledgerentry.issuer', + 'config' => [ + 'type' => 'input', + 'size' => 32, + 'max' => 32, + 'eval' => 'trim' + ] + ], + 'issuer_action' => [ + 'exclude' => true, + 'label' => $ll . 'tx_karma_domain_model_ledgerentry.issuer_action', + 'config' => [ + 'type' => 'input', + 'size' => 32, + 'max' => 32, + 'eval' => 'trim' ] ], 'campaign' => [ diff --git a/extensions/karma/Resources/Private/Templates/UserDisplay/List.html b/extensions/karma/Resources/Private/Templates/UserDisplay/List.html index ff784c18c19b0ee0083ceadaf75e4240adec1121..73868b4ee8d14c945191d65ad2a71dc953898cba 100644 --- a/extensions/karma/Resources/Private/Templates/UserDisplay/List.html +++ b/extensions/karma/Resources/Private/Templates/UserDisplay/List.html @@ -12,7 +12,7 @@ {entry.crdate -> f:format.date(format:'j F, Y')} - {entry.karmaSource.title} + {entry.karmaSource} {entry.issuer} {entry.issuerAction} {entry.immutableValue} {entry.mutableValue} diff --git a/extensions/karma/ext_tables.sql b/extensions/karma/ext_tables.sql index 0a27577a6e4d96d890066cc3370afdf1f5ca9dc4..e497476b78538e68d5ec3dd8ec87f7e290496787 100644 --- a/extensions/karma/ext_tables.sql +++ b/extensions/karma/ext_tables.sql @@ -14,6 +14,9 @@ CREATE TABLE tx_karma_domain_model_ledgerentry ( mutable_value int(11) DEFAULT '0', karma_source varchar(16) DEFAULT '', + issuer varchar(32) DEFAULT '', + issuer_action varchar(32) DEFAULT '', + campaign int(11) unsigned DEFAULT '0', user int(11) unsigned DEFAULT '0',