本文整理汇总了PHP中Subscriber类的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber类的具体用法?PHP Subscriber怎么用?PHP Subscriber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subscriber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run($arg)
{
// $last_working = Yii::app()->setting->getItem('last_working');
// if(!empty($last_working))
// {
// $timestampNext = strtotime(ActiveRecord::timeCalMinutes(-10));
// if(strtotime($last_working) > $timestampNext)
// {
//// Yii::log(strtotime($last_working), 'error', 'NewsletterCommand.run');
//// Yii::log($timestampNext, 'error', 'NewsletterCommand.run');
// echo 'waiting because last working is nearly';
// return;
// }
// }
$member = Users::model()->findAll('role_id = ' . ROLE_MEMBER);
if (count($member) > 0) {
foreach ($member as $item) {
$email = Subscriber::model()->find('email ="' . $item->email . '"');
if (count($email) == 0) {
$subcribe = new Subscriber();
$subcribe->email = $item->email;
$subcribe->name = $item->username;
$subcribe->subscriber_group_id = GROUP_MEMBER;
$subcribe->save();
}
}
}
//Yii::app()->setting->setDbItem('last_working', date('Y-m-d h:i:s'));
}
开发者ID:jasonhai,项目名称:onehome,代码行数:29,代码来源:AddSubcribeCommand.php
示例2: submitPlus
public function submitPlus(DataContainer $dc)
{
$subscriber = new Subscriber($dc->activeRecord->email);
$subscriber->setByDc($dc);
$cid = $dc->activeRecord->pid;
$time = time();
// set active
if ($dc->activeRecord->active == 1) {
$subscriber->activated = $time;
$subscriber->deactivated = '';
} else {
$subscriber->deactivated = $time;
}
if ($this->isCRActive($cid)) {
// new record - added manually --> call add() method
if (!$dc->activeRecord->addedOn && !$dc->activeRecord->tstamp) {
$subscriber->registered = $time;
$subscriber->addToCR();
}
// existing record - call update() method
if ($dc->activeRecord->tstamp) {
$subscriber->updateCR();
}
}
}
开发者ID:heimrichhannot,项目名称:contao-newsletter_plus,代码行数:25,代码来源:tl_newsletter_recipients.php
示例3: createNewUser
public function createNewUser($userId, $arrData)
{
$arrNewsletters = deserialize($arrData['newsletter'], true);
// Return if there are no newsletters
if (!is_array($arrNewsletters)) {
return;
}
$time = time();
// Add recipients
foreach ($arrNewsletters as $intNewsletter) {
$intNewsletter = intval($intNewsletter);
if ($intNewsletter < 1) {
continue;
}
$objRecipient = $this->Database->prepare("SELECT COUNT(*) AS total FROM tl_newsletter_recipients WHERE pid=? AND email=?")->execute($intNewsletter, $arrData['email']);
if ($objRecipient->total < 1) {
$subscriber = new Subscriber($arrData['email']);
$subscriber->tstamp = $time;
$subscriber->salutation = $arrData['gender'];
$subscriber->firstname = $arrData['firstname'];
$subscriber->lastname = $arrData['lastname'];
$subscriber->company = $arrData['company'];
$subscriber->addedOn = $time;
$subscriber->ip = $this->anonymizeIp($this->Environment->ip);
$subscriber->pid = $intNewsletter;
$subscriber->active = '';
$subscriber->token = '';
// account will get activated by registration token from registration E-Mail
$subscriber->registered = $time;
$subscriber->add();
}
}
}
开发者ID:heimrichhannot,项目名称:contao-newsletter_plus,代码行数:33,代码来源:NewsletterPlus.php
示例4: testUnsubscribeSubscribeByCustomerId
/**
* @magentoDataFixture Magento/Newsletter/_files/subscribers.php
* @magentoAppArea frontend
*/
public function testUnsubscribeSubscribeByCustomerId()
{
// Unsubscribe and verify
$this->assertSame($this->_model, $this->_model->unsubscribeCustomerById(1));
$this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->_model->getSubscriberStatus());
// Subscribe and verify
$this->assertSame($this->_model, $this->_model->subscribeCustomerById(1));
$this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->_model->getSubscriberStatus());
}
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:SubscriberTest.php
示例5: replaceCustomFieldValues
public static function replaceCustomFieldValues($string, Subscriber $subscriber)
{
$name = $subscriber->getName();
$string = str_replace("[!name!]", $name, $string);
$values = $subscriber->getCustomFieldValuesByLabels();
foreach ($values as $name => $value) {
$string = str_replace("[!{$name}!]", $value, $string);
}
return $string;
}
开发者ID:anirut,项目名称:wp-autoresponder,代码行数:10,代码来源:subscriber.php
示例6: _wpr_process_sendmail_parameters
function _wpr_process_sendmail_parameters($sid, $params, $footerMessage = "")
{
global $wpdb;
$subscriber = new Subscriber($sid);
$newsletter = _wpr_newsletter_get($subscriber->getNewsletterId());
//if the fromname field is set in the newsletter, then use that value otherwise use the blog name.
$fromname = !empty($params['fromname']) ? $params['fromname'] : !empty($newsletter->fromname) ? $newsletter->fromname : get_bloginfo("name");
if ($newsletter->reply_to) {
$replyto = $newsletter->reply_to;
}
$unsuburl = wpr_get_unsubscription_url($sid);
$subject = $params['subject'];
$address = get_option("wpr_address");
$textUnSubMessage = "\n\n{$address}\n\n" . __("To unsubscribe or change subscription options visit", 'wpr_autoresponder') . ":\r\n\r\n{$unsuburl}";
$reply_to = $newsletter->reply_to;
$htmlbody = trim($params['htmlbody']);
$textbody = $params['textbody'];
$subject = $params['subject'];
//append the address and the unsub link to the email
$address = "<br>\n<br>\n" . nl2br(get_option("wpr_address")) . "<br>\n<br>\n";
$htmlUnSubscribeMessage = "<br><br>" . $address . "<br><br>" . __("To unsubscribe or change subscriber options visit:", 'wpr_autoresponder') . "<br />\n\r\n <a href=\"{$unsuburl}\">{$unsuburl}</a>";
$htmlenabled = $params['htmlenabled'] ? 1 : 0;
if (!empty($htmlbody)) {
if ($footerMessage && !empty($htmlbody)) {
$htmlbody .= nl2br($footerMessage) . "<br>\n<br>\n";
}
if (strstr($htmlbody, "[!unsubscribe!]")) {
$htmlbody = str_replace("[!unsubscribe!]", $unsuburl, $htmlbody);
} else {
$htmlbody .= $htmlUnSubscribeMessage;
}
}
if ($footerMessage) {
$params['textbody'] .= $footerMessage . "\n\n";
}
if (strstr($params['textbody'], "[!unsubscribe!]")) {
$textbody = str_replace("[!unsubscribe!]", $unsuburl, $textbody);
} else {
$textbody = $params['textbody'] . $textUnSubMessage;
}
$textbody = addslashes($textbody);
$htmlbody = addslashes($htmlbody);
$subject = addslashes($subject);
$time = time();
$subject = str_replace("[!name!]", $subscriber->getName(), $subject);
$textbody = str_replace("[!name!]", $subscriber->getName(), $textbody);
$htmlbody = str_replace("[!name!]", $subscriber->getName(), $htmlbody);
$delivery_type = !empty($params['delivery_type']) ? $params['delivery_type'] : 0;
$email_type = !empty($params['email_type']) ? $params['email_type'] : 'misc';
$meta_key = !empty($params['meta_key']) ? $params['meta_key'] : "Misc-{$sid}-{$time}";
$hash = make_hash(array_merge(array('sid' => $sid), $params));
$from = !empty($params['fromemail']) ? $params['fromemail'] : !empty($newsletter->fromemail) ? $newsletter->fromemail : get_bloginfo('admin_email');
$parameters = array('from' => $from, 'fromname' => $fromname, 'to' => $subscriber->email, 'reply_to' => $reply_to, 'subject' => $subject, 'htmlbody' => $htmlbody, 'textbody' => $textbody, 'headers' => '', 'htmlenabled' => $htmlenabled, 'delivery_type' => $delivery_type, 'email_type' => $email_type, 'meta_key' => $meta_key, 'hash' => $hash);
return $parameters;
}
开发者ID:anirut,项目名称:wp-autoresponder,代码行数:55,代码来源:mail_functions.php
示例7: actionSend
public function actionSend($id)
{
$model = $this->loadModel($id);
if (isset($_POST['Massmail'])) {
$model->attributes = $_POST['Massmail'];
if (empty($model->groups)) {
$mailList = Subscriber::model()->findAll(array('condition' => 'confirmed=1 AND enabled=1'));
} else {
$mailList = Subscriber::model()->findAll(array('condition' => 'FIND_IN_SET(' . $model->groups . ', groups)>0 AND confirmed=1 AND enabled=1'));
}
$bccList = null;
$total = array_filter($mailList);
if (!empty($total)) {
//get email lists
foreach ($mailList as $values) {
$bccList .= $values['email'] . ',';
}
//send mail
$to = Yii::app()->params['adminEmail'];
$subject = $model->subject;
$message = $model->message_body;
$fromName = Yii::app()->params['Companyname'];
$fromMail = Yii::app()->params['adminEmail'];
Massmail::sendMail($to, $subject, $message, $fromName, $fromMail, $bccList);
Yii::app()->user->setFlash('success', 'Mail has been sent successfully!');
$this->redirect(array('admin'));
} else {
Yii::app()->user->setFlash('error', 'No subscriber found in this group!');
$this->redirect(array('admin'));
}
}
$this->render('send', array('model' => $model));
}
开发者ID:optimosolution,项目名称:jasorbd,代码行数:33,代码来源:MassmailController.php
示例8: getRecharge
public function getRecharge()
{
$accounts = Subscriber::where('is_admin', 0)->where(function ($query) {
$query->where('plan_type', PREPAID_PLAN)->orWhere('plan_type', FREE_PLAN);
})->orderby('uname')->lists('uname', 'id');
return View::make('admin.refill_coupons.recharge')->with('accounts', $accounts);
}
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:7,代码来源:RefillController.php
示例9: sendActivationMail
/**
* Send an email with an activation link to verify the subscriber is the owner of the email address.
*
* @throws InvalidArgumentException
* @throws Exception
*
* @return bool
*/
protected function sendActivationMail(Subscriber $subscriber)
{
try {
$from = sfNewsletterPluginConfiguration::getFromEmail();
$mailer = new Swift(new Swift_Connection_NativeMail());
$message = new Swift_Message(sfConfig::get('sf_newsletter_plugin_activation_mail_subject', 'Newsletter Subscription'), $this->getPartial('activation_mail', array('subscriber' => $subscriber)), 'text/html');
$sent = $mailer->send($message, $subscriber->getEmail(), $from);
$mailer->disconnect();
return $sent === 1;
} catch (Exception $e) {
if (!empty($mailer)) {
$mailer->disconnect();
}
throw $e;
}
}
开发者ID:havvg,项目名称:sfNewsletterPlugin,代码行数:24,代码来源:subscribeAction.class.php
示例10: getChannels
/**
* @param bool $refresh
*
* @return Channel[]
*/
public function getChannels($refresh = false)
{
if ($this->_channels && !$refresh) {
return $this->_channels;
}
return $this->_channels = $this->getDbDriver()->findByAttributes(array('subscriber_id' => $this->id), Subscriber::model());
}
开发者ID:sim2github,项目名称:yii-node-socket,代码行数:12,代码来源:Subscriber.php
示例11: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 30) as $index) {
$created = $faker->dateTimeThisYear;
Subscriber::create(array('subscriberName' => $faker->name, 'subscriberEmail' => $faker->email, 'created_at' => $created));
}
}
开发者ID:andrewchng,项目名称:cSystem,代码行数:8,代码来源:GenSubSeeder.php
示例12: saveData
public function saveData($aSubscriberData)
{
$oSubscriber = SubscriberQuery::create()->findPk($this->iSubscriberId);
if ($oSubscriber === null) {
$oSubscriber = new Subscriber();
$oSubscriber->setCreatedBy(Session::getSession()->getUserId());
$oSubscriber->setCreatedAt(date('c'));
}
$oSubscriber->setPreferredLanguageId($aSubscriberData['preferred_language_id']);
$oSubscriber->setName($aSubscriberData['name']);
$oSubscriber->setEmail($aSubscriberData['email']);
$this->validate($aSubscriberData, $oSubscriber);
if (!Flash::noErrors()) {
throw new ValidationException();
}
// Subscriptions
foreach ($oSubscriber->getSubscriberGroupMemberships() as $oSubscriberGroupMembership) {
$oSubscriberGroupMembership->delete();
}
$aSubscriptions = isset($aSubscriberData['subscriber_group_ids']) ? $aSubscriberData['subscriber_group_ids'] : array();
foreach ($aSubscriptions as $iSubscriberGroupId) {
$oSubscriberGroupMembership = new SubscriberGroupMembership();
$oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId);
$oSubscriber->addSubscriberGroupMembership($oSubscriberGroupMembership);
}
return $oSubscriber->save();
}
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:27,代码来源:SubscriberDetailWidgetModule.php
示例13: find
/**
* Get matched users with limit 10
* @param string $qry
* @return array
*/
public function find($qry, $catid, $tid)
{
$cid = (int) $catid;
$tid = (int) $tid;
$selector = '';
if ($cid) {
$selector = ', MAX(p.granted) AS allowed';
}
$users = \DB::table(PREFIX . 'codo_users AS u');
$users->select(\DB::raw('u.id, u.username, u.avatar' . $selector))->where('u.username', 'LIKE', "{$qry}%")->where('u.mail', '<>', 'anonymous@localhost');
if ($cid) {
$users->leftJoin(PREFIX . 'codo_user_roles AS r', 'r.uid', '=', 'u.id')->leftJoin(PREFIX . 'codo_permissions AS p', function ($join) use($cid) {
$join->on('p.permission', '=', \DB::raw('\'view all topics\''))->on('p.rid', '=', 'r.rid')->on('p.cid', '=', \DB::raw($cid))->on('p.tid', '=', \DB::raw(0));
})->groupBy('u.id');
}
$users = $users->take(10)->get();
$type = '';
if ($cid) {
$type = 'new_topic';
}
if ($tid) {
$type = 'new_reply';
}
$mutedIds = array();
if ($type != '' && count($users)) {
$uids = array_column($users, 'id');
$subscriber = new Subscriber();
$mutedIds = $subscriber->mutedOf($type, $cid, $tid, $uids);
}
$_users = array();
$i = 0;
foreach ($users as $user) {
$_users[$i]["username"] = $user['username'];
$_users[$i]["avatar"] = \CODOF\Util::get_avatar_path($user['avatar'], $user['id'], false);
if ($cid) {
//if $cid is not provided can't say whether user is mentionable or not
$notMentionable = in_array($user['id'], $mutedIds) || $user['allowed'] === 0;
$_users[$i]["mentionable"] = !$notMentionable ? 'yes' : 'no';
//better for js -> y/n
}
$i++;
}
return $_users;
}
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:49,代码来源:Mention.php
示例14: print_form
function print_form($post_data, $errors)
{
$sub = new Subscriber();
try {
$msisdn = $_GET['id'];
$sub->get($msisdn);
} catch (SubscriberException $e) {
echo "<img src='img/false.png' width='200' height='170' /><br/><br/>";
echo "<span style='font-size: 20px; color: red;'>" . _("ERROR GETTING SUBSCRIBER INFO!") . "<br/> " . $e->getMessage() . " </span><br/><br/><br/><br/>";
echo "<a href='#' onclick=\"parent.jQuery.fancybox.close()\"><button class='b1'>" . _("Close") . "</button></a>";
}
?>
<br/>
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="subscriber_delete.php">
<h1><?php
echo _("Delete Subscriber");
?>
</h1><br/>
<input type="hidden" name="msisdn" value="<?php
echo $sub->msisdn;
?>
" />
<?php
echo _("Confirm deletion of");
?>
<?php
echo $sub->name;
?>
<?php
echo $sub->msisdn;
?>
<button type="submit" name="delete_subscriber"><?php
echo _("Delete");
?>
</button>
<div class="spacer"></div>
</form>
</div>
<?php
}
开发者ID:infercom2,项目名称:rccn,代码行数:44,代码来源:subscriber_delete.php
示例15: unsubscribe
public function unsubscribe($id)
{
$subscriber = Subscriber::find((int) $id);
if ($subscriber) {
$subscriber->active = 0;
$subscriber->save();
$configs = Setting::getSiteSettings();
return View::make('frontend.unsubscribe', ['subscriber' => $subscriber, 'configs' => $configs]);
} else {
echo 'User not found.';
}
}
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:12,代码来源:FrontendController.php
示例16: doApplySubscriber
public function doApplySubscriber()
{
$validator = Validator::make(array('email' => trim(Input::get('email'))), array('email' => 'required|email|min:6|max:32'));
if ($validator->fails()) {
return Response::json(array('status' => false));
}
$existed = Subscriber::where('email', trim(Input::get('email')))->first();
if ($existed) {
return Response::json(array('status' => false, 'exist' => true));
}
Subscriber::create(array('email' => trim(Input::get('email'))));
return Response::json(array('status' => true));
}
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:13,代码来源:ApplyController.php
示例17: send_email
public function send_email($dummy)
{
$rules = array('from_name' => 'required|max:128', 'from_email' => 'required|email|max:255', 'subject' => 'required|max:128', 'emailbody' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Response::json(array('validation' => $validator->messages()->toArray()));
} else {
$from_name = Input::get('from_name');
$from_email = Input::get('from_email');
$selected = Input::get('to');
$subject = Input::get('subject');
$emailbody = Input::get('emailbody');
$from = $from_name . ' (' . $from_email . ')';
$recipients = Subscriber::whereIn('email', $selected)->where('active', '=', 1)->get();
$email = new Email();
$email->from = $from;
$email->subject = $subject;
$email->message = $emailbody;
$email->save();
$email_id = $email->id;
$numrecipients = $recipients->count();
$numsent = 0;
foreach ($recipients as $key => $recipient) {
$tracker = new Tracker();
$tracker->subscriber_id = $recipient->id;
$tracker->email_id = $email_id;
$tracker->save();
$tracker_id = $tracker->id;
$tracker_url = URL::to('tracker/' . $tracker_id);
$unsubscriber_url = URL::to('unsubscribe/' . $tracker_id);
$subscriber = $recipient;
$data = array('emailbody' => $emailbody, 'tracker' => $tracker_url, 'unsubscribe' => $unsubscriber_url, 'subscriber' => $subscriber);
$to_email = $subscriber->email;
$to_name = $subscriber->first_name . ' ' . $subscriber->last_name;
$issent = Mail::send('emails.sub-emails', $data, function ($message) use($from_email, $from_name, $to_email, $to_name, $subject) {
$message->from($from_email, $from_name)->to($to_email, $to_name)->subject($subject);
});
if ($issent) {
$numsent += 1;
} else {
$tracker->bounced = 1;
$tracker->save();
}
}
if ($numsent == $numrecipients) {
return Response::json(array('success' => 'Your email was successfully sent to <b>' . $numsent . '</b> subscribers out of the ' . $numrecipients . ' subscribers you selected. <b>Rejoice!</b>'));
} else {
return Response::json(array('success' => 'Your email was successfully sent to <b>' . $numsent . '</b> subscribers out of the ' . $numrecipients . 'All bounces have been logged.'));
}
}
}
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:51,代码来源:EmailController.php
示例18: doJob
protected function doJob($arg)
{
$models = Newsletter::model()->findAll(array('condition' => 't.remain_subscribers IS NOT NULL AND length(t.remain_subscribers) > 0 AND t.send_time <= NOW()', 'order' => 't.id ASC'));
foreach ($models as $model) {
$mail_models = ProNewsletterMail::model()->findAll(array('condition' => 't.newsletter_id = ' . $model->id, 'order' => 't.id ASC'));
if (count($mail_models)) {
$receivers = explode(',', $model->remain_subscribers);
$subscriber_count = 0;
foreach ($mail_models as $key => $k) {
$revei = array_shift($receivers);
// need update this field
$s = Subscriber::model()->getSubscriberByEmail($k->email);
if (empty($s)) {
continue;
}
if ($s) {
if ($s->status == 0) {
continue;
}
}
// add by Nguyen Dung
$url = Yii::app()->setting->getItem('server_name') . '/site/track_newsletter?newsletter_id=' . $model->id . '&subscriber_email=' . $s->email;
$img_track_read_email = '<img src="' . $url . '" alt="" height="1" width="1"/>';
$r = array('subject' => $model->subject, 'params' => array('content' => $model->content . $img_track_read_email, 'newsletterName' => Yii::app()->params['title'], 'unsubscribe' => Yii::app()->setting->getItem('server_name') . '/site/unsubscribe?id=' . $s->id . '&code=' . md5($s->id . $s->email)), 'view' => 'newsletter', 'to' => $s->email, 'from' => Yii::app()->params['autoEmail']);
$this->data[] = $r;
//Delete record in newsletter mail
ProNewsletterMail::model()->deleteByPk($k->id);
$subscriber_count++;
//count subscriber is served for current newsletter job
$this->index++;
//count email is sent for current cron job
if ($this->index >= $this->max) {
break;
}
}
$model->total_sent = $model->total_sent + $subscriber_count;
// track amount mail sent
$model->remain_subscribers = implode(',', $receivers);
$model->update(array('remain_subscribers', 'total_sent'));
}
}
//when sent all subscriber of a newsletter job but the
// if($this->index < $this->max)
// $this->doJob($arg);
}
开发者ID:jasonhai,项目名称:onehome,代码行数:45,代码来源:NewsletterCommand.php
示例19: postSelfRegister
public function postSelfRegister()
{
$input = Input::only('uname', 'pword', 'pword_confirmation', 'status', 'fname', 'lname', 'email', 'address', 'contact');
$rules = Config::get('validations.accounts');
$rules['uname'][] = 'unique:user_accounts';
$rules['pword'][] = 'confirmed';
$v = Validator::make($input, $rules);
$v->setAttributeNames(Config::get('attributes.accounts'));
if ($v->fails()) {
return Redirect::back()->withInput()->withErrors($v);
}
$input['plan_type'] = PREPAID_PLAN;
$input['clear_pword'] = $input['pword'];
$input['pword'] = Hash::make($input['pword']);
$input['is_admin'] = 0;
if (Subscriber::create($input)) {
Session::flash('success', 'succeed');
}
return Redirect::back();
}
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:20,代码来源:LoginController.php
示例20: addSubscibers
/** addSubscibers()
* @param array of email addresses to be added, if they don't exist
* @param string number of target subscriber group
* description:
* • subscribers are added if they don't exist
* • subscriber_group_membership is added if it does'nt exist
*
* @return array of integer received all / actually added
*/
public function addSubscibers($aSubscribers, $mTargetSubscriberGroup)
{
$sSubscribers = '';
$aTargetSubscriberGroups = is_array($mTargetSubscriberGroup) ? $mTargetSubscriberGroup : array($mTargetSubscriberGroup);
// If is string the addresses have not been processed and validated by js
if (is_string($aSubscribers)) {
// preg_match_all, use
$sSubscribers = trim($aSubscribers);
$aSubscribers = array();
$sSubscribers = preg_replace_callback('/' . Flash::$EMAIL_CHECK_PATTERN . '/', function ($aMatches) use(&$aSubscribers) {
$aSubscribers[] = $aMatches[0];
return '';
}, $sSubscribers);
}
$aSubscribers = array_unique($aSubscribers);
$iCountAll = count($aSubscribers);
$iMembershipsAdded = 0;
// Always create temporary groups with all imported subscribers
$oSubscriberGroup = new SubscriberGroup();
$oSubscriberGroup->setName(self::GENERATED_PREFIX . date('Ymd-Hs'));
$oSubscriberGroup->save();
array_push($aTargetSubscriberGroups, $oSubscriberGroup->getId());
foreach ($aSubscribers as $sEmail) {
$oSubscriber = SubscriberQuery::create()->filterByEmail($sEmail)->findOne();
// Create new if subscriber does not exist and email is correct
if ($oSubscriber === null) {
$oSubscriber = new Subscriber();
$oSubscriber->setEmail($sEmail);
$oSubscriber->setName($sEmail);
}
// Add subscriber_group_membership if it does not exists
// @todo check change jm > handle multiple groups including generated one
// Please check meaning and function of counting new subscriptions, only one is counted per subsriber $iMembershipsAdded
$bHasMemberShip = false;
foreach ($aTargetSubscriberGroups as $iSubscriberGroupId) {
if (!$oSubscriber->hasSubscriberGroupMembership($iSubscriberGroupId)) {
$bHasMemberShip = true;
$oSubscriberGroupMembership = new SubscriberGroupMembership();
$oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId);
$oSubscriber->addSubscriberGroupMembership($oSubscriberGroupMembership);
}
}
if ($bHasMemberShip) {
$iMembershipsAdded++;
}
$oSubscriber->save();
}
return array('all' => $iCountAll, 'added' => $iMembershipsAdded, 'text' => $sSubscribers);
}
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:58,代码来源:SubscriberImportWidgetModule.php
注:本文中的Subscriber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论