private function onReply(Module_Comments $mod_c, GWF_News $news, GWF_Comments $comments) { $ipp = 10; $nItems = $comments->getVar('cmts_count'); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp(Common::getGetInt('cpage'), 1, $nPages); $href = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-' . $page . '.html'; $me = $mod_c->getMethod('Reply'); $me instanceof Comments_Reply; return $me->onReply($href); }
public static function newNews($date, $catid, $userid, $langid, $title, $message, $fake = false, $options = 0) { $news = new GWF_News(array('news_date' => $date, 'news_catid' => $catid, 'news_userid' => $userid, 'news_readby' => ':', 'news_options' => $options)); if ($fake === false) { if (false === $news->insert()) { return false; } } else { $news->setVar('news_id', '0'); } $transdata = array('newst_langid' => $langid, 'newst_newsid' => $news->getID(), 'newst_title' => $title, 'newst_message' => $message, 'newst_options' => '0', 'newst_threadid' => '0'); if ($fake === false) { $trans = new GWF_NewsTranslation($transdata); if (false === $trans->insert()) { return false; } } else { // $news->setVar('news_trans', array($langid=>$transdata)); $news->setVar('news_userid', GWF_User::getByID($userid)); $news->translations = array($transdata); } return $news; }
public function newsToForum(GWF_News $news, $visible = true) { if (false === ($poster = $news->getUser())) { return GWF_HTML::error('News_Edit', 'News_Edit::newsToForum(): Nobody as Poster'); } // Get News root. if (false === ($news_root = $this->getNewsForumRoot())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $root_id = $news_root->getID(); $lang_roots = array(); foreach ($news->getTranslations() as $t) { if (false === ($lang = GWF_Language::getByID($t['newst_langid']))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === ($lang_board = $this->getNewsForumLangCached($lang, $root_id))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $iso = $lang->getISO(); $tid = (int) $t['newst_threadid']; $lang_roots[$iso] = $lang_board; $bid = $lang_board->getID(); $thread = GWF_ForumThread::getByID($tid); $title = $t['newst_title']; $message = $t['newst_message']; $gid = 0; $options = GWF_ForumThread::GUEST_VIEW; $options |= $visible ? 0 : GWF_ForumThread::INVISIBLE; if (!$visible) { if ($thread !== false) { $thread->setVisible($visible); } } else { if ($thread === false) { if (false === ($thread = GWF_ForumThread::newThread($poster, $title, $message, $options, $bid, $gid))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } else { if (false === ($post = $thread->getFirstPost())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $post->saveVar('post_message', $message)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } $thread->setVisible($visible); } $tid = $thread === false ? 0 : $thread->getID(); $langid = $lang->getID(); $newsid = $news->getID(); // Save threadid if (false === GDO::table('GWF_NewsTranslation')->update("newst_threadid={$tid}", "newst_langid={$langid} AND newst_newsid={$newsid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } // Set Boards Visible $news_root->setVisible($visible); foreach ($lang_roots as $iso => $board) { $board->setVisible($visible); } return ''; }
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); }