本文整理汇总了PHP中Subscriber::setEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber::setEmail方法的具体用法?PHP Subscriber::setEmail怎么用?PHP Subscriber::setEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber::setEmail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: pre_process
//.........这里部分代码省略.........
}
}
/* subscr_help_url */
if (isset($_POST['subscr_help_email']) && $_POST['subscr_help_email'] != "") {
$subscr_help_email_trim = trim($_POST['subscr_help_email']);
$this->form_data['subscr_help_email'] = Input::sanitizeEmail($subscr_help_email_trim);
if ($this->form_data['subscr_help_email'] != $subscr_help_email_trim) {
$this->form_data['subscr_help_email'] = "";
$this->form_data['subscr_help_email_invalid'] = true;
$this->displayInvalidCharError($subscr_help_email_trim, $this->form_data['subscr_help_email'], 'l10n_label_helpdeskemail');
$this->validationErrors = true;
}
}
/* subscr_help_email */
/* don't continue, if data was stripped due to the field
* sanitation */
if ($this->validationErrors) {
return;
}
switch (htmlentities($_POST['subscriber'])) {
case 'edit':
$subscriber = null;
if ($this->person->getSubscriber()->hasDBID($id)) {
$subscriber = $this->person->getSubscriber();
} else {
/* Other subscruber than user's
* subscriber, must create new object
* from DB */
$subscriber = Subscriber::getSubscriberByID($id, $this->person->getNREN());
}
if (!is_null($subscriber)) {
/* subscriber will clean input */
$update = $subscriber->setState($state);
$update |= $subscriber->setEmail($this->form_data['subscr_email']);
$update |= $subscriber->setPhone($this->form_data['subscr_phone']);
$update |= $subscriber->setRespName($this->form_data['subscr_responsible_name']);
$update |= $subscriber->setRespEmail($this->form_data['subscr_responsible_email']);
$update |= $subscriber->setComment($this->form_data['subscr_comment']);
$update |= $subscriber->setHelpURL($this->form_data['subscr_help_url']);
$update |= $subscriber->setHelpEmail($this->form_data['subscr_help_email']);
if ($update) {
if (!$subscriber->save(true)) {
Framework::error_output($this->translateTag('l10n_fail_editsubs1', 'nrenadmin'));
} else {
Framework::success_output($this->translateTag('l10n_suc_editsubs1', 'nrenadmin'));
}
}
/* show info-list for subscriber */
$this->tpl->assign('subscr_details', Subscriber::getSubscriberByID($id, $this->person->GetNREN())->getInfo());
$this->tpl->assign('subscriber_details', true);
$this->tpl->assign('subscriber_detail_id', $id);
}
break;
case 'editState':
$subscriber = null;
if ($this->person->getSubscriber()->hasDBID($id)) {
$subscriber = $this->person->getSubscriber();
} else {
$subscriber = Subscriber::getSubscriberByID($id, $this->person->getNREN());
}
if (!is_null($subscriber)) {
if ($subscriber->setState($state)) {
if (!$subscriber->save(true)) {
Framework::error_output("Could not update state of subscriber. Is the database-layer broken?");
Framework::error_output($this->translateTag("l10n_fail_edit_subscr_state", "nrenadmin"));
}
示例4: Subscriber
<?php
include_once "Subscriber.php";
include_once "Subscription.php";
if (isset($_POST['email']) && !empty($_POST['email'])) {
$subscriber = new Subscriber();
$subscriber->setEmail($_POST['email']);
$subscriber->saveSubscriber();
$subscription = new Subscription();
$subscription->setSubscriber($subscriber);
$response = array('success' => false, 'subscriber' => array());
if ($subscription->saveSubscription()) {
$response['success'] = true;
$response['subscriber'] = $subscriber->getSubscriber($subscriber->getId());
}
echo json_encode($response);
}
示例5: 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;
}
}
示例6: getSubscriberList
/**
* get the list of subscribers for that NREN
*
* @param void
* @return array<Subscriber> the subscribers signed up to this NREN
* @since Confusa v0.4-rc0
* @access public
*/
public function getSubscriberList($orderBy = 'subscriber_id')
{
$subscribers = null;
$query = "SELECT subscriber_id, name, org_state, lang, subscr_email, ";
$query .= "subscr_phone, subscr_resp_name, subscr_resp_email, ";
$query .= "subscr_comment, dn_name FROM subscribers WHERE nren_id=?\n\t\tORDER BY trim({$orderBy})";
$res = MDB2Wrapper::execute($query, array('integer'), array($this->getID()));
if (count($res) > 0) {
foreach ($res as $row) {
$subs = new Subscriber($row['name'], $this->getName(), $row['dn_name'], $row['org_state'], $row['subscriber_id']);
$subs->setEmail($row['subscr_email']);
$subs->setPhone($row['subscr_phone']);
$subs->setRespName($row['subscr_resp_name']);
$subs->setRespEmail($row['subscr_resp_email']);
$subs->setComment($row['subscr_comment']);
$subscribers[] = $subs;
}
}
return $subscribers;
}