Exemplo n.º 1
0
 public function templateComments(Module_Comments $mod_c, GWF_News $news, GWF_Comments $comments)
 {
     $ipp = 10;
     $cid = $comments->getID();
     $nItems = $comments->getVar('cmts_count');
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(Common::getGetInt('cpage'), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     // Method
     $me = $mod_c->getMethod('Reply');
     $me instanceof Comments_Reply;
     $where = "cmt_cid={$cid}";
     $with_perms = !GWF_User::isInGroupS('moderator');
     if ($with_perms) {
         $visible = GWF_Comment::VISIBLE;
         $deleted = GWF_Comment::DELETED;
         $flags = $visible | $deleted;
         $where .= " cmt_options & {$flags} = {$visible}";
     }
     $c = GDO::table('GWF_Comment')->selectObjects('*', 'cmt_cid=' . $comments->getID(), 'cmt_date ASC', $ipp, $from);
     $href = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-' . $page . '.html';
     $hrefp = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-%PAGE%.html';
     $tVars = array('news' => $news, 'newsitem' => Module_News::displayBoxB(array($news)), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $hrefp), 'comments' => $comments->displayComments($c, $href), 'form' => $me->templateReply($href));
     return $this->module->template('comments.tpl', $tVars);
 }
Exemplo n.º 2
0
 public function execute()
 {
     if (false === ($this->news = Module_News::getSavedPreview())) {
         return $this->module->error('err_no_preview');
     }
     if (false === ($mail = $this->getPreviewMail())) {
         return $this->module->error('err_no_preview');
     }
     switch (Common::getGet('mode')) {
         case 'html':
             return $this->previewHTML($mail);
         case 'text':
         default:
             return $this->previewText($mail);
     }
 }
Exemplo n.º 3
0
 private function previewNewsletter(GWF_News $news)
 {
     Module_News::savePreview($news);
     $aTEXT = sprintf('<a href="%s">%s</a>', GWF_WEB_ROOT . 'newsletter/preview/text', $this->module->lang('btn_preview_text'));
     $aHTML = sprintf('<a href="%s">%s</a>', GWF_WEB_ROOT . 'newsletter/preview/html', $this->module->lang('btn_preview_html'));
     return $this->module->lang('preview_info', array($aTEXT, $aHTML));
 }
Exemplo n.º 4
0
 public function showAccountLinkNews()
 {
     //		$db = gdo_db();
     //		$users = GWF_TABLE_PREFIX.'user';
     ////		$history = GWF_TABLE_PREFIX.'wc_user_history';
     //		$regat = GWF_TABLE_PREFIX.'wc_regat';
     //		$sites = GWF_TABLE_PREFIX.'wc_site';
     ////		$time = GWF_Time::getTimeWeekStart();
     //		$today = GWF_Time::getDate(GWF_Date::LEN_DAY);
     //		$query =
     //			"SELECT user_name, site_name, regat_solved ".
     //			"FROM $regat ".
     //			"LEFT JOIN $users ON user_id=regat_uid ".
     //			"LEFT JOIN $sites ON site_id=regat_sid ".
     //			"WHERE regat_linkdate='$today' AND regat_solved>0";
     //		if (false === ($result = $db->queryAll($query))) {
     //			return '';
     //		}
     $result = $this->getFirstLinkNews();
     if (count($result) === 0) {
         return '';
     }
     $msg = '';
     foreach ($result as $row) {
         $un = $row['fili_username'];
         $sn = $row['fili_sitename'];
         //			$site_link = sprintf('[url=%s]%s[/url]', GWF_WEB_ROOT, urlencode($sn), GWF_HTML::display($sn));
         $site_link = sprintf('[b]%s[/b]', $sn);
         $perc = sprintf('%.02f', $row['fili_percent']);
         $profile_link = sprintf('[url=/profile/%s]%s[/url]', $un, $un);
         $msg .= $this->lang('newsrow_link', array($profile_link, $site_link, $perc)) . PHP_EOL;
         //			$msg .= sprintf('%s', $this->lang('newsrow_link', sprintf('<a href="%sprofile/%s">%s</a>', GWF_WEB_ROOT, urlencode($un), GWF_HTML::display($row['fili_username'])), , )).PHP_EOL;
     }
     $title = $this->lang('newsrow_linkt');
     $wechalluser = $this->cfgWeChallUser();
     $english = GWF_Language::getEnglish();
     $news = GWF_News::newNews(GWF_Time::getDate(GWF_Date::LEN_SECOND), 0, $wechalluser->getID(), $english->getID(), $title, $msg, true);
     return Module_News::displayItem($news);
 }
Exemplo n.º 5
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()));
 }
Exemplo n.º 6
0
 public static function getTypeSelectB(Module_News $module, $key, $value = 0)
 {
     $key = GWF_HTML::display($key);
     $value = (int) $value;
     $back = sprintf('<select name="%s">' . PHP_EOL, $key);
     $sel = GWF_HTML::selected($value === 0);
     $back .= sprintf('<option value="%d"%s>%s</option>' . PHP_EOL, 0, $sel, $module->lang('type_none'));
     $sel = GWF_HTML::selected($value === self::WANT_TEXT);
     $back .= sprintf('<option value="%d"%s>%s</option>' . PHP_EOL, self::WANT_TEXT, $sel, $module->lang('type_text'));
     $sel = GWF_HTML::selected($value === self::WANT_HTML);
     $back .= sprintf('<option value="%d"%s>%s</option>' . PHP_EOL, self::WANT_HTML, $sel, $module->lang('type_html'));
     $back .= '</select>' . PHP_EOL;
     return $back;
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
0
 public function onStartup()
 {
     self::$instance = $this;
     //		$this->isMethodSelected('Show');
     //		GWF_Hook::add(GWF_Hook::SHOW_COMMENT_ITEM, self::hookShowCommentItem());
 }