-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathlib.php
More file actions
141 lines (60 loc) · 2.35 KB
/
Copy pathlib.php
File metadata and controls
141 lines (60 loc) · 2.35 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
function isReceivingFollowupPosts($sid)
{
global $wpdb;
//fetch all the post series subscriptions of this subscriber
$query = "SELECT * FROM ".$wpdb->prefix."wpr_followup_subscription where sid=$sid;";
$results = $wpdb->get_results($query);
if (count($results) ==0)
return;
//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
$aid = $subscription->eid;
$query = "SELECT count(*) num FROM ".$wpdb->prefix."wpr_autoresponder_messages where aid = $aid";
$results = $wpdb->get_results($query);
$numberOfEmailsInAutoresponder = $results[0]->num;
//get the number of the last email that was sent
$numberOfLastEmailSent = $subscription->sequence;
//if equal then return true else return false.
return $numberOfLastEmailSent == $numberOfEmailsInAutoresponder;
}