Commit cb162627 authored by mabolek's avatar mabolek Committed by Thomas Löffler
Browse files

[FEATURE] Basic karma widget for users

parent 5e9cea9d
......@@ -5,7 +5,7 @@ namespace T3o\Karma\Controller;
use T3o\Karma\Domain\Repository\KarmaSourceRepository;
use T3o\Karma\Domain\Repository\LedgerEntryRepository;
use T3o\Karma\Service\KarmaService;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use T3o\Karma\Domain\Repository\FrontendUserRepository;
/***************************************************************
* Copyright notice
......@@ -38,7 +38,7 @@ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
protected $karmaService;
/**
* @var FrontendUserRepository
* @var \T3o\Karma\Domain\Repository\FrontendUserRepository
*/
protected $frontendUserRepository;
......@@ -61,7 +61,7 @@ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
}
/**
* @param FrontendUserRepository $frontendUserRepository
* @param \T3o\Karma\Domain\Repository\FrontendUserRepository $frontendUserRepository
*/
public function injectFrontendUserRepository(FrontendUserRepository $frontendUserRepository)
{
......
......@@ -42,6 +42,15 @@ class UserDisplayController extends AbstractController
*/
public function statusWidgetAction()
{
if ($GLOBALS['TSFE']->fe_user->user['uid']) {
$frontendUser = $this->frontendUserRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
$immutableValue = $this->karmaService->getImmutableKarmaForUser($frontendUser);
$mutableValue = $this->karmaService->getMutableKarmaForUser($frontendUser);
$this->view->assign('immutableValue', $immutableValue);
$this->view->assign('mutableValue', $mutableValue);
$this->view->assign('hasKarma', ($immutableValue > 0 || $mutableValue > 0));
}
}
}
<section class="container">
<h3>Karma Status</h3>
<f:if condition="{hasKarma}">
<f:then>
<p>
<strong>{immutableValue}</strong> karma points<br>
<strong>{mutableValue}</strong> karma cash
</p>
</f:then>
<f:else>
<p>You do not have any karma yet. Participate in the community to earn some.</p>
</f:else>
</f:if>
</section>
\ No newline at end of file
Supports Markdown
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