Exemple #1
0
 public function oneweeksummaryAction()
 {
     $now = time();
     $dw = date("w", $now);
     if ($dw != "1") {
         die;
     }
     $threadModel = new ThreadModel();
     if ($threadModel->isWeekmailSent() == 1) {
         die;
     }
     $threadModel->setWeekmailSent();
     $oneweekbefore = $now - 60 * 60 * 24 * 7;
     $topThread = $threadModel->topThreadsFrom(10, $oneweekbefore);
     $bbsHero = $threadModel->topBbsHero(10, $oneweekbefore);
     $newscenter = new NewscenterModel();
     $news = $newscenter->news(1, 10, "apple");
     $data = array();
     $data["topThread"] = $topThread;
     $data["bbsHero"] = $bbsHero;
     $data["news"] = $news;
     $mail = new MailModel();
     $userModel = new UserModel();
     $users = $userModel->weeklyNewsUser();
     foreach ($users as $user) {
         $data["user"] = $user;
         $page = $this->makePage("MailTemplate", "weeksummary", $data);
         $mail->generateMail($user["email"], "OurCoders社区 <*****@*****.**>", "OurCoders社区每周精选", $page, 0);
     }
     echo "ok";
 }