Add space between if and ‘(‘
[MAILPOET-1791]
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
namespace MailPoet\Models;
|
||||
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class SubscriberSegment extends Model {
|
||||
public static $_table = MP_SUBSCRIBER_SEGMENT_TABLE;
|
||||
@ -12,7 +12,7 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
static function unsubscribeFromSegments($subscriber, $segment_ids = array()) {
|
||||
if($subscriber === false) return false;
|
||||
if ($subscriber === false) return false;
|
||||
|
||||
// Reset confirmation emails count, so user can resubscribe
|
||||
$subscriber->count_confirmations = 0;
|
||||
@ -21,18 +21,18 @@ class SubscriberSegment extends Model {
|
||||
$wp_segment = Segment::getWPSegment();
|
||||
$wc_segment = Segment::getWooCommerceSegment();
|
||||
|
||||
if(!empty($segment_ids)) {
|
||||
if (!empty($segment_ids)) {
|
||||
// unsubscribe from segments
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
|
||||
// do not remove subscriptions to the WP Users or WooCommerce Customers segments
|
||||
if(($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id)
|
||||
if (($wp_segment !== false && (int)$wp_segment->id === (int)$segment_id)
|
||||
|| ($wc_segment !== false && (int)$wc_segment->id === (int)$segment_id)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if((int)$segment_id > 0) {
|
||||
if ((int)$segment_id > 0) {
|
||||
self::createOrUpdate(array(
|
||||
'subscriber_id' => $subscriber->id,
|
||||
'segment_id' => $segment_id,
|
||||
@ -44,12 +44,12 @@ class SubscriberSegment extends Model {
|
||||
// unsubscribe from all segments (except the WP users and WooCommerce customers segments)
|
||||
$subscriptions = self::where('subscriber_id', $subscriber->id);
|
||||
|
||||
if($wp_segment !== false) {
|
||||
if ($wp_segment !== false) {
|
||||
$subscriptions = $subscriptions->whereNotEqual(
|
||||
'segment_id', $wp_segment->id
|
||||
);
|
||||
}
|
||||
if($wc_segment !== false) {
|
||||
if ($wc_segment !== false) {
|
||||
$subscriptions = $subscriptions->whereNotEqual(
|
||||
'segment_id', $wc_segment->id
|
||||
);
|
||||
@ -63,7 +63,7 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
static function resubscribeToAllSegments($subscriber) {
|
||||
if($subscriber === false) return false;
|
||||
if ($subscriber === false) return false;
|
||||
// (re)subscribe to all segments linked to the subscriber
|
||||
return self::where('subscriber_id', $subscriber->id)
|
||||
->findResultSet()
|
||||
@ -72,11 +72,11 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
static function subscribeToSegments($subscriber, $segment_ids = array()) {
|
||||
if($subscriber === false) return false;
|
||||
if(!empty($segment_ids)) {
|
||||
if ($subscriber === false) return false;
|
||||
if (!empty($segment_ids)) {
|
||||
// subscribe to specified segments
|
||||
foreach ($segment_ids as $segment_id) {
|
||||
if((int)$segment_id > 0) {
|
||||
if ((int)$segment_id > 0) {
|
||||
self::createOrUpdate(array(
|
||||
'subscriber_id' => $subscriber->id,
|
||||
'segment_id' => $segment_id,
|
||||
@ -97,7 +97,7 @@ class SubscriberSegment extends Model {
|
||||
$subscriber_ids = array(),
|
||||
$segment_ids = array()
|
||||
) {
|
||||
if(empty($subscriber_ids) || empty($segment_ids)) {
|
||||
if (empty($subscriber_ids) || empty($segment_ids)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
static function deleteManySubscriptions($subscriber_ids = array(), $segment_ids = array()) {
|
||||
if(empty($subscriber_ids)) return false;
|
||||
if (empty($subscriber_ids)) return false;
|
||||
|
||||
// delete subscribers' relations to segments (except WP and WooCommerce segments)
|
||||
$subscriptions = self::whereIn(
|
||||
@ -132,18 +132,18 @@ class SubscriberSegment extends Model {
|
||||
|
||||
$wp_segment = Segment::getWPSegment();
|
||||
$wc_segment = Segment::getWooCommerceSegment();
|
||||
if($wp_segment !== false) {
|
||||
if ($wp_segment !== false) {
|
||||
$subscriptions = $subscriptions->whereNotEqual(
|
||||
'segment_id', $wp_segment->id
|
||||
);
|
||||
}
|
||||
if($wc_segment !== false) {
|
||||
if ($wc_segment !== false) {
|
||||
$subscriptions = $subscriptions->whereNotEqual(
|
||||
'segment_id', $wc_segment->id
|
||||
);
|
||||
}
|
||||
|
||||
if(!empty($segment_ids)) {
|
||||
if (!empty($segment_ids)) {
|
||||
$subscriptions = $subscriptions->whereIn('segment_id', $segment_ids);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
static function deleteSubscriptions($subscriber, $segment_ids = array()) {
|
||||
if($subscriber === false) return false;
|
||||
if ($subscriber === false) return false;
|
||||
|
||||
$wp_segment = Segment::getWPSegment();
|
||||
$wc_segment = Segment::getWooCommerceSegment();
|
||||
@ -159,7 +159,7 @@ class SubscriberSegment extends Model {
|
||||
$subscriptions = self::where('subscriber_id', $subscriber->id)
|
||||
->whereNotIn('segment_id', [$wp_segment->id, $wc_segment->id]);
|
||||
|
||||
if(!empty($segment_ids)) {
|
||||
if (!empty($segment_ids)) {
|
||||
$subscriptions = $subscriptions->whereIn('segment_id', $segment_ids);
|
||||
}
|
||||
return $subscriptions->deleteMany();
|
||||
@ -171,7 +171,7 @@ class SubscriberSegment extends Model {
|
||||
|
||||
static function createOrUpdate($data = array()) {
|
||||
$keys = false;
|
||||
if(isset($data['subscriber_id']) && isset($data['segment_id'])) {
|
||||
if (isset($data['subscriber_id']) && isset($data['segment_id'])) {
|
||||
$keys = array(
|
||||
'subscriber_id' => (int)$data['subscriber_id'],
|
||||
'segment_id' => (int)$data['segment_id']
|
||||
|
Reference in New Issue
Block a user