PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
← All changes | modules/subscriptions/classes/Actions.php +15 -5 3.0.83.1.6 View file →
@@ -2,8 +2,10 @@
2 2
3 3 namespace wpforo\modules\subscriptions\classes;
4 4
5 5 class Actions {
6 + private $is_approval_context = false;
7 +
6 8 public function __construct() {
7 9 $this->init_hooks();
8 10 }
9 11
@@ -169,8 +171,9 @@
169 171 return false;
170 172 }
171 173
172 174 public function after_post_approve( $post ) {
175 + $this->is_approval_context = true;
173 176 if( (int) wpfval($post, 'is_first_post') ){
174 177 if( ($topicid = wpforo_bigintval(wpfval($post, 'topicid')))
175 178 && ($topic = WPF()->topic->get_topic( $topicid ))
176 179 && ($forumid = (int) wpfval($post, 'forumid'))
@@ -187,8 +190,9 @@
187 190 WPF()->sbscrb->Mentioning->Actions->send_mail_to_mentioned_users( $post, $topic );
188 191 $this->after_add_post( $post, $topic );
189 192 }
190 193 }
194 + $this->is_approval_context = false;
191 195 }
192 196
193 197 public function after_delete_topic( $topic ) {
194 198 if( wpfval( $topic, 'topicid' ) ) WPF()->sbscrb->delete( [ 'type' => 'topic', 'itemid' => $topic['topicid'] ] );
@@ -200,12 +204,12 @@
200 204
201 205 public function after_add_topic( $topic, $forum ) {
202 206 if( ! wpfval( $topic, 'url' ) ) $topic['url'] = wpforo_topic( $topic['topicid'], 'url' );
203 207 if( ! wpfkey( $topic, 'body' ) ) $topic['body'] = wpforo_post( $topic['first_postid'], 'body' );
204 -
208 +
205 209 $topic = apply_filters( 'wpforo_sbscrb_after_add_topic__topic_filter', $topic );
206 210 $forum = apply_filters( 'wpforo_sbscrb_after_add_topic__forum_filter', $forum );
207 -
211 +
208 212 $owner = wpforo_member( $topic );
209 213
210 214 $forums_sbs = WPF()->sbscrb->get_subscribes( [ 'itemid' => 0, 'type' => [ 'forums', 'forums-topics' ] ] );
211 215 $forum_sbs = WPF()->sbscrb->get_subscribes( [ 'itemid' => $topic['forumid'], 'type' => [ 'forum' , 'forum-topic' ] ] );
@@ -226,10 +230,13 @@
226 230 }
227 231
228 232 if( ! WPF()->topic->view_access( $topic, $user ) ) continue;
229 233
234 + if( $this->is_approval_context && WPF()->perm->forum_can( 'au', $topic['forumid'], wpfval( $user, 'groupids' ) ?: [] ) ) continue;
235 +
230 236 $unsubscribe_link = WPF()->sbscrb->get_unsubscribe_link( $subscriber['confirmkey'] );
231 237 } else {
238 + if( $this->is_approval_context ) continue;
232 239 $user = [ 'display_name' => $subscriber, 'user_email' => $subscriber ];
233 240 $unsubscribe_link = '';
234 241 }
235 242
@@ -245,9 +252,9 @@
245 252 if( wpforo_is_users_same( $owner, $user ) ) continue;
246 253 if( wpforo_is_users_same( $user ) ) continue;
247 254
248 255 $sbj_msg = WPF()->sbscrb->get_sbj_msg( 'new_topic', $forum, $topic, $owner, $user, $unsubscribe_link );
249 - wpforo_send_email( $user['user_email'], $sbj_msg['sbj'], $sbj_msg['msg'] );
256 + wpforo_send_email( $user['user_email'], $sbj_msg['sbj'], $sbj_msg['msg'], '', 'subscription', (int) $topic['topicid'] );
250 257
251 258 WPF()->ram_cache->set( $key, true );
252 259 }
253 260 }
@@ -256,9 +263,9 @@
256 263
257 264 public function after_add_post( $post, $topic ) {
258 265 $post = apply_filters( 'wpforo_sbscrb_after_add_post__post_filter', $post );
259 266 $topic = apply_filters( 'wpforo_sbscrb_after_add_post__topic_filter', $topic );
260 -
267 +
261 268 $owner = wpforo_member( $post );
262 269 $forums_sbs = WPF()->sbscrb->get_subscribes( [ 'itemid' => 0, 'type' => 'forums-topics' ] );
263 270 $forum_sbs = WPF()->sbscrb->get_subscribes( [ 'itemid' => $post['forumid'], 'type' => 'forum-topic' ] );
264 271 $topic_sbs = WPF()->sbscrb->get_subscribes( [ 'itemid' => $post['topicid'], 'type' => 'topic' ] );
@@ -279,10 +286,13 @@
279 286 }
280 287
281 288 if( ! WPF()->post->view_access( $post, $user ) ) continue;
282 289
290 + if( $this->is_approval_context && WPF()->perm->forum_can( 'au', $post['forumid'], wpfval( $user, 'groupids' ) ?: [] ) ) continue;
291 +
283 292 $unsubscribe_link = WPF()->sbscrb->get_unsubscribe_link( $subscriber['confirmkey'] );
284 293 } else {
294 + if( $this->is_approval_context ) continue;
285 295 $user = [ 'display_name' => $subscriber, 'user_email' => $subscriber ];
286 296 $unsubscribe_link = '';
287 297 }
288 298
@@ -297,9 +307,9 @@
297 307 if( wpforo_is_users_same( $owner, $user ) ) continue;
298 308 if( wpforo_is_users_same( $user ) ) continue;
299 309
300 310 $sbj_msg = WPF()->sbscrb->get_sbj_msg( 'new_post', $topic, $post, $owner, $user, $unsubscribe_link );
301 - wpforo_send_email( $user['user_email'], $sbj_msg['sbj'], $sbj_msg['msg'] );
311 + wpforo_send_email( $user['user_email'], $sbj_msg['sbj'], $sbj_msg['msg'], '', 'subscription', (int) $post['postid'] );
302 312
303 313 WPF()->ram_cache->set( $key, true );
304 314 }
305 315 }