-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.php
112 lines (56 loc) · 1.95 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
function isReceivingFollowupPosts($sid)
{
global $wpdb;
//fetch all the post series subscriptions of this subscriber
$query = "SELECT * FROM ".$wpdb->prefix."wpr_followup_subscriptions where sid=$sid;";
$results = $wpdb->get_results($query);
if (count($results) ==0)
return false;
//for each post series or follow up series subscription, check if it is active
foreach ($results as $subscription)
{
if ($subscription->type == 'postseries')
{
return isPostSeriesSubscriptionActive($subscription);
}
else if ($subscription->type == 'autoresponder')
{
return isAutoresponderSeriesActive($subscription);
}
}
}
/*
* This function checks if the subscription
*/
function isPostSeriesSubscriptionActive($subscription)
{
global $wpdb;
//get number of posts in the category
//get the post series
$pid= $subscription->eid;
$query = "SELECT * FROM ".$wpdb->prefix."wpr_blog_series where id=$pid";
$results = $wpdb->get_results($query);
if (count($results) != 1)
{
return;
}
//get the category id
$catId = $results[0]->catid;
//get the number of posts in that category
$postsInCategory = get_posts("category=$catId");
$numberOfPosts = count($postsInCategory);
//get the number of the last post that was delivered.
// get the sequence number - the number of the last post that was delivered
//if equal return yes otherwise return false.
return ($subscription->sequence+1 < $numberOfPosts);
}
function isAutoresponderSeriesActive($subscription)
{
global $wpdb;
//get the number of emails in the follow up series
if (-2== intval($subscriptoin->eid))
return false;
else
return true;
}