Example #1
0
 public static function generateTSVOutput(&$rows)
 {
     $output = "";
     if (!empty($rows)) {
         $output = implode("\t", array_keys((array) $rows[0])) . "\n";
         foreach ($rows as $row) {
             $row = (array) $row;
             $row['ct_page_title'] = WAPLinker::makeWikiHowUrl($row['ct_page_title']);
             $output .= implode("\t", $row) . "\n";
         }
     }
     return $output;
 }
 protected function completedReport($startDate, $endDate)
 {
     $wapDB = WAPDB::getInstance($this->dbType);
     $langs = $this->wapConfig->getSupportedLanguages();
     $linker = new WAPLinker($this->dbType);
     $defaultUserText = $this->wapConfig->getDefaultUserName();
     foreach ($langs as $lang) {
         $urls = array();
         $articles = $wapDB->getTranslatedArticlesFromDate($lang, $startDate, $endDate);
         foreach ($articles as $a) {
             $userText = $a->getUserText();
             $userText = empty($userText) ? $defaultUserText : $userText;
             $urls[] = $linker->makeWikiHowUrl($a->getPageTitle()) . "\t{$userText}";
         }
         $wapDB->completeTranslatedArticles($articles, $lang);
         if (!empty($urls)) {
             $subject = $this->getSubject("Completed Articles", $lang);
             $body = "The following articles were completed via the translation links tool yesterday.\n\n" . implode("\n", $urls) . "\n\n";
             $emails = $this->wapConfig->getMaintenanceCompletedEmailList();
             mail($emails, $subject, $body);
         }
     }
 }
 protected function genericCheckup($sql, $type)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $rows = $dbr->query($sql, __METHOD__);
     $urls = array();
     foreach ($rows as $row) {
         $userText = intval($row->ct_user_id) > 0 ? $row->ct_user_text : "[NOT ASSIGNED]";
         $urls[$row->ct_lang_code][] = "{$row->ct_page_id}\t" . WAPLinker::makeWikiHowUrl($row->ct_page_title) . "\t{$userText}\t{$row->extra}";
     }
     $system = $this->wapConfig->getSystemName();
     $langs = $this->wapConfig->getSupportedLanguages();
     foreach ($langs as $lang) {
         // Email articles that are assigned to wikiphoto admins so they can sort it out
         $body = "";
         $subject = "{$system} CHECKUP Report: Forward this to Jordan <eom>";
         if ($type == self::REDIRECT_TYPE) {
             $subject = "CHECKUP - Redirect Articles";
             $body = "The following articles became redirects in wikiHow but exist in {$system}\n\n";
         } elseif ($type == DailyEdits::DELETE_TYPE) {
             $subject = "CHECKUP - Deleted Articles";
             $body = "The following articles were deleted in wikiHow but exist in {$system}\n\n";
         } elseif ($type == self::EXCLUDED_TYPE) {
             $subject = "CHECKUP - Excluded Articles";
             $body = "The following articles are on the excluded article list but exist in {$system}\n\n";
         } elseif ($type == self::BAD_TEMPLATE_TYPE) {
             $subject = "CHECKUP - Articles with Bad Templates";
             $body = "The following articles had a bad template but exist in {$system}\n\n";
         } elseif ($type == self::MOVED_TYPE) {
             $subject = "CHECKUP - Moved Articles";
             $body = "The following articles should be moved in {$system}\n\n";
         } elseif ($type == self::COMPLETED_TYPE) {
             $subject = "CHECKUP - Completed Articles";
             $body = "The following articles should be completed in {$system}\n\n";
         }
         $urlsByLang = $urls[$lang];
         if (!empty($urlsByLang)) {
             $subject = $this->getSubject($subject, $lang);
             $body .= implode("\n", $urlsByLang);
             $emails = '*****@*****.**';
             mail($emails, $subject, $body);
         }
     }
 }