PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.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 10.3.0 10.4.0 All 60 releases
acymailing / back / Controllers / UsersController.php

UsersController.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.0, at back/Controllers/UsersController.php

93 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers;
4
5 use AcyMailing\Classes\UserClass;
6 use AcyMailing\Core\AcymController;
7 use AcyMailing\Controllers\Users\Listing;
8 use AcyMailing\Controllers\Users\Edition;
9 use AcyMailing\Controllers\Users\Import;
10 use AcyMailing\Controllers\Users\Export;
11 use AcyMailing\Controllers\Users\Subscription;
12
13 class UsersController extends AcymController
14 {
15 use Listing;
16 use Edition;
17 use Import;
18 use Export;
19 use Subscription;
20
21 public function __construct()
22 {
23 parent::__construct();
24
25 $this->breadcrumb[acym_translation('ACYM_SUBSCRIBERS')] = acym_completeLink('users');
26 $this->loadScripts = [
27 'edit' => ['datepicker'],
28 'all' => ['vue-applications' => ['entity_select']],
29 ];
30 }
31
32 public function getAll(): array
33 {
34 $userClass = new UserClass();
35
36 return $userClass->getAll();
37 }
38
39 public function clean(): void
40 {
41 if (acym_isAcyCheckerInstalled()) {
42 if (ACYM_CMS === 'joomla') {
43 acym_redirect(acym_route('index.php?option=com_acychecker', false));
44 } else {
45 acym_redirect(admin_url().'admin.php?page=acychecker_dashboard');
46 }
47 } else {
48 acym_redirect(acym_completeLink('dashboard&task=acychecker', false, true));
49 }
50 }
51
52 public function getUserInfoAjax(): void
53 {
54 $userId = acym_getVar('int', 'userId', 0);
55
56 if (empty($userId)) {
57 acym_sendAjaxResponse(acym_translation('ACYM_USER_NOT_FOUND'), [], false);
58 }
59
60 $userClass = new UserClass();
61 $user = $userClass->getCustomFieldValueById($userId);
62
63 if (empty($user)) {
64 acym_sendAjaxResponse(acym_translation('ACYM_SUBSCRIBER_NOT_CUSTOM_FIELD'), [], false);
65 }
66
67 acym_sendAjaxResponse('', $user);
68 }
69
70 /**
71 * Search user emails to suggest (autocomplete on send a test)
72 * Users without access will not see autocomplete results, they can still type emails manually
73 */
74 public function searchTestReceiversAjax(): void
75 {
76 if (!acym_isAllowed('users')) {
77 echo json_encode([]);
78 exit;
79 }
80
81 $search = acym_getVar('string', 'search', '');
82 $userClass = new UserClass();
83 $users = $userClass->getUsersLikeEmail($search);
84
85 $return = [];
86 foreach ($users as $oneUser) {
87 $return[] = [$oneUser->id, $oneUser->email];
88 }
89 echo json_encode($return);
90 exit;
91 }
92 }
93