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/Users/Subscription.php +0 -138 10.11.1 → 11.1.1 View file →
@@ -1,138 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Users;
4 -
5 -use AcyMailing\Classes\UserClass;
6 -
7 -trait Subscription
8 -{
9 - public function resetSubscription(): void
10 - {
11 - $userId = acym_getVar('int', 'userId');
12 -
13 - if (empty($userId)) {
14 - $this->listing();
15 -
16 - return;
17 - }
18 -
19 - $userClass = new UserClass();
20 - if (!$userClass->hasUserAccess($userId)) {
21 - die('Access denied for subscription reset of this user');
22 - }
23 -
24 - $lists = json_decode(acym_getVar('string', 'acym__entity_select__selected', '[]'), true);
25 - if (empty($lists)) {
26 - $lists = [];
27 - }
28 - $userClass->resetSubscription([$userId], $lists);
29 -
30 - $this->edit();
31 - }
32 -
33 - public function unsubscribeUser(): void
34 - {
35 - $userId = acym_getVar('int', 'userId');
36 - if (empty($userId)) {
37 - $this->listing();
38 -
39 - return;
40 - }
41 -
42 - $userClass = new UserClass();
43 - if (!$userClass->hasUserAccess($userId)) {
44 - die('Access denied for unsubscribing this user');
45 - }
46 -
47 - $lists = json_decode(acym_getVar('string', 'acym__entity_select__selected', '[]'), true);
48 - if (empty($lists)) {
49 - $lists = [];
50 - }
51 - $userClass->unsubscribe([$userId], $lists);
52 -
53 - $this->edit();
54 - }
55 -
56 - public function unsubscribeUserFromAll(): void
57 - {
58 - $userId = acym_getVar('int', 'userId');
59 -
60 - if (empty($userId)) {
61 - $this->listing();
62 -
63 - return;
64 - }
65 -
66 - $userClass = new UserClass();
67 - if (!$userClass->hasUserAccess($userId)) {
68 - die('Access denied for unsubscribing this user');
69 - }
70 -
71 - $lists = [];
72 - $subscriptions = $userClass->getSubscriptionStatus($userId);
73 - foreach ($subscriptions as $i => $oneList) {
74 - if ($oneList->status == 1) {
75 - $lists[] = $oneList->list_id;
76 - }
77 - }
78 -
79 - $userClass->unsubscribe([$userId], $lists);
80 -
81 - $this->edit();
82 - }
83 -
84 - public function resubscribeUserToAll(): void
85 - {
86 - $userId = acym_getVar('int', 'userId');
87 - if (empty($userId)) {
88 - $this->listing();
89 -
90 - return;
91 - }
92 -
93 - $userClass = new UserClass();
94 - if (!$userClass->hasUserAccess($userId)) {
95 - die('Access denied for resubscribing this user');
96 - }
97 -
98 - $lists = [];
99 - $subscriptions = $userClass->getSubscriptionStatus($userId);
100 - foreach ($subscriptions as $i => $oneList) {
101 - if ($oneList->status == 0) {
102 - $lists[] = $oneList->list_id;
103 - }
104 - }
105 -
106 - $userClass->subscribe([$userId], $lists);
107 -
108 - $this->edit();
109 - }
110 -
111 - public function subscribeUser(bool $returnOnEdit = true, array $lists = [], bool $frontCreation = false): void
112 - {
113 - $userId = acym_getVar('int', 'userId');
114 - if (empty($userId)) {
115 - $this->listing();
116 -
117 - return;
118 - }
119 -
120 - $userClass = new UserClass();
121 - if (!$frontCreation && !$userClass->hasUserAccess($userId)) {
122 - die('Access denied for subscribing this user');
123 - }
124 -
125 - if (empty($lists)) {
126 - $lists = json_decode(acym_getVar('string', 'acym__entity_select__selected', '[]'), true);
127 - if (empty($lists)) {
128 - $lists = [];
129 - }
130 - }
131 -
132 - $userClass->subscribe([$userId], $lists);
133 -
134 - if ($returnOnEdit) {
135 - $this->edit();
136 - }
137 - }
138 -}