Пример #1
0
 public function getNewsletterMessage(Module_News $module, $email)
 {
     if (false === ($nl = GWF_Newsletter::getByEmail($email))) {
         $nl = GWF_Newsletter::getPreviewRow($email);
     }
     if (false === ($user = GWF_User::getByEmail($email))) {
         $username = $module->lang('anrede', array($email));
     } else {
         $username = $module->lang('anrede', array($user->getName()));
     }
     $unsign = $nl->getUnsignAnchor();
     return $module->lang('newsletter_wrap', array($username, $unsign, $this->getTitle(), $this->displayMessage()));
 }
Пример #2
0
 private static function sendNewsletter(Module_News $module, GWF_News $item)
 {
     $ft = $item->getFirstTranslation();
     $ts = $item->getTranslations();
     $first_id = (int) $ft['newst_langid'];
     $newsid = $item->getID();
     $sender_mail = $module->cfgSender();
     $micros = $module->cfgSleepMillis() * 1000;
     //		$newsletter = GDO::table('GWF_Newsletter');
     $db = gdo_db();
     $nlt = GWF_TABLE_PREFIX . 'newsletter';
     $query = "SELECT * FROM {$nlt}";
     if (false === ($result = $db->queryRead($query))) {
         return;
     }
     //		self::log('Sender email is: '.$sender_mail);
     //		$recs = $newsletter->selectAll();
     //		$recs = $newsletter->queryAll();
     while (false !== ($row = $db->fetchAssoc($result))) {
         //		foreach ($recs as $rec)
         //		{
         //			$rec instanceof GWF_Newsletter;
         $rec = new GWF_Newsletter($row);
         if ($rec->hasBeenMailed($newsid)) {
             continue;
         }
         $langid = $rec->getVar('nl_langid');
         $uselid = $first_id;
         foreach ($ts as $tlid => $t) {
             if ($langid === $tlid) {
                 $uselid = $tlid;
                 break;
             }
         }
         $iso = GWF_Language::getISOByID($uselid);
         $receive_mail = $rec->getVar('nl_email');
         self::notice("Sending EMail to {$receive_mail} ({$iso})");
         $title = GWF_HTML::display($ts[$uselid]['newst_title']);
         $message = GWF_Message::display($ts[$uselid]['newst_message'], true, false, false);
         $username = GWF_HTML::display($rec->getUsername());
         $unsign = $unsign = $rec->getUnsignAnchor();
         $body = $module->langISO($iso, 'newsletter_wrap', array($username, $unsign, $title, $message));
         $mail = new GWF_Mail();
         $mail->setSender($sender_mail);
         $mail->setReceiver($receive_mail);
         $mail->setSubject($module->langISO($iso, 'newsletter_title'));
         $mail->setBody($body);
         //			if (GWF_DEBUG_EMAIL) {
         //				$success = true;
         //			}
         //			else
         //			{
         if (false !== ($user = $rec->getUser())) {
             $success = $mail->sendToUser($user);
         }
         //			}
         //			else if ($rec->isHTML()) {
         //				$success = $mail->sendAsHTML();
         //			} else {
         //				$success = $mail->sendAsText();
         //			}
         if (!$success) {
             self::error("Can not send email to {$receive_mail}.");
             return;
         } else {
             $rec->setBeenMailed($newsid);
         }
         usleep($micros);
         //			return;
     }
     $db->free($result);
     $item->saveOption(GWF_News::MAILED, true);
 }
Пример #3
0
 private function onNewSign($email, $type, $langid)
 {
     $subscribe = new GWF_Newsletter(array('nl_email' => $email, 'nl_userid' => GWF_Session::getUserID(), 'nl_options' => $type, 'nl_unsign' => GWF_Random::randomKey(16), 'nl_langid' => $langid, 'nl_mailed_ids' => ':'));
     if (false === $subscribe->replace()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_signed');
 }
Пример #4
0
 public function onHookChangeMail(GWF_User $user, array $args)
 {
     if (false === GWF_Newsletter::onHookChangeMail($args[0], $args[1])) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }