本文整理汇总了PHP中Subscriber::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber::save方法的具体用法?PHP Subscriber::save怎么用?PHP Subscriber::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber::save方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'));
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Subscriber('create');
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Subscriber'])) {
$model->attributes = $_POST['Subscriber'];
if ($model->save()) {
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
}
示例3: 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);
}
示例4: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aSubscriber !== null) {
if ($this->aSubscriber->isModified() || $this->aSubscriber->isNew()) {
$affectedRows += $this->aSubscriber->save($con);
}
$this->setSubscriber($this->aSubscriber);
}
if ($this->aSubscriberGroup !== null) {
if ($this->aSubscriberGroup->isModified() || $this->aSubscriberGroup->isNew()) {
$affectedRows += $this->aSubscriberGroup->save($con);
}
$this->setSubscriberGroup($this->aSubscriberGroup);
}
if ($this->aUserRelatedByCreatedBy !== null) {
if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByCreatedBy->save($con);
}
$this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
}
if ($this->aUserRelatedByUpdatedBy !== null) {
if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
}
$this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Subscriber();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Subscriber'])) {
$model->attributes = $_POST['Subscriber'];
//save groups
if (is_array(@$_POST['Subscriber']['groups'])) {
$model->groups = implode(",", $model->attributes['groups']);
}
if ($model->save()) {
Yii::app()->user->setFlash('success', 'Subscriber has been created successfully');
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例6: add_new_subscriber
public function add_new_subscriber()
{
$rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:subscribers');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Response::json($validator->messages());
} else {
$first_name = Input::get('first_name');
$last_name = Input::get('last_name');
$email = Input::get('email');
$subscriber = new Subscriber();
$subscriber->first_name = $first_name;
$subscriber->last_name = $last_name;
$subscriber->email = $email;
$subscriber->active = 1;
$subscriber->save();
$list = Addressbook::find(1);
$list->subscribers()->attach($subscriber->id);
$list->save();
$feedback = array('success' => 'New subscriber successfully saved');
return Response::json($feedback);
}
}
示例7: actionContact
public function actionContact()
{
$this->pageTitle = 'Contact Us - ' . Yii::app()->params['title'];
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
$model->name = $_POST['ContactForm']['name'];
$model->position = $_POST['ContactForm']['position'];
$model->company = $_POST['ContactForm']['company'];
$model->message = $_POST['ContactForm']['message'];
$model->email = trim($model->email);
if ($model->validate()) {
$model->message = nl2br($model->message);
$enquiry_type = $_POST['ContactForm']['enquiry_type'];
$model->enquiry_type = ContactForm::$enqueryType[$enquiry_type];
$email_to = Yii::app()->params['adminEmail'];
//save data
$contactus = new ProContactUs();
$contactus->attributes = $_POST['ContactForm'];
$contactus->save();
SendEmail::sendMailContact($model, $email_to);
Yii::app()->user->setFlash('success', 'Your message has been sent!<br/>
Thank you for contacting us. We greatly value any feedback provided to us.<br/>
If required, we will get back to you shortly.
');
$this->redirect(array('contactThankyou'));
示例8: actionSubscribe
public function actionSubscribe()
{
$model = new Subscriber();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Subscriber'])) {
$model->attributes = $_POST['Subscriber'];
if ($model->save()) {
$from = $_POST['Subscriber']['email'];
$name = $_POST['Subscriber']['name'];
$subject = 'Geralmiskin:New subscriber Request';
$headers = "From: {$name} <{$model->email}>\r\n" . "Reply-To: {$model->email}\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8";
$body = 'A new subscription has been recieved from ' . $_POST['Subscriber']['email'];
mail(Yii::app()->params['adminEmail'], $subject, $body, $headers);
Yii::app()->user->setFlash('subscribe', 'Thank you for subscribing with us. We will respond to you as soon as possible.');
}
}
$this->layout = 'contentdetails';
$this->render('site/subscribe', array('model' => $model));
}
示例9: executeResult
public function executeResult()
{
$this->setLayout(false);
if ($code = $this->getRequestParameter("codeid")) {
$c = new Criteria();
$c->add(SubscriberPeer::CODE, $code);
$user = SubscriberPeer::doSelectOne($c);
if ($user) {
$user->setPublicationStatus(UtilsHelper::STATUS_ACTIVE);
//$user->setCode(null);
$user->save();
$this->msg = "Subscribtion confirmed";
} else {
$this->err = "A problem occured";
}
return "Confirm";
}
$email = trim($this->getRequestParameter('newsletter_email'));
if (!empty($email)) {
$new = false;
$c = new Criteria();
$c->add(SubscriberPeer::EMAIL, $email);
$c->add(SubscriberPeer::PUBLICATION_STATUS, UtilsHelper::STATUS_WAITING);
$subscriber = SubscriberPeer::doSelectOne($c);
if (!$subscriber) {
$subscriber = new Subscriber();
$subscriber->setLabel($email);
$subscriber->setEmail($email);
$code = md5(time());
$subscriber->setCode($code);
$new = true;
} else {
$code = $subscriber->getCode();
}
$from_name = UtilsHelper::SYSTEM_SENDER;
$from_email = UtilsHelper::NO_REPLY_MAIL;
$mail = new sfMail();
$mail->initialize();
$mail->setMailer('sendmail');
$mail->setCharset('utf-8');
$mail->setSender($from_email, $from_name);
$mail->setFrom($from_email, $from_name);
$mail->addReplyTo($from_email);
$mail->addAddress($email);
$mail->addBcc(UtilsHelper::COPY_MAIL);
$mail->setContentType('text/html');
$mail->setSubject('Newsletter subscribtion');
$resultPage = Document::getDocumentByExclusiveTag('website_page_newsletter_result');
if ($resultPage) {
$resultPageHref = $resultPage->getHref();
}
$request = $this->getRequest();
$request->setParameter('activationUrl', $resultPageHref . "?codeid=" . $code);
$body = $this->getPresentationFor("newsletter", "confirmMail");
$mail->setBody($body);
try {
$mail->send();
$defMailinglist = Document::getDocumentByExclusiveTag('newsletter_mailinglist_default');
if ($defMailinglist && $new) {
$subscriber->save(null, $defMailinglist);
$subscriber->setPublicationStatus(UtilsHelper::STATUS_WAITING, true);
}
$this->msg = "Subscribtion successfull, check your email";
} catch (Exception $e) {
$this->getRequest()->setError('newsletter_email', "A problem occured");
}
} else {
$this->getRequest()->setError('newsletter_email', "Please enter your email");
$this->form = true;
}
}
示例10: User
if ($oForm2->valid == true) {
//no errors, therefore creates new user in system:
$oCustomer = new User();
$oCustomer->firstName = $_POST["firstName"];
$oCustomer->lastName = $_POST["lastName"];
$oCustomer->username = $_POST["username"];
$oCustomer->email = $_POST["email"];
$oCustomer->address = $_POST["address"];
$oCustomer->telephone = $_POST["telephone"];
$oCustomer->password = password_hash($_POST["password"], PASSWORD_DEFAULT);
$oCustomer->save();
$oSubscriber = new Subscriber();
if (isset($_POST["newsSignUp"])) {
$oSubscriber->email = $_POST["email"];
}
$oSubscriber->save();
// redirect after adding new page successfully to that new location
header("Location:loginSignUp.php?message=created");
// will prompt message to come up
exit;
// terminates request
}
}
// form markup:
$oForm2->makeInput("firstName", "First Name *", "doubleColumn heightApplied floatLeft");
$oForm2->makeInput("lastName", "Last Name *", "doubleColumn heightApplied floatLeft");
$oForm2->makeInput("username", "Username *", "doubleColumn heightApplied floatLeft ");
$oForm2->makeInput("email", "Email *", "doubleColumn heightApplied floatLeft ");
$oForm2->makeInput("address", "Address *", "doubleColumn heightApplied floatLeft ");
$oForm2->makeInput("telephone", "Telephone *", "doubleColumn heightApplied floatLeft");
$oForm2->makePassword("password", "Password *", "doubleColumn heightApplied floatLeft");
示例11: saveSubscriberUser
/**
* @Author: TRÂM EM Apr 08, 2014
* @Todo: save user suscriber if check to subscriber
* @Param: $user_id id user
*/
public static function saveSubscriberUser($user_id)
{
$users = Users::model()->findByPk($user_id);
$subscriber = self::getSubscriberByEmail($users->email);
if (empty($subscriber)) {
$model = new Subscriber('create');
$model->email = $users->email;
$model->subscriber_group_id = $users->role_id;
$model->status = $users->status;
$model->name = $users->first_name . " " . $users->last_name;
$model->save();
}
}
示例12: store
public function store()
{
$inputs = [];
foreach (Input::all() as $key => $input) {
$inputs[$key] = Jamesy\Sanitiser::trimInput($input);
}
$validation = Jamesy\MyValidations::validate($inputs, $this->rules);
if ($validation != NULL) {
return Redirect::back()->withErrors($validation)->withInput();
} else {
$maillists = Input::has('lists') ? Input::get('lists') : [Maillist::first()->id];
$subscriber = new Subscriber();
$subscriber->first_name = $inputs['first_name'];
$subscriber->last_name = $inputs['last_name'];
$subscriber->email = $inputs['email'];
if (Input::get('active') == '0' || Input::get('active') == '1') {
$subscriber->active = Input::get('active');
}
$subscriber->save();
$subscriber->maillists()->sync($maillists);
$generalList = Maillist::find(1);
$generalList->subscribers()->attach($subscriber->id);
$newMaillists = Subscriber::with('maillists')->find($subscriber->id)->maillists;
foreach ($newMaillists as $maillist) {
if ($maillist->active == 0) {
$subscriber->active = 0;
$subscriber->save();
break;
}
}
return Redirect::to('dashboard/subscribers')->withSuccess('New subscriber created.');
}
}
示例13: isset
<?php
define('_MEXEC', 'OK');
require_once $_SERVER['DOCUMENT_ROOT'] . "/config/app.php";
$path = isset($_SESSION['page_url']) ? $_SESSION['page_url'] : DOMAIN;
if (!isset($_POST['csrf']) || $_POST['csrf'] != '2f2f6673aab0fa90d9992a67801046cf') {
die(header('Location: ' . $path));
} else {
$subsEmail = $_POST['subscribe_email'];
$subscriber = new Subscriber();
$subscriber->subscriber = $subsEmail;
$subscriber->save();
$_SESSION['subscribe_success'] = 'Successfully added to our subscriber list.';
die(header('Location: ' . $path));
}
示例14: foreach
<?php
require_once "../Lib.php";
while (true) {
echo "\n\nFetching Messages...\n";
$smss = SMS::fetch();
foreach ($smss as $sms) {
echo "Received Message From: {$sms->sender} at {$sms->time}:\n";
echo "{$sms->message}\n\n";
$sub = new Subscriber();
$sub->phone = $sms->sender;
$sub->save();
$msg = $sms->message;
switch (strtolower($msg)) {
case '_stop':
$reply = "You will no longer receive our stock updates. Thank you for using our service.";
$sub->delete();
echo "Subscriber deleted...\n";
break;
default:
$company = $msg;
$stock = Stock::find($company);
if (!$stock) {
$reply = "Dear Subscriber, the specified company '{$company}' was not found.";
} else {
$reply = "Stock Price for {$company}: {$stock->price}";
}
}
SMS::send($sms->sender, $reply);
echo "Sent Reply to {$sms->sender}:\n{$reply}\n";
SMS::delete($sms);