PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/component/class-recipients.php +42 -25 6.1.0 → 6.3.0 View file →
@@ -56,9 +56,9 @@
56 56 $module_map
57 57 );
58 58 $this->unsubscribe_recipient_from_modules( $unsubscribed, $key, $in_house, $module_map );
59 59
60 - if ( ! empty( $saved_models ) ) {
60 + if ( array() !== $saved_models ) {
61 61 if ( 1 === count( $saved_models ) ) {
62 62 $this->notification->send_email( $subscriber, $saved_models[0]->export() );
63 63 } else {
64 64 $this->notification->send_invite_all_email( $subscriber, $saved_models );
@@ -137,11 +137,14 @@
137 137 if ( $in_house && 0 === $user_id ) {
138 138 return false;
139 139 }
140 140
141 - $group = $in_house ? 'in_house_recipients' : 'out_house_recipients';
142 - if ( isset( $model->{$group}[ $key ] ) ) {
143 - $changed = $this->update_existing_recipient( $model, $group, $key, $name );
141 + $exists = $in_house
142 + ? isset( $model->in_house_recipients[ $key ] )
143 + : isset( $model->out_house_recipients[ $key ] );
144 +
145 + if ( $exists ) {
146 + $changed = $this->update_existing_recipient( $model, $in_house, $key, $name );
144 147 if ( $in_house ) {
145 148 $this->maybe_update_wp_user_profile( $user_id, $name, $subscriber );
146 149 }
147 150
@@ -147,27 +150,27 @@
147 150
148 151 return $changed;
149 152 }
150 153
151 - $list = $model->{$group};
152 -
153 154 if ( $in_house ) {
154 - $list[ $key ] = array(
155 + $list = $model->in_house_recipients;
156 + $list[ $key ] = array(
155 157 'id' => $user_id,
156 158 'name' => $name,
157 159 'email' => $key,
158 160 'status' => Model_Notification::USER_SUBSCRIBE_NA,
159 161 );
162 + $model->in_house_recipients = $list;
160 163 } else {
161 - $list[ $key ] = array(
164 + $list = $model->out_house_recipients;
165 + $list[ $key ] = array(
162 166 'name' => $name,
163 167 'email' => $key,
164 168 'status' => Model_Notification::USER_SUBSCRIBE_NA,
165 169 );
170 + $model->out_house_recipients = $list;
166 171 }
167 172
168 - $model->{$group} = $list;
169 -
170 173 return true;
171 174 }
172 175
173 176 /**
@@ -172,27 +175,36 @@
172 175
173 176 /**
174 177 * Update an existing recipient record in one module.
175 178 *
176 - * @param Model_Notification $model Notification model.
177 - * @param string $group Recipient group property.
178 - * @param string $key Recipient lookup key.
179 - * @param string $name Recipient display name.
179 + * @param Model_Notification $model Notification model.
180 + * @param bool $in_house Whether the recipient is a WordPress user.
181 + * @param string $key Recipient lookup key.
182 + * @param string $name Recipient display name.
180 183 * @return bool Whether the recipient data changed.
181 184 */
182 - private function update_existing_recipient( Model_Notification $model, string $group, string $key, string $name ): bool {
183 - $changed = false;
185 + private function update_existing_recipient( Model_Notification $model, bool $in_house, string $key, string $name ): bool {
186 + $changed = false;
187 + $recipients = $in_house ? $model->in_house_recipients : $model->out_house_recipients;
184 188
185 - if ( $model->{$group}[ $key ]['name'] !== $name ) {
186 - $model->{$group}[ $key ]['name'] = $name;
187 - $changed = true;
189 + if ( $recipients[ $key ]['name'] !== $name ) {
190 + $recipients[ $key ]['name'] = $name;
191 + $changed = true;
188 192 }
189 193
190 - if ( Model_Notification::USER_SUBSCRIBE_CANCELED === $model->{$group}[ $key ]['status'] ) {
191 - $model->{$group}[ $key ]['status'] = Model_Notification::USER_SUBSCRIBE_NA;
192 - $changed = true;
194 + if ( Model_Notification::USER_SUBSCRIBE_CANCELED === $recipients[ $key ]['status'] ) {
195 + $recipients[ $key ]['status'] = Model_Notification::USER_SUBSCRIBE_NA;
196 + $changed = true;
193 197 }
194 198
199 + if ( $changed ) {
200 + if ( $in_house ) {
201 + $model->in_house_recipients = $recipients;
202 + } else {
203 + $model->out_house_recipients = $recipients;
204 + }
205 + }
206 +
195 207 return $changed;
196 208 }
197 209
198 210 /**
@@ -210,10 +222,11 @@
210 222 if ( ! $model instanceof Model_Notification ) {
211 223 continue;
212 224 }
213 225
214 - $group = $in_house ? 'in_house_recipients' : 'out_house_recipients';
215 - $recipient = $model->$group[ $key ] ?? null;
226 + $recipient = $in_house
227 + ? ( $model->in_house_recipients[ $key ] ?? null )
228 + : ( $model->out_house_recipients[ $key ] ?? null );
216 229
217 230 if (
218 231 ! is_array( $recipient )
219 232 || Model_Notification::USER_SUBSCRIBE_CANCELED === $recipient['status']
@@ -220,9 +233,13 @@
220 233 ) {
221 234 continue;
222 235 }
223 236
224 - $model->{$group}[ $key ]['status'] = Model_Notification::USER_SUBSCRIBE_CANCELED;
237 + if ( $in_house ) {
238 + $model->in_house_recipients[ $key ]['status'] = Model_Notification::USER_SUBSCRIBE_CANCELED;
239 + } else {
240 + $model->out_house_recipients[ $key ]['status'] = Model_Notification::USER_SUBSCRIBE_CANCELED;
241 + }
225 242 $model->save();
226 243 $this->notification->send_unsubscribe_email( $model, $recipient['email'], $in_house, $recipient['name'] );
227 244 }
228 245 }