Skip to content

Commit f15668c

Browse files
authored
[Bug]: Add missing permission check on Rules controller (#483)
* 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]>
1 parent b244000 commit f15668c

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/Controller/Admin/RulesController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@
1515

1616
namespace CustomerManagementFrameworkBundle\Controller\Admin;
1717

18+
use Pimcore\Bundle\AdminBundle\Controller\AdminController;
19+
use Pimcore\Controller\KernelControllerEventInterface;
1820
use Symfony\Component\HttpFoundation\Request;
21+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
1922
use Symfony\Component\Routing\Annotation\Route;
2023

2124
/**
2225
* @Route("/rules")
2326
*/
24-
class RulesController extends \Pimcore\Bundle\AdminBundle\Controller\AdminController
27+
class RulesController extends AdminController implements KernelControllerEventInterface
2528
{
29+
public function onKernelControllerEvent(ControllerEvent $event)
30+
{
31+
$this->checkPermission('plugin_cmf_perm_customer_automation_rules');
32+
}
33+
2634
/**
2735
* get saved action trigger rules
2836
*

src/Targeting/SegmentTracker.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,15 @@ public function getFilteredAssignments(VisitorInfo $visitorInfo, array $allowedS
175175

176176
//order segments by count, pick $limitSegmentCountPerGroup top segments
177177
foreach ($segmentCollection as $group => $groupCollection) {
178-
if (!empty($groupCollection)) {
179-
usort($groupCollection, function ($left, $right) {
180-
if ($left['count'] === $right['count']) {
181-
return 0;
182-
}
178+
usort($groupCollection, function ($left, $right) {
179+
if ($left['count'] === $right['count']) {
180+
return 0;
181+
}
183182

184-
return ($left['count'] < $right['count']) ? 1 : -1;
185-
});
183+
return ($left['count'] < $right['count']) ? 1 : -1;
184+
});
186185

187-
$segmentCollection[$group] = array_slice($groupCollection, 0, $limitSegmentCountPerGroup);
188-
}
186+
$segmentCollection[$group] = array_slice($groupCollection, 0, $limitSegmentCountPerGroup);
189187
}
190188

191189
return $segmentCollection;

0 commit comments

Comments
 (0)