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/dynamics/sendinblue/users.php +12 -5 10.0.1 → 11.1.0 View file →
@@ -4,10 +4,11 @@
4 4
5 5 class SendinblueUsers extends SendinblueClass
6 6 {
7 7 const MAX_USERS_IMPORT_NB = 5000;
8 - var $list;
9 8
9 + private SendinblueList $list;
10 +
10 11 public function __construct(&$plugin, $headers, $list)
11 12 {
12 13 parent::__construct($plugin, $headers);
13 14 $this->list = $list;
@@ -48,10 +49,13 @@
48 49 $message = acym_translation('ACYM_ERROR_CREATING_EXPORT_FILE');
49 50 acym_logError($message, 'sendinblue');
50 51 if ($ajax) {
51 52 acym_sendAjaxResponse($message, [], false);
52 - } else {
53 - acym_enqueueMessage($message, 'error');
53 + $notification = [
54 + 'name' => 'error_creating_export_file',
55 + 'removable' => 1,
56 + ];
57 + acym_enqueueMessage($message, 'error', false, [$notification]);
54 58 }
55 59
56 60 return;
57 61 }
@@ -106,8 +110,9 @@
106 110 }
107 111
108 112 private function sendUsers($listId)
109 113 {
114 + // Call API to import
110 115 $data = [
111 116 'fileUrl' => ACYM_TMP_URL.plgAcymSendinblue::SENDING_METHOD_ID.'.txt',
112 117 'listIds' => [$listId],
113 118 'updateExistingContacts' => true,
@@ -113,8 +118,9 @@
113 118 'updateExistingContacts' => true,
114 119 ];
115 120
116 121 $response = $this->callApiSendingMethod('contacts/import', $data, $this->headers, 'POST');
122 + //TODO delete the import file to avoid leaking user data
117 123
118 124 if (!empty($response['error_curl'])) {
119 125 $this->errors[] = acym_translationSprintf('ACYM_ERROR_OCCURRED_WHILE_CALLING_API', $response['error_curl']);
120 126 } elseif (!empty($response['code']) && !empty($response['message'])) {
@@ -148,9 +154,9 @@
148 154 $added = $this->addAttribute($existingAttributes, $subjectAttributeName);
149 155 $added = $this->addAttribute($existingAttributes, $contentAttributeName) || $added;
150 156
151 157 if ($added) {
152 - $this->config->save(['sendinblue_attributes' => json_encode($existingAttributes)]);
158 + $this->config->saveConfig(['sendinblue_attributes' => json_encode($existingAttributes)]);
153 159 }
154 160 }
155 161
156 162 private function addAttribute(&$existingAttributes, $attributeName): bool
@@ -252,9 +258,9 @@
252 258 $removedAnAttribute = $this->removeAttribute($existingAttributes, $subjectAttributeName);
253 259 $removedAnAttribute = $this->removeAttribute($existingAttributes, $contentAttributeName) || $removedAnAttribute;
254 260
255 261 if ($removedAnAttribute) {
256 - $this->config->save(['sendinblue_attributes' => json_encode($existingAttributes)]);
262 + $this->config->saveConfig(['sendinblue_attributes' => json_encode($existingAttributes)]);
257 263 }
258 264 }
259 265
260 266 private function removeAttribute(&$existingAttributes, $attributeName): bool
@@ -269,8 +275,9 @@
269 275 }
270 276
271 277 public function synchronizeExistingUsers()
272 278 {
279 + // Generate file with user to import
273 280 $userClass = new UserClass();
274 281 $users = $userClass->getAllSimpleData();
275 282 if (empty($users)) {
276 283 acym_sendAjaxResponse(acym_translation('ACYM_NO_USER_TO_SYNCHRONIZE'));