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