Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge for release 1.8.3 #95

Merged
merged 7 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions Classes/Service/AccessControlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use Thucke\ThRating\Exception\FeUserNotFoundException;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use \Thucke\ThRating\Domain\Model\Voter;
Expand Down Expand Up @@ -68,6 +67,18 @@ public function injectVoterRepository(\Thucke\ThRating\Domain\Repository\VoterRe
$this->voterRepository = $voterRepository;
}

/**
* @var \TYPO3\CMS\Core\Context\Context $context
*/
protected $context;
/**
* @param \TYPO3\CMS\Core\Context\Context $context
*/
public function injectContext(\TYPO3\CMS\Core\Context\Context $context): void
{
$this->context = $context;
}

/**
* Tests, if the given person is logged into the frontend
*
Expand All @@ -86,7 +97,6 @@ public function isLoggedIn(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $person
return true; //treat anonymous user also as logged in
}
}

return false;
}

Expand All @@ -96,9 +106,7 @@ public function isLoggedIn(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $person
*/
public function backendAdminIsLoggedIn(): bool
{
/** @var Context $context */
$context = GeneralUtility::makeInstance(Context::class, null);
return $context->getPropertyFromAspect('backend.user', 'isLoggedIn');
return $this->context->getPropertyFromAspect('backend.user', 'isLoggedIn');
}

/**
Expand All @@ -108,8 +116,7 @@ public function backendAdminIsLoggedIn(): bool
public function hasLoggedInFrontendUser(): bool
{
/** @var Context $context */
$context = GeneralUtility::makeInstance(Context::class, array());
return $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
return $this->context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
}

/**
Expand All @@ -119,9 +126,8 @@ public function hasLoggedInFrontendUser(): bool
public function getFrontendUserGroups(): array
{
if ($this->hasLoggedInFrontendUser()) {
return $GLOBALS['TSFE']->fe_user->groupData['uid'];
return $this->context->getPropertyFromAspect('frontend.user', 'groupIds');
}

return [];
}

Expand All @@ -131,8 +137,8 @@ public function getFrontendUserGroups(): array
*/
public function getFrontendUserUid(): ?int
{
if ($this->hasLoggedInFrontendUser() && !empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
return (int)$GLOBALS['TSFE']->fe_user->user['uid'];
if ($this->hasLoggedInFrontendUser()) {
return $this->context->getPropertyFromAspect('frontend.user', 'id');
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'title' => 'Rating AX',
'description' => 'Highly flexible AJAX rating based on extbase/fluid/jquery. Allows multiple ratings within one page. Could be used as a cObj by other extensions or included in every FLUID template using the viewhelper. Each ratingstep could be configured having a name - international localization included.',
'category' => 'misc',
'version' => '1.8.2',
'version' => '1.8.3',
'state' => 'stable',
'uploadfolder' => false,
'createDirs' => '',
Expand Down