Skip to content

Commit

Permalink
[TASK:T12] Restore button to requeue document in solr-info -> "Index …
Browse files Browse the repository at this point in the history
…Documents"

* Uses ModuleProvider to check access to modules
* Removes unused imports
* Uses `f:be.link` for re-queue action in solr info module

Fixes: #3580
Relates: #3376
  • Loading branch information
sfroemkenjw committed Jun 2, 2023
1 parent 17f46ce commit dfc1435
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use InvalidArgumentException;
use RuntimeException;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Backend\Module\ModuleProvider;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;

Expand Down Expand Up @@ -61,24 +61,16 @@ public function initializeArguments(): void
*/
protected static function evaluateCondition($arguments = null)
{
/** @var BackendUserAuthentication $beUser */
$beUser = $GLOBALS['BE_USER'];
try {
$hasAccessToModule = $beUser->modAccess(
self::getModuleConfiguration(self::getModuleSignatureFromArguments($arguments))
$hasAccessToModule = self::getModuleProvider()->accessGranted(
self::getModuleSignatureFromArguments($arguments),
$GLOBALS['BE_USER']
);
} catch (RuntimeException $exception) {
return false;
}
return $hasAccessToModule;
}

/**
* Returns the backend module configuration
*/
protected static function getModuleConfiguration(string $moduleSignature)
{
return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
return $hasAccessToModule;
}

/**
Expand All @@ -92,14 +84,18 @@ protected static function getModuleSignatureFromArguments(array $arguments): str
$possibleErrorCode = 1496311009;
if (!is_string($moduleSignature)) {
$moduleSignature = $arguments['main'];
$subModuleName = $arguments['extension'] . GeneralUtility::underscoredToUpperCamelCase($arguments['sub']);
$subModuleName = GeneralUtility::underscoredToUpperCamelCase($arguments['sub']);
$moduleSignature .= '_' . $subModuleName;
$possibleErrorMessageAppendix = vsprintf(self::ERROR_APPENDIX_FOR_SIGNATURE_RESOLUTION, [$arguments['extension'], $arguments['main'], $arguments['sub']]);
$possibleErrorCode = 1496311010;
}
if (!isset($GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature])) {

$moduleSignature = strtolower($moduleSignature);

if (!self::getModuleProvider()->isModuleRegistered($moduleSignature)) {
throw new RuntimeException(vsprintf('Module with signature "%s" is not configured or couldn\'t be resolved. ' . $possibleErrorMessageAppendix, [$moduleSignature]), $possibleErrorCode);
}

return $moduleSignature;
}

Expand All @@ -120,4 +116,9 @@ public function validateArguments(): void
throw new InvalidArgumentException('ifHasAccessToModule view helper requires either "signature" or all three other arguments: "extension", "main" and "sub". Please set arguments properly.', 1496314352);
}
}

protected static function getModuleProvider(): ModuleProvider
{
return GeneralUtility::makeInstance(ModuleProvider::class);
}
}
12 changes: 2 additions & 10 deletions Resources/Private/Templates/Backend/Search/InfoModule/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,11 @@ <h3 class="panel-title">
<core:icon identifier="actions-document-view" />
</f:link.action>
</span>
<f:comment>
<!-- The additionalPrams M:'...' can be removed whe TYPO3 8 support will be dropped. -->
</f:comment>
<solr:backend.security.ifHasAccessToModule extension="Solr" main="searchbackend" sub="indexqueue">
<span class="btn btn-default">

<f:link.action action="requeueDocument" arguments="{uid: document.uid, type: document.type}"
controller="Backend\Search\IndexQueueModule"
pluginName="searchbackend_SolrIndexqueue"
additionalParams="{M:'searchbackend_SolrIndexqueue',route: 'searchbackend_SolrIndexqueue'}" title="ReQueue for all languages">
<f:be.link route="searchbackend_indexqueue.Backend\Search\IndexQueueModule_requeueDocument" parameters="{uid: document.uid, type: document.type}">
<core:icon identifier="actions-refresh" />
</f:link.action>

</f:be.link>
</span>
</solr:backend.security.ifHasAccessToModule>
</td>
Expand Down

0 comments on commit dfc1435

Please sign in to comment.