Skip to content

Commit

Permalink
[Bug]: Add missing permission check on Rules controller (#483)
Browse files Browse the repository at this point in the history
* chore: fix rules permission check

* Apply php-cs-fixer changes

* chore: fix wrong class

* Update RulesController.php

* fix stan

---------

Co-authored-by: kingjia90 <[email protected]>
  • Loading branch information
kingjia90 and kingjia90 authored Jul 4, 2023
1 parent b244000 commit f15668c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/Controller/Admin/RulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@

namespace CustomerManagementFrameworkBundle\Controller\Admin;

use Pimcore\Bundle\AdminBundle\Controller\AdminController;
use Pimcore\Controller\KernelControllerEventInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/rules")
*/
class RulesController extends \Pimcore\Bundle\AdminBundle\Controller\AdminController
class RulesController extends AdminController implements KernelControllerEventInterface
{
public function onKernelControllerEvent(ControllerEvent $event)
{
$this->checkPermission('plugin_cmf_perm_customer_automation_rules');
}

/**
* get saved action trigger rules
*
Expand Down
16 changes: 7 additions & 9 deletions src/Targeting/SegmentTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,15 @@ public function getFilteredAssignments(VisitorInfo $visitorInfo, array $allowedS

//order segments by count, pick $limitSegmentCountPerGroup top segments
foreach ($segmentCollection as $group => $groupCollection) {
if (!empty($groupCollection)) {
usort($groupCollection, function ($left, $right) {
if ($left['count'] === $right['count']) {
return 0;
}
usort($groupCollection, function ($left, $right) {
if ($left['count'] === $right['count']) {
return 0;
}

return ($left['count'] < $right['count']) ? 1 : -1;
});
return ($left['count'] < $right['count']) ? 1 : -1;
});

$segmentCollection[$group] = array_slice($groupCollection, 0, $limitSegmentCountPerGroup);
}
$segmentCollection[$group] = array_slice($groupCollection, 0, $limitSegmentCountPerGroup);
}

return $segmentCollection;
Expand Down

0 comments on commit f15668c

Please sign in to comment.