예제 #1
0
 public function getSubscribersForDelivery(AutoresponderMessage $message, DateTime $time)
 {
     global $wpdb;
     $offsetDay = $message->getDayNumber();
     $getSubscribersForDeliveryForMessageQuery = sprintf("SELECT SS.* FROM `{$wpdb->prefix}wpr_followup_subscriptions` `ASU`, {$wpdb->prefix}wpr_subscribers SS WHERE SS.id=ASU.sid AND FLOOR((%d-ASU.doc)/86400) = %d", $time->getTimestamp(), $offsetDay);
     $results = $wpdb->get_results($getSubscribersForDeliveryForMessageQuery);
     return $results;
 }
 private function deliver($subscriber, AutoresponderMessage $message, DateTime $time)
 {
     global $wpdb, $javelinQueue;
     $params = array('meta_key' => sprintf('AR-%d-%d-%d-%d', $message->getAutoresponder()->getId(), $subscriber->sid, $message->getId(), $message->getDayNumber()), 'htmlbody' => $message->getHTMLBody(), 'textbody' => $message->getTextBody(), 'subject' => $message->getSubject());
     $subscriber_object = new Subscriber($subscriber->sid);
     $javelinQueue->enqueue($subscriber_object, $params);
     $updateSubscriptionMarkingItAsProcessedForCurrentDay = sprintf("UPDATE %swpr_followup_subscriptions SET sequence=%d, last_date=%d WHERE id=%d", $wpdb->prefix, $message->getDayNumber(), strtotime($time->format("Y-m-d H:i:s")), $subscriber->id);
     $wpdb->query($updateSubscriptionMarkingItAsProcessedForCurrentDay);
 }