コード例 #1
0
ファイル: ModuleSubscribe.php プロジェクト: rikaix/core
 /**
  * Activate a recipient
  */
 protected function activateRecipient()
 {
     $this->Template = new \FrontendTemplate('mod_newsletter');
     // Check the token
     $objRecipient = \NewsletterRecipientsModel::findByToken(\Input::get('token'));
     if ($objRecipient === null) {
         $this->Template->mclass = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['invalidToken'];
         return;
     }
     $arrAdd = array();
     $arrChannels = array();
     $arrCids = array();
     // Update the subscriptions
     while ($objRecipient->next()) {
         $objChannel = $objRecipient->getRelated('pid');
         $arrAdd[] = $objRecipient->id;
         $arrChannels[] = $objChannel->title;
         $arrCids[] = $objChannel->id;
         $objRecipient->active = 1;
         $objRecipient->token = '';
         $objRecipient->pid = $objChannel->id;
         $objRecipient->save();
     }
     // Log activity
     $this->log($objRecipient->email . ' has subscribed to the following channels: ' . implode(', ', $arrChannels), 'ModuleSubscribe activateRecipient()', TL_NEWSLETTER);
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateRecipient']) && is_array($GLOBALS['TL_HOOKS']['activateRecipient'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateRecipient'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objRecipient->email, $arrAdd, $arrCids);
         }
     }
     // Confirm activation
     $this->Template->mclass = 'confirm';
     $this->Template->message = $GLOBALS['TL_LANG']['MSC']['nl_activate'];
 }
コード例 #2
0
 /**
  * Activate a recipient
  */
 protected function activateRecipient()
 {
     /** @var \FrontendTemplate|object $objTemplate */
     $objTemplate = new \FrontendTemplate('mod_newsletter');
     $this->Template = $objTemplate;
     // Check the token
     $objRecipient = \NewsletterRecipientsModel::findByToken(\Input::get('token'));
     if ($objRecipient === null) {
         $this->Template->mclass = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['invalidToken'];
         return;
     }
     $time = time();
     $arrAdd = array();
     $arrChannels = array();
     $arrCids = array();
     // Update the subscriptions
     while ($objRecipient->next()) {
         /** @var \NewsletterChannelModel $objChannel */
         $objChannel = $objRecipient->getRelated('pid');
         $arrAdd[] = $objRecipient->id;
         $arrChannels[] = $objChannel->title;
         $arrCids[] = $objChannel->id;
         $objRecipient->active = 1;
         $objRecipient->token = '';
         $objRecipient->pid = $objChannel->id;
         $objRecipient->confirmed = $time;
         $objRecipient->save();
     }
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateRecipient']) && is_array($GLOBALS['TL_HOOKS']['activateRecipient'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateRecipient'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback[0]}->{$callback[1]}($objRecipient->email, $arrAdd, $arrCids);
         }
     }
     // Confirm activation
     $this->Template->mclass = 'confirm';
     $this->Template->message = $GLOBALS['TL_LANG']['MSC']['nl_activate'];
 }