本文整理汇总了PHP中NewsletterSubscription::save方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsletterSubscription::save方法的具体用法?PHP NewsletterSubscription::save怎么用?PHP NewsletterSubscription::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsletterSubscription
的用法示例。
在下文中一共展示了NewsletterSubscription::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newsletter_unsubscribe_all_email
/**
* Block an email address from all newsletters
*
* @param string $email The email address to block
*
* @return boolean True on success, false on failure
*/
function newsletter_unsubscribe_all_email($email)
{
$result = false;
if (!empty($email) && newsletter_is_email_address($email)) {
// get subscription
$subscription = newsletter_get_subscription($email);
if (empty($subscription)) {
$subscription = new NewsletterSubscription();
$subscription->title = $email;
if (!$subscription->save()) {
return false;
}
// remove all existing subscriptions
remove_entity_relationships($subscription->getGUID(), NewsletterSubscription::SUBSCRIPTION);
// add to general blacklist
$site = elgg_get_site_entity();
$result = (bool) add_entity_relationship($subscription->getGUID(), NewsletterSubscription::GENERAL_BLACKLIST, $site->getGUID());
}
}
return $result;
}
示例2: trim
$successMessage = "";
if (sizeof($_POST) > 0) {
$logger->LogInfo("Processing newsletter subscription ...");
$systemConfiguration->assertReferer();
if (isset($_POST['email'])) {
$emailAddress = trim($_POST['email']);
$logger->LogDebug("Email address for newsletter was specified.");
$logger->LogDebug($emailAddress);
$subscription = NewsletterSubscription::fetchFromDbForEmail($emailAddress);
if ($subscription == null) {
$subscription = new NewsletterSubscription();
}
$subscription->email = $emailAddress;
$subscription->isActive = true;
$logger->LogDebug("Saving subscription ...");
if ($subscription->save()) {
$logger->LogDebug("Saving is successful.");
$successMessage = HOME_BOX_BOTTOM_LEFT_SUCCESS;
} else {
$logger->LogError("Saving FAILED!");
$logger->LogError($subscription->errors);
$errorMessage = BOOKING_DETAILS_EMAIL_INVALID;
}
}
}
$logger->LogDebug("Starting HTML ...");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>