diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index f7006d0db4115df1e9af9c33f27a1c4790c11636..5bbacd45ba291e3bfb83a7dbe6488571d413c4e1 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -159,10 +159,12 @@ class JoblistController extends ActionController { $offset = $currentPageBrowserPage * $jobLimit; } + $frontendPluginSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + $frontendPluginSettings = $frontendPluginSettings['settings']; + // get all jobs for the current page - $ordering = (int) $this->configurationManager->getConfiguration( - ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK - )['settings']['orderBy']; + $ordering = (int)$frontendPluginSettings['orderBy']; + FrontendFilterService::setAllowManualSorting($frontendPluginSettings['allowManualSorting']); $jobs = FrontendFilterService::getJobs($filters, $jobLimit, $offset, $ordering); // get all jobs for the current page diff --git a/Classes/Domain/Repository/JobRepository.php b/Classes/Domain/Repository/JobRepository.php index 735b98fd360890bcff759f96d69972f37cc80be1..64b88c9770db461e7d9f82c417ad98b0b5834e85 100644 --- a/Classes/Domain/Repository/JobRepository.php +++ b/Classes/Domain/Repository/JobRepository.php @@ -44,6 +44,11 @@ class JobRepository extends Repository { const ORDER_BY_CRDATE = 2; const ORDER_BY_SORTING = 0; + /** + * @var bool $allowManualSorting + */ + protected $allowManualSorting = false; + /** * initializes the object */ @@ -191,7 +196,10 @@ class JobRepository extends Repository { array $filters = [], $limit = 0, $offset = 0, $ordering = 0 ): ExtbaseQueryResultInterface { $query = $this->createQuery(); - if ($ordering === self::ORDER_BY_TITLE) { + + + + if ($ordering === self::ORDER_BY_TITLE || (!$this->allowManualSorting && $ordering === self::ORDER_BY_SORTING)) { $query->setOrderings( [ 'title' => QueryInterface::ORDER_ASCENDING, @@ -207,7 +215,7 @@ class JobRepository extends Repository { ); } - if ($ordering === self::ORDER_BY_SORTING) { + if ($ordering === self::ORDER_BY_SORTING && $this->allowManualSorting) { $query->setOrderings( [ 'sorting' => QueryInterface::ORDER_ASCENDING @@ -327,4 +335,20 @@ class JobRepository extends Repository { return $query->matching($query->logicalAnd($constraints))->execute(); } + + /** + * @return bool + */ + public function isAllowManualSorting(): bool { + return $this->allowManualSorting; + } + + /** + * @param bool $allowManualSorting + */ + public function setAllowManualSorting(bool $allowManualSorting) { + $this->allowManualSorting = $allowManualSorting; + } + + } diff --git a/Classes/Service/FrontendFilterService.php b/Classes/Service/FrontendFilterService.php index b63b181c53ba8ceff42fc022556217468b4310d2..ac1b9db9c595f15679e07534692dd1028ca567c3 100644 --- a/Classes/Service/FrontendFilterService.php +++ b/Classes/Service/FrontendFilterService.php @@ -51,4 +51,22 @@ class FrontendFilterService { $jobRepository = $objectManager->get(JobRepository::class); return $jobRepository->findJobsByFilter($filters, $limit, $offset, $ordering)->toArray(); } + + /** + * @return bool + */ + public static function isAllowManualSorting(): bool { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $jobRepository = $objectManager->get(JobRepository::class); + return $jobRepository->isAllowManualSorting(); + } + + /** + * @param bool $allowManualSorting + */ + public static function setAllowManualSorting(bool $allowManualSorting) { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $jobRepository = $objectManager->get(JobRepository::class); + $jobRepository->setAllowManualSorting($allowManualSorting); + } } diff --git a/Configuration/TypoScript/Frontend/constants.typoscript b/Configuration/TypoScript/Frontend/constants.typoscript index e0f95ba9896846d07d55c8088a24e83b6428e2ef..310da88baaab021c1e07eea655ebbc20ffd43896 100644 --- a/Configuration/TypoScript/Frontend/constants.typoscript +++ b/Configuration/TypoScript/Frontend/constants.typoscript @@ -13,6 +13,8 @@ plugin.tx_sgjobs { settings { # cat=plugin.tx_sgjobs/other; type=string; label=Mail address to send submitted applications to applicationEmail = + # cat=plugin.tx_sgjobs/other; type=boolean; label=Enable manual sorting + allowManualSorting = 0 # cat=plugin.tx_sgjobs/other; type=string; label=Allowed file extensions for uploads in the controller (comma separated) allowedFileExtensions = pdf # cat=plugin.tx_sgjobs/other; type=string; label=Allowed mime types for uploads in the Fluid template (comma separated) diff --git a/Configuration/TypoScript/Frontend/setup.typoscript b/Configuration/TypoScript/Frontend/setup.typoscript index a1929d9be924ba5ecc702196749af88c33f3f884..105a23bc712c9549cb046d7b6e765e8742cb1314 100644 --- a/Configuration/TypoScript/Frontend/setup.typoscript +++ b/Configuration/TypoScript/Frontend/setup.typoscript @@ -23,6 +23,7 @@ plugin.tx_sgjobs { settings { allowedFileExtensions = {$plugin.tx_sgjobs.settings.allowedFileExtensions} + allowManualSorting = {$plugin.tx_sgjobs.settings.allowManualSorting} allowedMimeTypes = {$plugin.tx_sgjobs.settings.allowedMimeTypes} allowedMaxFileSize = {$plugin.tx_sgjobs.settings.allowedMaxFileSize} privacyPolicyPage = {$plugin.tx_sgjobs.settings.privacyPolicyPage} diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index f7da7d58cc2b889237b526ae90f6cca09779aa3e..e2cdf4c55a27cc0f1b6c06f3ce66b3581863dbe0 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -214,8 +214,8 @@ <target><![CDATA[Sortierung der Stellenangebote]]></target> </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.orderBy_1" approved="yes"> - <source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module)]]></source> - <target><![CDATA[Manuell (Stellenangebote werden wie im "Stellenangebote" Modul sortiert)]]></target> + <source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module. Must be enabled in configuration)]]></source> + <target><![CDATA[Manuell (Stellenangebote werden wie im "Stellenangebote" Modul sortiert. Muss in den Einstellungen erlaubt sein.)]]></target> </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.orderBy_2" approved="yes"> <source><![CDATA[Alphabetically by job title (A-Z)]]></source> @@ -371,4 +371,4 @@ </trans-unit> </body> </file> -</xliff> \ No newline at end of file +</xliff> diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 2195fcb877661396db0a52299ef7bed2c085c1de..50d3a9110c66d9a58fc6af2739ed0e6ce7e08eea 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -166,7 +166,7 @@ <source><![CDATA[Sorting of job offers]]></source> </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.orderBy_1"> - <source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module)]]></source> + <source><![CDATA[Manual (Uses sorting visible in the "Job Offers" module. Must be enabled in configuration)]]></source> </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.orderBy_2"> <source><![CDATA[Alphabetically by job title (A-Z)]]></source> @@ -284,4 +284,4 @@ </trans-unit> </body> </file> -</xliff> \ No newline at end of file +</xliff>