Commit 6f1729e5 authored by Sebastian Kotte's avatar Sebastian Kotte
Browse files

[FEATURE] added slack online badge

parent 6ede11c0
Pipeline #6218 failed with stages
in 12 seconds
...@@ -17,34 +17,32 @@ class IsSlackOnlineViewhelper extends AbstractViewHelper ...@@ -17,34 +17,32 @@ class IsSlackOnlineViewhelper extends AbstractViewHelper
*/ */
public $slackUserRepository; public $slackUserRepository;
/**
* @var \T3o\T3oSlack\Domain\Repository\SlackFrontendUserRepository
* @inject
*/
public $slackFrontendUserRepository;
/** /**
* Check if a property of the userprofile is visible in the current context * Checks if the user is online in slack
* *
* @param int $frontendUserUID * @param int $frontendUserUID
* @return string * @return string
*/ */
public function render(int $frontendUserUID) public function render($frontendUserUID)
{ {
$feUser = $this->slackFrontendUserRepository->findByUid($frontendUserUID); $feUser = $this->slackFrontendUserRepository->findByUid($frontendUserUID);
$slackUser = $this->slackUserRepository->findBySlackId($feUser->getSlackId()); $slackUser = $this->slackUserRepository->findBySlackId($feUser->getSlackId());
if ($slackUser) { if ($slackUser) {
if ($slackUser->getPresence() === 'active') { if ($slackUser->getPresence() === 'active') {
$content = '<a href="https://typo3.slack.com/messages/' . $slackUser->getLink() . '" target="_blank">' . $slackUser->getSlackUserName() . ' </a> Realname: ' . $slackUser->getRealName() . ' status: ' . $slackUser->getPresence(); $status = "slack-online";
} else { } else {
$content = 'Slack username: ' . $slackUser->getSlackUserName() . ' Realname: ' . $slackUser->getRealName() . ' status: ' . $slackUser->getPresence(); $status = "slack-offline";
} }
} else { } else {
// @todo render link to register for slack $status = "no-slack";
if ($GLOBALS['TSFE']->fe_user->user['uid'] == $frontendUserUID) {
// @todo add TS configuration
$content = '<a href="https://my.typo3.org/?id=23">Get your TYPO3 Slack Account</a>';
} else {
$content = 'No Slack profile yet';
}
} }
return $status;
return $content;
} }
} }
\ No newline at end of file
{namespace userprofile=In2code\Userprofile\ViewHelpers} {namespace userprofile=In2code\Userprofile\ViewHelpers}
{namespace slack=T3o\T3oSlack\ViewHelpers} {namespace t3omy=T3o\T3omy\ViewHelpers}
<f:comment>
<f:debug>{frontendUser.uid}</f:debug>
<f:debug title="FE USer:{frontendUser.uid}">{t3omy:isSlackOnline(frontendUserUID:'{frontendUser.uid}')}</f:debug>
</f:comment>
<f:debug>{frontendUser}</f:debug>
<f:link.action class="user-box" controller="UserProfile" action="show" arguments="{user:frontendUser}"> <f:link.action class="user-box" controller="UserProfile" action="show" arguments="{user:frontendUser}">
<div class="user-box-image "> <div class="user-box-image ">
<f:if condition="{frontendUser.image} AND {userprofile:isPropertyVisible(propertyName: 'image', user: '{frontendUser}')}"> <f:if condition="{frontendUser.image} AND {userprofile:isPropertyVisible(propertyName: 'image', user: '{frontendUser}')}">
...@@ -57,9 +62,9 @@ ...@@ -57,9 +62,9 @@
</f:if> </f:if>
</div> </div>
<f:if condition="userprofile.isSlackOnline">
<div class="user-box-badge slack-online"> <div class="user-box-badge {t3omy:isSlackOnline(frontendUserUID:'{frontendUser.uid}')}">
<i class="fa fa-2x fa-slack" aria-hidden="true"></i> <i class="fa fa-2x fa-slack" aria-hidden="true"></i>
</div> </div>
</f:if>
</f:link.action> </f:link.action>
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