Commit 0e1a97e0 authored by mabolek's avatar mabolek

[TASK] Completed karma source referencing

parent ab37000d
......@@ -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
*
......
......@@ -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);
......
......@@ -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__
);
}
}
......@@ -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' => [
......
......@@ -12,7 +12,7 @@
<f:for each="{entries}" as="entry">
<tr id="entry-{entry.uid}">
<td>{entry.crdate -> f:format.date(format:'j F, Y')}</td>
<td>{entry.karmaSource.title}</td>
<td>{entry.karmaSource} {entry.issuer} {entry.issuerAction}</td>
<td>{entry.immutableValue}</td>
<td>{entry.mutableValue}</td>
</tr>
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment