本文整理汇总了PHP中Subscriber::getSubscriber方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber::getSubscriber方法的具体用法?PHP Subscriber::getSubscriber怎么用?PHP Subscriber::getSubscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber::getSubscriber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findSubscriber
/**
* Find which subscriber this message was sent to
* @param string $text
* @return bool|Subscriber
*/
private function findSubscriber($text)
{
$subscriber = false;
$subscriber_id = '';
preg_match('/X-ListMember: (.*)\\R/iU', $text, $match);
if (is_array($match) && isset($match[1])) {
$subscriber_id = trim($match[1]);
} else {
# older version use X-User
preg_match('/X-User: (.*)\\R/iU', $text, $match);
if (is_array($match) && isset($match[1])) {
$subscriber_id = trim($match[1]);
}
}
if ($subscriber_id != '') {
# some versions used the email to identify the subscribers, some the userid and others the uniqid
# use backward compatible way to find subscriber
if (strpos($subscriber_id, '@') !== false) {
$subscriber = Subscriber::getSubscriberByEmailAddress($subscriber_id);
} elseif (preg_match('/^\\d$/', $subscriber_id)) {
$subscriber = Subscriber::getSubscriber($subscriber_id);
} elseif (!empty($subscriber_id)) {
$subscriber = Subscriber::getSubscriberByUniqueId($subscriber_id);
}
}
if ($subscriber === false) {
### if we didn't find any, parse anything looking like an email address and check if it's a subscriber.
## this is probably fairly time consuming, but as the process is only done once every so often
## that should not be too bad
preg_match_all('/[\\S]+@[\\S\\.]+/', $text, $regs);
foreach ($regs[0] as $match) {
$subscriberObj = Subscriber::getSubscriberByEmailAddress(Util::cleanEmail($match));
if ($subscriberObj !== false) {
return $subscriberObj;
}
}
}
return $subscriber;
}
示例2: startProcessing
//.........这里部分代码省略.........
$this->counters['total_subscribers_for_campaign ' . $campaign->id] = $subscriberids_result->rowCount();
}
if (Config::MAILQUEUE_BATCH_SIZE > 0) {
## in case of sending multiple campaigns, reduce batch with "sent"
$this->num_per_batch -= $this->sent;
# send in batches of $this->num_per_batch subscribers
$batch_total = $this->counters['total_subscribers_for_campaign ' . $campaign->id];
if ($this->num_per_batch > 0) {
$subscriberids_query .= sprintf(' LIMIT 0,%d', $this->num_per_batch);
if (Config::VERBOSE) {
phpList::log()->debug($this->num_per_batch . ' query -> ' . $subscriberids_query, ['page' => 'porcessqueue']);
}
try {
$subscriberids_result = phpList::DB()->query($subscriberids_query);
} catch (\PDOException $e) {
$this->queueProcessError($e->getMessage());
}
} else {
phpList::log()->debug(s('No subscribers to process for this batch'), ['page' => 'porcessqueue']);
//TODO: Can we remove this pointless query (will have to change the while loop below)
$subscriberids_result = phpList::DB()->query(sprintf('SELECT * FROM %s WHERE id = 0', Config::getTableName('user')));
}
$affrows = $subscriberids_result->rowCount();
phpList::log()->debug(s('Processing batch of ') . ': ' . $affrows, ['page' => 'porcessqueue']);
}
while ($subscriberdata = $subscriberids_result->fetch()) {
$this->counters['processed_subscribers_for_campaign ' . $campaign->id]++;
$failure_reason = '';
if ($this->num_per_batch && $this->sent >= $this->num_per_batch) {
phpList::log()->debug(s('batch limit reached') . ": {$this->sent} ({$this->num_per_batch})", ['page' => 'porcessqueue']);
Config::setRunningConfig('wait', $this->batch_period);
return false;
}
$subscriber = Subscriber::getSubscriber($subscriberdata[0]);
# id of the subscriber
if ($output_speed_stats) {
phpList::log()->info('-----------------------------------' . "\n" . 'start process subscriber ' . $subscriber->id);
}
$some = 1;
set_time_limit(120);
$seconds_to_go = $finish_sending_before - time();
$stop_sending = $seconds_to_go < 0;
# check if we have been "killed"
# phpList::log()->debug('Process ID '.$this->send_process_id, ['page' => 'porcessqueue']);
$alive = Process::checkLock($this->send_process_id);
## check for max-process-queue-time
$elapsed = Timer::get('process_queue')->elapsed(true);
if ($restrictions['max_process_queue_time'] && $elapsed > $restrictions['max_process_queue_time'] && $this->sent > 0) {
phpList::log()->info(s('queue processing time has exceeded max processing time ') . $restrictions['max_process_queue_time'], ['page' => 'processqueue']);
break;
} elseif ($alive && !$stop_sending) {
Process::keepLock($this->send_process_id);
} elseif ($stop_sending) {
phpList::log()->debug(s('Campaign sending timed out, is past date to process until'), ['page' => 'porcessqueue']);
break;
} else {
$this->queueProcessError(s('Process Killed by other process'));
}
# check if the campaign we are working on is still there and in process
$campaign = Campaign::getCampaign($campaign->id);
if (empty($campaign)) {
$this->queueProcessError(s('Campaign I was working on has disappeared'));
} elseif ($campaign->status != 'inprocess') {
$this->queueProcessError(s('Sending of this campaign has been suspended'));
}
flush();