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/Controllers/MailboxActions/Edition.php +29 -19 10.2.2 → 11.1.0 View file →
@@ -62,26 +62,12 @@
62 62
63 63 acym_trigger('onAcymMailboxActionDefine', [&$actions]);
64 64
65 65 $actionOptions = ['' => acym_translation('ACYM_CHOOSE_ACTION')];
66 - $actionParameters = '';
67 -
68 66 foreach ($actions as $key => $oneAction) {
69 67 $actionOptions[$key] = $oneAction->name;
70 - $actionParameters .= '<div class="acym__mailbox__edition__action__one__parameters '.$key.' margin-top-1">'.$oneAction->option.'</div>';
71 68 }
72 69
73 - $initialAction = acym_select(
74 - $actionOptions,
75 - 'acym_action[__num__][action]',
76 - '',
77 - [
78 - 'class' => 'acym__select acym__mailbox__edition__action__one__choice',
79 - 'acym-data-infinite' => '',
80 - ]
81 - );
82 - $initialAction .= $actionParameters;
83 -
84 70 $data = [
85 71 'mailboxId' => $mailboxId,
86 72 'mailboxActions' => $mailboxAction,
87 73 'delayType' => new DelayType(),
@@ -86,9 +72,10 @@
86 72 'mailboxActions' => $mailboxAction,
87 73 'delayType' => new DelayType(),
88 74 'groups' => acym_getGroups(),
89 75 'lists' => $listsClass->getAllWithIdName(),
90 - 'initialAction' => $initialAction,
76 + 'actionDeclarations' => $actions,
77 + 'actionOptions' => $actionOptions,
91 78 ];
92 79
93 80 parent::display($data);
94 81 }
@@ -106,8 +93,10 @@
106 93 }
107 94
108 95 public function storeMailboxAction(): void
109 96 {
97 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
98 +
110 99 $mailbox = acym_getVar('array', 'mailbox', []);
111 100 $mailboxClass = new MailboxClass();
112 101 $mailboxObject = new \stdClass();
113 102
@@ -146,8 +135,10 @@
146 135 }
147 136
148 137 public function testMailboxAction(): void
149 138 {
139 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
140 +
150 141 $mailbox = acym_getVar('array', 'mailbox', []);
151 142
152 143 if (empty($mailbox)) {
153 144 acym_sendAjaxResponse(acym_translation('ACYM_NO_CONFIGURATION'), [], false);
@@ -154,19 +145,28 @@
154 145 }
155 146
156 147 $mailbox = (object)$mailbox;
157 148
149 + // If this is not a new mailbox or if it is not from the configuration menu, we need to get the password from the database
158 150 if (!empty($mailbox->id)) {
159 151 if ($mailbox->id !== 'configuration') {
152 + // We check if the password has not changed
160 153 if (empty(trim($mailbox->password, '*'))) {
161 154 $mailboxClass = new MailboxClass();
162 155 $mailboxFromDatabase = $mailboxClass->getOneById($mailbox->id);
163 - $mailbox->password = $mailboxFromDatabase->password;
156 + if (!empty($mailboxFromDatabase) && $this->isSameMailboxHost($mailbox->server ?? '', $mailboxFromDatabase->server)) {
157 + $mailbox->password = $mailboxFromDatabase->password;
158 + }
164 159 }
165 160 } elseif (empty(trim($mailbox->password, '*'))) {
166 - $mailbox->password = $this->config->get('bounce_password');
167 - $mailbox->bounce_access_token = str_replace('Bearer ', '', $this->config->get('bounce_access_token', ''));
168 - $mailbox->connection_method = $this->config->get('connection_method', 'imap');
161 + // If it comes from the configuration menu, we need to get the password from the config table (not the mailbox_action table)
162 + if ($this->isSameMailboxHost($mailbox->server ?? '', $this->config->get('bounce_server'))) {
163 + $mailbox->password = $this->config->get('bounce_password');
164 + $mailbox->bounce_access_token = str_replace('Bearer ', '', $this->config->get('bounce_access_token', ''));
165 + if (empty($mailbox->connection_method)) {
166 + $mailbox->connection_method = $this->config->get('connection_method', 'imap');
167 + }
168 + }
169 169 }
170 170 }
171 171
172 172 $mailboxHelper = new MailboxHelper();
@@ -180,6 +180,16 @@
180 180 acym_sendAjaxResponse(acym_translation('ACYM_CONNECTION_FAILED'), ['report' => $this->mailboxReport], false);
181 181 } else {
182 182 acym_sendAjaxResponse(acym_translation('ACYM_CONNECTION_SUCCESSFUL'));
183 183 }
184 + }
185 +
186 + private function isSameMailboxHost($submittedServer, $storedServer): bool
187 + {
188 + $storedServer = trim((string)$storedServer);
189 + if ($storedServer === '') {
190 + return false;
191 + }
192 +
193 + return strcasecmp(trim((string)$submittedServer), $storedServer) === 0;
184 194 }
185 195 }