PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
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 +0 -88 10.0.1 → 11.1.1 View file →
@@ -1,88 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers;
4 -
5 -use AcyMailing\Helpers\EntitySelectHelper;
6 -use AcyMailing\Core\AcymController;
7 -
8 -class EntitySelectController extends AcymController
9 -{
10 - var $entitySelectHelper;
11 -
12 - public function __construct()
13 - {
14 - parent::__construct();
15 - $this->entitySelectHelper = new EntitySelectHelper();
16 - $this->loadScripts = [
17 - 'all' => ['vue-applications' => ['entity_select']],
18 - ];
19 - }
20 -
21 - public function loadEntityFront()
22 - {
23 - $entity = acym_getVar('string', 'entity');
24 - $offset = acym_getVar('int', 'offset');
25 - $perCalls = acym_getVar('int', 'perCalls');
26 - $join = acym_getVar('string', 'join');
27 - $joinColumnGet = acym_getVar('string', 'join_table', '');
28 - $columnsToDisplay = explode(',', acym_getVar('string', 'columns', ''));
29 - if (!empty($joinColumnGet)) {
30 - $columnsToDisplay['join'] = $joinColumnGet;
31 - }
32 -
33 - $entityBack = $this->loadEntityBack($entity, $offset, $perCalls, $join, $columnsToDisplay);
34 - if (!empty($entityBack['error'])) {
35 - acym_sendAjaxResponse($entityBack['error'], [], false);
36 - } else {
37 - acym_sendAjaxResponse('', ['results' => $entityBack]);
38 - }
39 - }
40 -
41 - private function loadEntityBack($entity, $offset, $perCalls, $join, $columnsToDisplay): array
42 - {
43 - if (empty($entity) || (empty($offset) && 0 !== $offset) || empty($perCalls)) {
44 - return ['error' => acym_translation('ACYM_MISSING_PARAMETERS')];
45 - }
46 -
47 - $entityParams = [
48 - 'offset' => $offset,
49 - 'elementsPerPage' => $perCalls,
50 - 'entitySelect' => true,
51 - ];
52 - if (!empty($join)) $entityParams['join'] = $join;
53 - if (!empty($columnsToDisplay)) $entityParams['columns'] = $columnsToDisplay;
54 -
55 - if ('list' === $entity) {
56 - $entityParams['columns'][] = 'description';
57 - }
58 -
59 - if (!acym_isAdmin()) {
60 - $entityParams['creator_id'] = acym_currentUserId();
61 - }
62 -
63 - $namespaceClass = 'AcyMailing\\Classes\\'.ucfirst($entity).'Class';
64 - $entityClass = new $namespaceClass;
65 -
66 - $availableEntity = $entityClass->getMatchingElements($entityParams);
67 -
68 - $this->formatEntites($availableEntity, $entity);
69 -
70 - return ['data' => empty($availableEntity) ? 'end' : $availableEntity];
71 - }
72 -
73 - private function formatEntites(&$availableEntity, $entity)
74 - {
75 - if ($entity == 'list') {
76 - foreach ($availableEntity['elements'] as $key => $element) {
77 - $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);
79 - }
80 - } elseif ($entity == 'user') {
81 - 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>').'
84 - </span>';
85 - }
86 - }
87 - }
88 -}