本文整理汇总了PHP中Subscriber::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscriber::remove方法的具体用法?PHP Subscriber::remove怎么用?PHP Subscriber::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeRecipient
/**
* Add a new recipient
*/
protected function removeRecipient()
{
$arrChannels = $this->Input->post('channels');
$arrChannels = array_intersect($arrChannels, $this->nl_channels);
// see #3240
// Check the selection
if (!is_array($arrChannels) || count($arrChannels) < 1) {
$_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
$this->reload();
}
$arrSubscriptions = array();
$email = \Idna::encodeEmail($this->Input->post('email', true));
$subscriber = new Subscriber($email);
// Get active subscriptions
$objSubscription = $this->Database->prepare("SELECT pid FROM tl_newsletter_recipients WHERE email=? AND active=1")->execute($email);
if ($objSubscription->numRows) {
$arrSubscriptions = $objSubscription->fetchEach('pid');
}
$arrRemove = array_intersect($arrChannels, $arrSubscriptions);
// Return if there are no subscriptions to remove
if (!is_array($arrRemove) || count($arrRemove) < 1) {
$_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['unsubscribed'];
$this->reload();
}
// check for cleverreach support
$objChannel = $this->Database->execute("SELECT id FROM tl_newsletter_channel WHERE cleverreach_active = 1 AND id IN(" . implode(',', array_map('intval', $arrRemove)) . ")");
// TODO: multiple channel unsubscription
$subscriber->getByChannel($arrRemove[0]);
// Remove subscriptions
$subscriber->remove($arrRemove);
// optional Cleverreach Deletion
if ($objChannel->numRows > 0) {
$subscriber->removeFromCR($objChannel->fetchEach('id'));
}
// Get channels
$objChannels = $this->Database->execute("SELECT title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', $arrRemove)) . ")");
$arrChannels = $objChannels->fetchEach('title');
// HOOK: post unsubscribe callback
if (isset($GLOBALS['TL_HOOKS']['removeRecipient']) && is_array($GLOBALS['TL_HOOKS']['removeRecipient'])) {
foreach ($GLOBALS['TL_HOOKS']['removeRecipient'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($varInput, $arrRemove);
}
}
global $objPage;
// Redirect to jumpTo page
if (strlen($this->jumpTo) && $this->jumpTo != $objPage->id) {
$objNextPage = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($this->jumpTo);
if ($objNextPage->numRows) {
$this->redirect($this->generateFrontendUrl($objNextPage->fetchAssoc()));
}
}
if ($subscriber->sendUnSubscribeMail($arrRemove)) {
$this->reload();
}
}