PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Controllers/EntitySelectController.php +34 -15 10.0.1 → 11.1.0 View file →
@@ -1,25 +1,22 @@
1 1 <?php
2 2
3 3 namespace AcyMailing\Controllers;
4 4
5 -use AcyMailing\Helpers\EntitySelectHelper;
6 5 use AcyMailing\Core\AcymController;
7 6
8 7 class EntitySelectController extends AcymController
9 8 {
10 - var $entitySelectHelper;
11 -
12 9 public function __construct()
13 10 {
14 11 parent::__construct();
15 - $this->entitySelectHelper = new EntitySelectHelper();
12 +
16 13 $this->loadScripts = [
17 14 'all' => ['vue-applications' => ['entity_select']],
18 15 ];
19 16 }
20 17
21 - public function loadEntityFront()
18 + public function loadEntityFront(): void
22 19 {
23 20 $entity = acym_getVar('string', 'entity');
24 21 $offset = acym_getVar('int', 'offset');
25 22 $perCalls = acym_getVar('int', 'perCalls');
@@ -37,21 +34,35 @@
37 34 acym_sendAjaxResponse('', ['results' => $entityBack]);
38 35 }
39 36 }
40 37
41 - private function loadEntityBack($entity, $offset, $perCalls, $join, $columnsToDisplay): array
38 + private function loadEntityBack(string $entity, int $offset, int $perCalls, string $join, array $columnsToDisplay): array
42 39 {
43 40 if (empty($entity) || (empty($offset) && 0 !== $offset) || empty($perCalls)) {
44 41 return ['error' => acym_translation('ACYM_MISSING_PARAMETERS')];
45 42 }
46 43
44 + if (!in_array($entity, ['list', 'user'])) {
45 + return ['error' => acym_translation('ACYM_UNAUTHORIZED_ACCESS')];
46 + }
47 +
47 48 $entityParams = [
48 49 'offset' => $offset,
49 50 'elementsPerPage' => $perCalls,
50 51 'entitySelect' => true,
51 52 ];
52 - if (!empty($join)) $entityParams['join'] = $join;
53 - if (!empty($columnsToDisplay)) $entityParams['columns'] = $columnsToDisplay;
53 + if ($entity === 'list') {
54 + $entityParams['status'] = 'active';
55 + }
56 + if (!empty($join)) {
57 + $entityParams['join'] = $join;
58 + }
59 + if (!empty($columnsToDisplay)) {
60 + foreach ($columnsToDisplay as $column) {
61 + acym_secureDBColumn($column);
62 + }
63 + $entityParams['columns'] = $columnsToDisplay;
64 + }
54 65
55 66 if ('list' === $entity) {
56 67 $entityParams['columns'][] = 'description';
57 68 }
@@ -60,9 +71,9 @@
60 71 $entityParams['creator_id'] = acym_currentUserId();
61 72 }
62 73
63 74 $namespaceClass = 'AcyMailing\\Classes\\'.ucfirst($entity).'Class';
64 - $entityClass = new $namespaceClass;
75 + $entityClass = new $namespaceClass();
65 76
66 77 $availableEntity = $entityClass->getMatchingElements($entityParams);
67 78
68 79 $this->formatEntites($availableEntity, $entity);
@@ -69,19 +80,27 @@
69 80
70 81 return ['data' => empty($availableEntity) ? 'end' : $availableEntity];
71 82 }
72 83
73 - private function formatEntites(&$availableEntity, $entity)
84 + private function formatEntites(array &$availableEntity, string $entity): void
74 85 {
75 - if ($entity == 'list') {
86 + if ($entity === 'list') {
76 87 foreach ($availableEntity['elements'] as $key => $element) {
77 88 $availableEntity['elements'][$key]->color = '<i style="color: '.$element->color.'" class="acym_subscription acymicon-circle">';
78 - if (!empty($element->description)) $availableEntity['elements'][$key]->name = $element->name.acym_info($element->description);
89 + if (!empty($element->description)) {
90 + ob_start();
91 + acym_info(['textShownInTooltip' => $element->description]);
92 + $tooltip = ob_get_clean();
93 + $availableEntity['elements'][$key]->name = $element->name.$tooltip;
94 + }
79 95 }
80 - } elseif ($entity == 'user') {
96 + } elseif ($entity === 'user') {
81 97 foreach ($availableEntity['elements'] as $key => $element) {
82 - $availableEntity['elements'][$key]->email = $element->email.'<span class="acym__hover__user_info" data-id="'.$availableEntity['elements'][$key]->id.'">
83 - '.acym_info('<i class="acymicon-circle-o-notch acymicon-spin"></i>').'
98 + ob_start();
99 + acym_info(['textShownInTooltip' => '<i class="acymicon-circle-o-notch acymicon-spin"></i>']);
100 + $tooltip = ob_get_clean();
101 + $availableEntity['elements'][$key]->email = $element->email.'<span class="acym__hover__user_info" data-id="'.esc_attr($availableEntity['elements'][$key]->id).'">
102 + '.$tooltip.'
84 103 </span>';
85 104 }
86 105 }
87 106 }