예제 #1
0
function wfNotifyRequesterOnNab($article_id)
{
    $dbw = wfGetDB(DB_MASTER);
    $res = $dbw->select(array('suggested_notify', 'page'), array('sn_notify', 'page_title', 'page_namespace'), array('sn_page=page_id', 'page_id' => $article_id));
    // Only send an email if the article doesn't suck (bug 557)
    $templateRegExp = "@{{(Copyvio|Copyviobot|accuracy|nfd|stub){1}@im";
    $r = Revision::loadFromPageId($dbw, $article_id);
    if (!is_null($r) && preg_match($templateRegExp, $r->getText()) === 0) {
        $emails = array();
        while ($row = $dbw->fetchObject($res)) {
            $title = Title::makeTitle($row->page_namespace, $row->page_title);
            $arr = split(',', $row->sn_notify);
            foreach ($arr as $e) {
                $emails[trim($e)] = $title;
            }
        }
        if (sizeof($emails) > 0) {
            wfSendRequestNotificationEmail($emails);
        }
    }
    $dbw->delete('suggested_notify', array('sn_page' => $article_id));
    return true;
}
<?php

require_once 'commandLine.inc';
$dbw = wfGetDB(DB_MASTER);
$ts = wfTimestamp(TS_MW, time() - 2 * 24 * 3600);
$res = $dbw->select(array('suggested_notify', 'page'), array('sn_page', 'page_title', 'page_namespace', 'sn_notify'), array("sn_timestamp < '{$ts}'", 'page_id=sn_page'));
while ($row = $dbw->fetchObject($res)) {
    $emails = array();
    $t = Title::newFromText($row->page_title);
    $title = Title::makeTitle($row->page_namespace, $row->page_title);
    $arr = split(',', $row->sn_notify);
    foreach ($arr as $e) {
        $emails[trim($e)] = $title;
    }
    if (sizeof($emails) > 0) {
        wfSendRequestNotificationEmail($emails);
    }
    $dbw->delete('suggested_notify', array('sn_page' => $row->sn_page));
}