Skip to content

Commit

Permalink
[FEATURE] Respect authorization in company detail view
Browse files Browse the repository at this point in the history
for activity protocol and lead list
  • Loading branch information
einpraegsam committed Feb 28, 2024
1 parent 6a7a114 commit dfa58fe
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Classes/Controller/LeadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public function companiesDisabledAction(string $tokenWiredminds = ''): ResponseI
* @return ResponseInterface
* @throws InvalidConfigurationTypeException
* @throws InvalidQueryException
* @throws AuthenticationException
*/
public function companyAction(Company $company): ResponseInterface
{
Expand All @@ -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),
Expand Down
7 changes: 4 additions & 3 deletions Classes/Domain/Repository/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
11 changes: 8 additions & 3 deletions Classes/Domain/Repository/VisitorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Box/Company/Visitors.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="panel-heading">
<h3 class="panel-title">
<f:translate key="LLL:EXT:lux/Resources/Private/Language/locallang_db.xlf:dictionary.leads">Leads</f:translate>
({visitors -> f:count()})
<f:if condition="{visitors}"><span class="badge pull-right">{visitors -> f:count()}</span></f:if>
</h3>
</div>
<div class="panel-body">
Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Partials/Box/Leads/WhoIsOnline.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="panel-heading">
<h3 class="panel-title">
<f:translate key="LLL:EXT:lux/Resources/Private/Language/locallang_db.xlf:module.box.whoisonline.title">Now online</f:translate>
<f:if condition="{whoisonline}"><span class="badge pull-right">{whoisonline -> f:count()}</span></f:if>
</h3>
</div>
<div class="panel-body">
Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Partials/Box/Miscellaneous/Log.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="panel-heading">
<h3 class="panel-title">
<f:translate key="LLL:EXT:lux/Resources/Private/Language/locallang_db.xlf:module.analysis.log">Log</f:translate>
<f:if condition="{interestingLogs}"><span class="badge pull-right">{interestingLogs -> f:count()}</span></f:if>
</h3>
</div>
<div class="panel-body">
Expand Down

0 comments on commit dfa58fe

Please sign in to comment.