public function sendDigest() { $smarty = \CODOF\Smarty\Single::get_instance(SYSPATH . 'CODOF/Forum/Notification/Digest/', true); $user = \CODOF\User\User::get(); $smarty->assign('site_title', \CODOF\Util::get_opt('site_title')); $smarty->assign('brand_img', \CODOF\Util::get_opt('brand_img')); $smarty->assign('username', $user->username); $date = date('Y-F-j-S', time()); list($year, $month, $day, $ordinal) = explode("-", $date); $dayInfo = array("year" => $year, "month" => $month, "day" => $day, "ordinal" => $ordinal); $smarty->assign('dayInfo', $dayInfo); $smarty->assign('statistics_img', 'http://i.imgur.com/7sBa4Ow.png'); //RAW $smarty->assign('create_new_img', 'http://i.imgur.com/E0MhBwI.png'); //RAW $notifier = new \CODOF\Forum\Notification\Notifier(); $events = $notifier->get(TRUE, 0, 'asc'); //get all unread notifications $sortedEvents = $this->sort($events); $smarty->assign('events', $sortedEvents); $smarty->assign('new_posts', $this->newPosts . " "); $smarty->assign('new_topics', $this->newTopics . " "); if (empty($events)) { $smarty->assign('nothing_new', true); } else { $smarty->assign('nothing_new', false); } $frequency = $user->prefers('notification_frequency'); $html = $smarty->fetch("{$frequency}.tpl"); $text = $smarty->fetch("{$frequency}Text.tpl"); $this->daily = $html; $this->dailyText = $text; $mailer = new \CODOF\Forum\Notification\Mail(); $mailer->setHTML($mailer->replace_tokens($this->dailyText)); $mailer->to = $user->mail; $mailer->subject = _t('Daily digest - ') . \CODOF\Util::get_opt('site_title'); $mailer->message = $this->daily; $mailer->send_mail(); }
} else { $time = time(); } $events = $notifier->getLatest($time); if (!empty($events)) { $lastEventTime = $events[0]['created']; $time = $lastEventTime; } $notifications = $notifier->getFormattedForInline($events); echo json_encode(array("events" => $notifications, "time" => $time)); } }); dispatch_get('Ajax/notifications/all', function () { if (Request::valid($_GET['_token'])) { $notifier = new \CODOF\Forum\Notification\Notifier(); $notifications = $notifier->get(); echo json_encode($notifier->getFormattedForInline($notifications)); } }); //search: from query dispatch_get('Ajax/topics/get_topics', function () { if (Request::valid($_GET['token'])) { $topics = new Controller\Ajax\forum\topics(); $list = $topics->get_topics($_GET['from'], isset($_GET['str'])); echo json_encode($list); } }); dispatch_get('Ajax/topics/mark_read', function () { if (Request::valid($_GET['token'])) { $tracker = new CODOF\Forum\Tracker(); $tracker->mark_forum_as_read();