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

[FEATURE] added slack online badge

parent 6ede11c0
Pipeline #6218 failed with stages
in 12 seconds
......@@ -17,34 +17,32 @@ class IsSlackOnlineViewhelper extends AbstractViewHelper
*/
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
* @return string
*/
public function render(int $frontendUserUID)
public function render($frontendUserUID)
{
$feUser = $this->slackFrontendUserRepository->findByUid($frontendUserUID);
$slackUser = $this->slackUserRepository->findBySlackId($feUser->getSlackId());
if ($slackUser) {
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 {
$content = 'Slack username: ' . $slackUser->getSlackUserName() . ' Realname: ' . $slackUser->getRealName() . ' status: ' . $slackUser->getPresence();
$status = "slack-offline";
}
} else {
// @todo render link to register for 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';
}
$status = "no-slack";
}
return $content;
return $status;
}
}
\ No newline at end of file
{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}">
<div class="user-box-image ">
<f:if condition="{frontendUser.image} AND {userprofile:isPropertyVisible(propertyName: 'image', user: '{frontendUser}')}">
......@@ -57,9 +62,9 @@
</f:if>
</div>
<f:if condition="userprofile.isSlackOnline">
<div class="user-box-badge slack-online">
<i class="fa fa-2x fa-slack" aria-hidden="true"></i>
</div>
</f:if>
<div class="user-box-badge {t3omy:isSlackOnline(frontendUserUID:'{frontendUser.uid}')}">
<i class="fa fa-2x fa-slack" aria-hidden="true"></i>
</div>
</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