Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
t3o
my.typo3.org
Commits
df6a3234
Commit
df6a3234
authored
Nov 06, 2018
by
mabolek
Committed by
Thomas Löffler
Feb 11, 2019
Browse files
[FEATURE] Basic karma widget for users
parent
a0d0aa20
Changes
4
Hide whitespace changes
Inline
Side-by-side
extensions/karma/Classes/Controller/AbstractController.php
View file @
df6a3234
...
...
@@ -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
T
YPO3\CMS\Extbase
\Domain\Repository\FrontendUserRepository
;
use
T
3o\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
)
{
...
...
extensions/karma/Classes/Controller/UserDisplayController.php
View file @
df6a3234
...
...
@@ -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
));
}
}
}
extensions/karma/Classes/Service/KarmaService.php
View file @
df6a3234
...
...
@@ -105,7 +105,7 @@ class KarmaService implements \TYPO3\CMS\Core\SingletonInterface
$frontendUser
=
$this
->
ensureCorrectFrontendUserSubclass
(
$frontendUser
);
if
(
!
$ignoreCache
)
{
return
$frontendUser
->
getKarmaMutableValue
();
return
$frontendUser
->
getKarmaMutableValue
Cache
();
}
$mutableKarma
=
$this
->
ledgerEntryRepository
->
calculateMutableKarmaTotalForUser
(
$frontendUser
);
...
...
html/typo3conf/ext/karma/Resources/Private/Templates/UserDisplay/StatusWidget.html
0 → 100644
View file @
df6a3234
<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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment