From dfa58fec4b6c0386932633d4a7b4a3ab4ed17ba2 Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Wed, 28 Feb 2024 15:12:42 +0100 Subject: [PATCH] [FEATURE] Respect authorization in company detail view for activity protocol and lead list --- Classes/Controller/LeadController.php | 3 ++- Classes/Domain/Repository/LogRepository.php | 7 ++++--- Classes/Domain/Repository/VisitorRepository.php | 11 ++++++++--- Resources/Private/Partials/Box/Company/Visitors.html | 2 +- Resources/Private/Partials/Box/Leads/WhoIsOnline.html | 1 + Resources/Private/Partials/Box/Miscellaneous/Log.html | 1 + 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Classes/Controller/LeadController.php b/Classes/Controller/LeadController.php index df57fd99..f5371914 100644 --- a/Classes/Controller/LeadController.php +++ b/Classes/Controller/LeadController.php @@ -247,6 +247,7 @@ public function companiesDisabledAction(string $tokenWiredminds = ''): ResponseI * @return ResponseInterface * @throws InvalidConfigurationTypeException * @throws InvalidQueryException + * @throws AuthenticationException */ public function companyAction(Company $company): ResponseInterface { @@ -260,7 +261,7 @@ public function companyAction(Company $company): ResponseInterface $this->view->assignMultiple([ 'company' => $company, 'categories' => $this->categoryRepository->findAllLuxCompanyCategories(), - 'interestingLogs' => $this->logRepository->findInterestingLogsByCompany($company), + 'interestingLogs' => $this->logRepository->findInterestingLogsByCompany($company, $filter->setLimit(250)), 'scoringWeeks' => GeneralUtility::makeInstance(CompanyScoringWeeksDataProvider::class, $filter), 'categoryScorings' => GeneralUtility::makeInstance(CompanyCategoryScoringsDataProvider::class, $filter), 'numberOfVisitorsData' => GeneralUtility::makeInstance(PagevisistsDataProvider::class, $filter), diff --git a/Classes/Domain/Repository/LogRepository.php b/Classes/Domain/Repository/LogRepository.php index 34779728..fadf6fc5 100644 --- a/Classes/Domain/Repository/LogRepository.php +++ b/Classes/Domain/Repository/LogRepository.php @@ -51,18 +51,19 @@ public function findInterestingLogs(FilterDto $filter): QueryResultInterface /** * @param Company $company - * @param int $limit + * @param FilterDto $filter * @return QueryResultInterface * @throws InvalidConfigurationTypeException * @throws InvalidQueryException */ - public function findInterestingLogsByCompany(Company $company, int $limit = 250): QueryResultInterface + public function findInterestingLogsByCompany(Company $company, FilterDto $filter): QueryResultInterface { $query = $this->createQuery(); $logicalAnd = $this->interestingLogsLogicalAnd($query); $logicalAnd[] = $query->equals('visitor.companyrecord', $company); + $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForSite($filter, $query, $logicalAnd); $query->matching($query->logicalAnd(...$logicalAnd)); - $query->setLimit($limit); + $query->setLimit($filter->getLimit()); return $query->execute(); } diff --git a/Classes/Domain/Repository/VisitorRepository.php b/Classes/Domain/Repository/VisitorRepository.php index 496607bb..a9180417 100644 --- a/Classes/Domain/Repository/VisitorRepository.php +++ b/Classes/Domain/Repository/VisitorRepository.php @@ -26,6 +26,7 @@ use In2code\Lux\Utility\ArrayUtility; use In2code\Lux\Utility\DatabaseUtility; use In2code\Lux\Utility\DateUtility; +use In2code\Lux\Utility\ObjectUtility; use In2code\Lux\Utility\StringUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; @@ -547,9 +548,13 @@ public function getScoringSumFromCompany(Company $company): int public function findByCompany(Company $company, int $limit = 200): array { $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); - $sql = 'select uid,scoring from ' . Visitor::TABLE_NAME - . ' where deleted=0 and blacklisted=0 and companyrecord = ' . $company->getUid() - . ' order by identified desc, scoring desc limit ' . $limit; + $sql = 'select v.uid,v.scoring from ' . Visitor::TABLE_NAME . ' v' + . ' left join ' . Pagevisit::TABLE_NAME . ' pv on v.uid = pv.visitor' + . ' where v.deleted=0 and v.blacklisted=0 and v.companyrecord = ' . $company->getUid() + . $this->extendWhereClauseWithFilterSite(ObjectUtility::getFilterDto(), 'pv') + . ' group by v.uid,v.scoring' + . ' order by v.identified desc, v.scoring desc' + . ' limit ' . $limit; $results = $connection->executeQuery($sql)->fetchAllAssociative(); $visitors = []; diff --git a/Resources/Private/Partials/Box/Company/Visitors.html b/Resources/Private/Partials/Box/Company/Visitors.html index d7800e69..d7305a0b 100644 --- a/Resources/Private/Partials/Box/Company/Visitors.html +++ b/Resources/Private/Partials/Box/Company/Visitors.html @@ -2,7 +2,7 @@

Leads - ({visitors -> f:count()}) + {visitors -> f:count()}

diff --git a/Resources/Private/Partials/Box/Leads/WhoIsOnline.html b/Resources/Private/Partials/Box/Leads/WhoIsOnline.html index d96e5d3e..0779aca2 100644 --- a/Resources/Private/Partials/Box/Leads/WhoIsOnline.html +++ b/Resources/Private/Partials/Box/Leads/WhoIsOnline.html @@ -2,6 +2,7 @@

Now online + {whoisonline -> f:count()}

diff --git a/Resources/Private/Partials/Box/Miscellaneous/Log.html b/Resources/Private/Partials/Box/Miscellaneous/Log.html index 59124d48..a3f69083 100644 --- a/Resources/Private/Partials/Box/Miscellaneous/Log.html +++ b/Resources/Private/Partials/Box/Miscellaneous/Log.html @@ -2,6 +2,7 @@

Log + {interestingLogs -> f:count()}