Ejemplo n.º 1
0
 }
 $views = 0;
 $articles = 0;
 //CHECK DATE (dont' want testing date left in there)
 $res = $dbr->select(array('revision', 'pageview'), array('pv_30day'), array('rev_page=pv_page', 'rev_user' => $user->getID(), "rev_timestamp > {$minDate}"), __METHOD__, array('GROUP BY' => 'rev_page'));
 foreach ($res as $object) {
     $views += intval($object->pv_30day);
     $articles++;
 }
 if ($views < 50) {
     //echo "No email sent to " . $user->getName() . ". Not enough views ({$views})\n";
     continue;
 }
 $from_name = "Krystle <*****@*****.**>";
 $subject = wfMsg("viewership_subject");
 $cta = AuthorEmailNotification::getCTA('monthly_views', 'email');
 if ($articles == 1) {
     $article = "article";
 } else {
     $article = "articles";
 }
 $contribsPage = SpecialPage::getTitleFor('Contributions', $user->getName());
 $contribsLink = $contribsPage->getFullURL();
 $body = wfMsg("viewership_body", $user->getName(), number_format($articles), number_format($views), $cta, $article, $contribsLink);
 wfDebug($email . " " . $subject . " " . $body . "\n");
 $emailCount++;
 AuthorEmailNotification::notify($user, $from_name, $subject, $body, "", true);
 $userNames .= $user->getName() . " ";
 if ($emailCount > 500) {
     break;
 }
Ejemplo n.º 2
0
 function sendMilestoneEmails($datestamp)
 {
     wfLoadExtensionMessages('Milestones');
     $dbw = wfGetDB(DB_MASTER);
     $dbr = wfGetDB(DB_SLAVE);
     $users = $this->getMilestonesComplete($datestamp);
     $emailCount = 0;
     foreach ($users as $userInfo) {
         $user = User::newFromId($userInfo->{$this->userField});
         $email = $user->getEmail();
         if ($email == "") {
             continue;
         }
         $registration = $user->getRegistration();
         //need to check for false for the users who have no registration date
         //like Krystle and JackHerrick
         if ($registration == NULL || $registration <= $this->minRegistration) {
             echo "No email sent to " . $user->getName() . ". Not a new registration\n";
             wfDebug("No email sent to " . $user->getName() . ". Not a new registration\n");
             continue;
         }
         if ($user->getOption('disablemarketingemail') == '1') {
             wfDebug("No email sent to " . $user->getName() . ". Marketing email disabled.\n");
             continue;
         }
         $todayUnix = wfTimestamp(TS_UNIX, $datestamp + "000000");
         $minUnix = strtotime("-30 days", $todayUnix);
         $minDate = wfTimestamp(TS_MW, $minUnix);
         $views = 0;
         $articles = 0;
         $res = $dbr->select(array('revision', 'pageview'), array('pv_30day'), array('rev_page=pv_page', 'rev_user' => $user->getID(), "rev_timestamp > {$minDate}"), __METHOD__, array('GROUP BY' => 'rev_page'));
         foreach ($res as $object) {
             $views += intval($object->pv_30day);
             $articles++;
         }
         $from_name = wfMsg('milestone_from');
         $subject = wfMsg('milestone_subject');
         $message = wfMsg('milestone_message_' . $userInfo->ms_editcount);
         if ($views > 20) {
             $viewership = wfMsg('milestone_viewership', number_format($articles), number_format($views));
         } else {
             $viewership = "";
         }
         $cta = AuthorEmailNotification::getCTA('email_roll', 'email');
         $body = wfMsg('milestone_body', $user->getName(), $message, $viewership, $cta);
         wfDebug($user->getEmail() . " " . $subject . " " . $body . "\n");
         $emailCount++;
         AuthorEmailNotification::notify($user, $from_name, $subject, $body, "", true);
         $dbw->update($this->tableName, array($this->emailField => $datestamp), array($this->userField => $userInfo->{$this->userField}));
     }
     echo $emailCount . " milestone emails were sent\n";
 }