Exemplo n.º 1
0
 function markRevisionsPatrolled($article)
 {
     global $wgOut;
     $request = $this->getRequest();
     // some sanity checks
     $rcid = $request->getInt('rcid');
     $rc = RecentChange::newFromId($rcid);
     if (is_null($rc)) {
         throw new ErrorPageError('markedaspatrollederror', 'markedaspatrollederrortext');
     }
     $user = $this->getUser();
     if (!$user->matchEditToken($request->getVal('token'), $rcid)) {
         throw new ErrorPageError('sessionfailure-title', 'sessionfailure');
     }
     // check if skip has been passed to us
     if ($request->getInt('skip') != 1) {
         // find his and lows
         $rcids = array();
         $rcids[] = $rcid;
         if ($request->getVal('rchi', null) && $request->getVal('rclow', null)) {
             $hilos = wfGetRCPatrols($rcid, $request->getVal('rchi'), $request->getVal('rclow'), $article->mTitle->getArticleID());
             $rcids = array_merge($rcids, $hilos);
         }
         $rcids = array_unique($rcids);
         foreach ($rcids as $id) {
             RecentChange::markPatrolled($id, false);
         }
         wfRunHooks('MarkPatrolledBatchComplete', array(&$article, &$rcids, &$user));
     } else {
         RCPatrol::skipPatrolled($article);
     }
 }
Exemplo n.º 2
0
 static function markPatrolledCallback(&$article, $rcid)
 {
     global $wgRequest, $wgUser, $wgOut;
     // check if skip has been passed to us
     if ($wgRequest->getInt('skip', null) != 1) {
         // find his and lows
         $rcids = array();
         $rcids[] = $rcid;
         if ($wgRequest->getVal('rchi', null) && $wgRequest->getVal('rclow', null)) {
             $hilos = wfGetRCPatrols($rcid, $wgRequest->getVal('rchi'), $wgRequest->getVal('rclow'), $article->mTitle->getArticleID());
             $rcids = array_merge($rcids, $hilos);
         }
         $rcids = array_unique($rcids);
         foreach ($rcids as $id) {
             RecentChange::markPatrolled($id, $article);
             PatrolLog::record($id, false);
         }
         wfRunHooks('MarkPatrolledBatchComplete', array(&$article, &$rcids, &$wgUser));
         wfRunHooks('MarkPatrolledComplete', array(&$rcid, &$wgUser, false));
     } else {
         self::skipPatrolled($article);
     }
     $show_namespace = $wgRequest->getVal('show_namespace');
     $invert = $wgRequest->getVal('invert');
     $reverse = $wgRequest->getVal('reverse');
     $featured = $wgRequest->getVal('featured');
     $fromrc = $wgRequest->getVal('fromrc', null) == null ? "" : "&fromrc=1";
     //TODO: shorten this to a selectRow call
     $sql = "SELECT rc_id, rc_cur_id, rc_moved_to_ns, \n\t\t\trc_moved_to_title, rc_new, rc_namespace, rc_title, rc_last_oldid, rc_this_oldid FROM recentchanges " . ($featured ? " LEFT OUTER JOIN page on page_title = rc_title and page_namespace = rc_namespace " : "") . " WHERE rc_id " . ($reverse == 1 ? " > " : " < ") . " {$rcid} and rc_patrolled = 0  " . ($featured ? " AND page_is_featured = 1 " : "") . " AND rc_user_text != '" . $wgUser->getName() . "' ";
     if ($show_namespace != null && $show_namespace != '') {
         $sql .= " AND rc_namespace " . ($invert ? '!=' : '=') . $show_namespace;
     } else {
         // avoid the delete logs, etc
         $sql .= " AND rc_namespace NOT IN ( " . NS_VIDEO . ") ";
     }
     $sql .= " ORDER by rc_id " . ($reverse == 1 ? " ASC " : " DESC ") . "  LIMIT 1";
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->query($sql);
     if ($row = $dbw->fetchObject($res)) {
         $xx = Title::makeTitle($row->rc_namespace, $row->rc_title);
         if ($row->rc_moved_to_title != "") {
             $xx = Title::makeTitle($row->rc_moved_to_ns, $row->rc_moved_to_title);
         }
         $url = "";
         if ($row->rc_new == 1) {
             $url = $xx->getFullURL() . "?redirect=no&rcid=" . $row->rc_id;
         } else {
             $url = $xx->getFullURL() . "?title=" . $xx->getPrefixedURL() . "&curid=" . $row->rc_cur_id . "&diff={$row->rc_this_oldid}&oldid=" . $row->rc_last_oldid . "&rcid=" . $row->rc_id;
         }
         if ($show_namespace != null) {
             $url .= "&show_namespace={$show_namespace}&invert={$invert}";
         }
         $url .= "&reverse={$reverse}&featured={$featured}{$fromrc}";
         $dbw->freeResult($res);
         $wgOut->redirect($url);
         return false;
     }
     return true;
 }