Skip to content
Snippets Groups Projects
Commit db4bff21 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Fixed record location, backend view

parent 209cf43d
No related branches found
No related tags found
No related merge requests found
...@@ -30,11 +30,13 @@ use SGalinski\SgJobs\Domain\Model\Company; ...@@ -30,11 +30,13 @@ use SGalinski\SgJobs\Domain\Model\Company;
use SGalinski\SgJobs\Service\BackendService; use SGalinski\SgJobs\Service\BackendService;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/** /**
* The backend module controller * The backend module controller
...@@ -87,19 +89,20 @@ class BackendController extends ActionController { ...@@ -87,19 +89,20 @@ class BackendController extends ActionController {
BackendService::makeButtons($this->docHeaderComponent, $this->request); BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
list($totalJobCount, $jobs) = BackendService::getJobsByPid($pageUid, $filters); // get all jobs
debug($totalJobCount); /** @var ObjectStorage $jobs */
// when we are on a siteroot page then display the normal view $jobs = $this->jobRepository->findJobs($pageUid, $filters);
$totalJobCount = $jobs->count();
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
$this->view->assign('pageUid', $pageUid);
if ($totalJobCount) { if ($totalJobCount) {
// get all jobs
/** @var ObjectStorage $jobs */
$jobs = $this->jobRepository->findJobs($this->rootPageUid, $filters);
$this->view->assign('jobs', $jobs); $this->view->assign('jobs', $jobs);
// get all Locations // get all Locations
/** @noinspection PhpUndefinedMethodInspection */ /** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $categories */ /** @var QueryResultInterface $categories */
$companies = $this->companyRepository->findByPid($this->rootPageUid); $companies = $this->companyRepository->findByPid($pageUid);
$locationOptions = []; $locationOptions = [];
/** @var Company $companies */ /** @var Company $companies */
...@@ -113,13 +116,15 @@ class BackendController extends ActionController { ...@@ -113,13 +116,15 @@ class BackendController extends ActionController {
$this->view->assign('rootPageUid', $this->rootPageUid); $this->view->assign('rootPageUid', $this->rootPageUid);
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
} else { } else {
$this->view->assign('pages', BackendService::getPagesWithJobRecords()); $this->view->assign('noRecords', 1);
$this->addFlashMessage(
LocalizationUtility::translate('backend.notice.noRecords', 'SgJobs'), '', FlashMessage::INFO
);
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {
// check for NULL value in view and render an error message // check for NULL value in view and render an error message
$this->view->assign('docHeader', NULL); $this->view->assign('docHeader', NULL);
} }
} }
} }
...@@ -29,14 +29,12 @@ namespace SGalinski\SgJobs\Service; ...@@ -29,14 +29,12 @@ namespace SGalinski\SgJobs\Service;
use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Request; use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
/** /**
* Backend Service class * Backend Service class
...@@ -207,50 +205,4 @@ class BackendService { ...@@ -207,50 +205,4 @@ class BackendService {
} }
return $out; return $out;
} }
/**
* Counts the job records on the specified page and returns users records based on the filter options
*
* @param int $pid
* @param array $filters
* @return array
* @throws \InvalidArgumentException
*/
public static function getJobsByPid($pid, array $filters = []): array {
$pid = (int) $pid;
$tableName = 'fe_users';
/** @var $databaseConnection DatabaseConnection */
$databaseConnection = $GLOBALS['TYPO3_DB'];
/** @var DatabaseRecordList $databaseRecordList */
$databaseRecordList = GeneralUtility::makeInstance(DatabaseRecordList::class);
$databaseRecordList->start($pid, $tableName, 0);
$databaseRecordList->setTotalItems($tableName, $pid, []);
$totalUserCount = (int) $databaseRecordList->totalItems;
if (trim($filters['search'])) {
$databaseRecordList->start($pid, $tableName, 0, trim($filters['search']));
}
$queryBuilder = $databaseRecordList->getQueryBuilder($tableName, $pid);
if ($filters['usergroups'] && count($filters['usergroups'])) {
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($tableName)
->getExpressionBuilder();
$groupConstraints = [];
/** @var array $usergroups */
$usergroups = $filters['usergroups'];
foreach ($usergroups as $groupUid) {
$groupUid = (int) $groupUid;
if ($groupUid) {
$groupConstraints[] = $expressionBuilder->inSet($tableName . '.usergroup', $groupUid);
}
}
if (count($groupConstraints)) {
$groupConstraint = call_user_func_array([$expressionBuilder, 'orX'], $groupConstraints);
$queryBuilder = $databaseRecordList->getQueryBuilder($tableName, $pid, [$groupConstraint]);
}
}
$users = $queryBuilder->execute()->fetchAll();
return [$totalUserCount, $users];
}
} }
...@@ -110,6 +110,10 @@ ...@@ -110,6 +110,10 @@
<source>There are no jobs that match your criteria</source> <source>There are no jobs that match your criteria</source>
<target>Es gibt keine Stellenangebote für Ihre Suchkriterien</target> <target>Es gibt keine Stellenangebote für Ihre Suchkriterien</target>
</trans-unit> </trans-unit>
<trans-unit id="backend.notice.noRecords" approved="yes">
<source>There are no records on this page</source>
<target>Es gibt keine Datensätze auf dieser Seite</target>
</trans-unit>
<trans-unit id="backend.selectRootPage" approved="yes"> <trans-unit id="backend.selectRootPage" approved="yes">
<source>Please select one of the following website roots:</source> <source>Please select one of the following website roots:</source>
<target>Bitte wählen Sie eine der folgenden Seiten aus:</target> <target>Bitte wählen Sie eine der folgenden Seiten aus:</target>
......
...@@ -84,6 +84,9 @@ ...@@ -84,6 +84,9 @@
<trans-unit id="backend.noJobsMessage"> <trans-unit id="backend.noJobsMessage">
<source>There are no jobs that match your criteria</source> <source>There are no jobs that match your criteria</source>
</trans-unit> </trans-unit>
<trans-unit id="backend.notice.noRecords">
<source>There are no records on this page</source>
</trans-unit>
<trans-unit id="backend.selectRootPage"> <trans-unit id="backend.selectRootPage">
<source>Please select one of the following website roots:</source> <source>Please select one of the following website roots:</source>
</trans-unit> </trans-unit>
......
...@@ -9,30 +9,42 @@ ...@@ -9,30 +9,42 @@
<f:translate key="backend.jobs.header" /> <f:translate key="backend.jobs.header" />
</f:section> </f:section>
<f:section name="content"> <f:section name="content">
<f:if condition="{docHeader}"> <f:flashMessages />
<f:if condition="{pageUid}">
<f:then> <f:then>
<f:if condition="{pages}"> <f:if condition="{docHeader}">
<f:then> <f:then>
<f:render partial="SelectRoot" arguments="{pages: pages}" /> <f:if condition="{noRecords}">
</f:then>
<f:else>
<f:render partial="Filter" arguments="{filters: filters, locationOptions: locationOptions}" />
<f:render partial="CreateJob" arguments="{rootPageUid:rootPageUid}" />
<f:if condition="{jobs}">
<f:then> <f:then>
<f:render partial="JobList" arguments="{jobs: jobs}" />
</f:then>
<f:else>
<p> <p>
<f:translate key="backend.noJobsMessage" />
</p> </p>
<f:render partial="CreateJob" arguments="{rootPageUid:rootPageUid}" />
</f:then>
<f:else>
<f:render partial="Filter" arguments="{filters: filters, locationOptions: locationOptions}" />
<f:render partial="CreateJob" arguments="{rootPageUid:rootPageUid}" />
<f:if condition="{jobs}">
<f:then>
<f:render partial="JobList" arguments="{jobs: jobs}" />
</f:then>
<f:else>
<p>
<f:translate key="backend.noJobsMessage" />
</p>
</f:else>
</f:if>
</f:else> </f:else>
</f:if> </f:if>
</f:then>
<f:else>
<f:render partial="Error" />
</f:else> </f:else>
</f:if> </f:if>
</f:then> </f:then>
<f:else> <f:else>
<f:render partial="Error" /> <f:render partial="SelectRoot" arguments="{pages: pages}" />
</f:else> </f:else>
</f:if> </f:if>
</f:section> </f:section>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment