當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subscriber::removeFromCR方法代碼示例

本文整理匯總了PHP中Subscriber::removeFromCR方法的典型用法代碼示例。如果您正苦於以下問題:PHP Subscriber::removeFromCR方法的具體用法?PHP Subscriber::removeFromCR怎麽用?PHP Subscriber::removeFromCR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Subscriber的用法示例。


在下文中一共展示了Subscriber::removeFromCR方法的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();
     }
 }
開發者ID:heimrichhannot,項目名稱:contao-newsletter_plus,代碼行數:59,代碼來源:ModuleUnsubscribePlus.php


注:本文中的Subscriber::removeFromCR方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。