本文整理汇总了PHP中RecentChange::markPatrolled方法的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange::markPatrolled方法的具体用法?PHP RecentChange::markPatrolled怎么用?PHP RecentChange::markPatrolled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecentChange
的用法示例。
在下文中一共展示了RecentChange::markPatrolled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Patrols the article or provides the reason the patrol failed.
*/
public function execute()
{
global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
$this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
if (!isset($params['token'])) {
$this->dieUsageMsg(array('missingparam', 'token'));
}
if (!isset($params['rcid'])) {
$this->dieUsageMsg(array('missingparam', 'rcid'));
}
if (!$wgUser->matchEditToken($params['token'])) {
$this->dieUsageMsg(array('sessionfailure'));
}
$rc = RecentChange::newFromID($params['rcid']);
if (!$rc instanceof RecentChange) {
$this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
}
$retval = RecentChange::markPatrolled($params['rcid']);
if ($retval) {
$this->dieUsageMsg(current($retval));
}
$result = array('rcid' => $rc->getAttribute('rc_id'));
ApiQueryBase::addTitleInfo($result, $rc->getTitle());
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例2: wfMarkUndoneEditAsPatrolled
function wfMarkUndoneEditAsPatrolled()
{
global $wgRequest;
if ($wgRequest->getVal('wpUndoEdit', null) != null) {
$oldid = $wgRequest->getVal('wpUndoEdit');
// using db master to avoid db replication lag
$dbr = wfGetDB(DB_MASTER);
$rcid = $dbr->selectField('recentchanges', 'rc_id', array('rc_this_oldid' => $oldid));
RecentChange::markPatrolled($rcid);
PatrolLog::record($rcid, false);
}
return true;
}
示例3: execute
/**
* Patrols the article or provides the reason the patrol failed.
*/
public function execute()
{
$params = $this->extractRequestParams();
$rc = RecentChange::newFromID($params['rcid']);
if (!$rc instanceof RecentChange) {
$this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
}
$retval = RecentChange::markPatrolled($params['rcid']);
if ($retval) {
$this->dieUsageMsg(reset($retval));
}
$result = array('rcid' => intval($rc->getAttribute('rc_id')));
ApiQueryBase::addTitleInfo($result, $rc->getTitle());
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例4: markpatrolled
/**
* Mark this particular edit as patrolled
*/
function markpatrolled()
{
global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUser;
$wgOut->setRobotPolicy('noindex,nofollow');
# Check RC patrol config. option
if (!$wgUseRCPatrol) {
$wgOut->errorPage('rcpatroldisabled', 'rcpatroldisabledtext');
return;
}
# Check permissions
if (!$wgUser->isAllowed('patrol')) {
$wgOut->permissionRequired('patrol');
return;
}
# If we haven't been given an rc_id value, we can't do anything
$rcid = $wgRequest->getVal('rcid');
if (!$rcid) {
$wgOut->errorPage('markedaspatrollederror', 'markedaspatrollederrortext');
return;
}
# Handle the 'MarkPatrolled' hook
if (!wfRunHooks('MarkPatrolled', array($rcid, &$wgUser, false))) {
return;
}
$return = SpecialPage::getTitleFor('Recentchanges');
# If it's left up to us, check that the user is allowed to patrol this edit
# If the user has the "autopatrol" right, then we'll assume there are no
# other conditions stopping them doing so
if (!$wgUser->isAllowed('autopatrol')) {
$rc = RecentChange::newFromId($rcid);
# Graceful error handling, as we've done before here...
# (If the recent change doesn't exist, then it doesn't matter whether
# the user is allowed to patrol it or not; nothing is going to happen
if (is_object($rc) && $wgUser->getName() == $rc->getAttribute('rc_user_text')) {
# The user made this edit, and can't patrol it
# Tell them so, and then back off
$wgOut->setPageTitle(wfMsg('markedaspatrollederror'));
$wgOut->addWikiText(wfMsgNoTrans('markedaspatrollederror-noautopatrol'));
$wgOut->returnToMain(false, $return);
return;
}
}
# Mark the edit as patrolled
RecentChange::markPatrolled($rcid);
wfRunHooks('MarkPatrolledComplete', array(&$rcid, &$wgUser, false));
# Inform the user
$wgOut->setPageTitle(wfMsg('markedaspatrolled'));
$wgOut->addWikiText(wfMsgNoTrans('markedaspatrolledtext'));
$wgOut->returnToMain(false, $return);
}
示例5: doNABAction
/**
* If a user is nabbing an article, there are Skip/Cancel and Mark as
* Patrolled buttons at the buttom of the list of NAB actions. When
* either of these buttons are pushed, this function processes the
* submitted form.
*/
private function doNABAction(&$dbw)
{
global $wgRequest, $wgOut, $wgUser;
$err = false;
$aid = $wgRequest->getVal('page', 0);
$aid = intval($aid);
if ($wgRequest->getVal('nap_submit', null) != null) {
$title = Title::newFromID($aid);
// MARK ARTICLE AS PATROLLED
self::markNabbed($dbw, $aid, $wgUser->getId());
if (!$title) {
$wgOut->addHTML('Error: target page for NAB was not found');
return;
}
// LOG ENTRY
$params = array($aid);
$log = new LogPage('nap', false);
$log->addEntry('nap', $title, wfMsg('nap_logsummary', $title->getFullText()), $params);
// ADD ANY TEMPLATES
self::addTemplates($title);
// Rising star actions FS RS
$this->flagRisingStar($title);
// DELETE ARTICLE IF PATROLLER WANTED THIS
if ($wgRequest->getVal('delete', null) != null && $wgUser->isAllowed('delete')) {
$article = new Article($title);
$article->doDelete($wgRequest->getVal("delete_reason"));
}
// MOVE/RE-TITLE ARTICLE IF PATROLLER WANTED THIS
if ($wgRequest->getVal('move', null) != null && $wgUser->isAllowed('move')) {
if ($wgRequest->getVal('move_newtitle', null) == null) {
$wgOut->addHTML('Error: no target page title specified.');
return;
}
$newTarget = $wgRequest->getVal('move_newtitle');
$newTitle = Title::newFromText($newTarget);
if (!$newTitle) {
$wgOut->addHTML("Bad new title: {$newTarget}");
return;
}
$ret = $title->moveTo($newTitle);
if (is_string($ret)) {
$wgOut->addHTML("Renaming of the article failed: " . wfMsg($ret));
$err = true;
}
// move the talk page if it exists
$oldTitleTalkPage = $title->getTalkPage();
if ($oldTitleTalkPage->exists()) {
$newTitleTalkPage = $newTitle->getTalkPage();
$err = $oldTitleTalkPage->moveTo($newTitleTalkPage) === true;
}
$title = $newTitle;
}
// MARK ALL PREVIOUS EDITS AS PATROLLED IN RC
$maxrcid = $wgRequest->getVal('maxrcid');
if ($maxrcid) {
$res = $dbw->select('recentchanges', 'rc_id', array('rc_id<=' . $maxrcid, 'rc_cur_id=' . $aid, 'rc_patrolled=0'), __METHOD__);
while ($row = $dbw->fetchObject($res)) {
RecentChange::markPatrolled($row->rc_id);
PatrolLog::record($row->rc_id, false);
}
$dbw->freeResult($res);
}
wfRunHooks("NABArticleFinished", array($aid));
}
// GET NEXT UNPATROLLED ARTICLE
if ($wgRequest->getVal('nap_skip') && $wgRequest->getVal('page')) {
// if article was skipped, clear the checkout of the
// article, so others can NAB it
$dbw->update('newarticlepatrol', array('nap_user_co=0'), array("nap_page", $aid), __METHOD__);
}
$title = $this->getNextUnpatrolledArticle($dbw, $aid);
if (!$title) {
$wgOut->addHTML("Unable to get next id to patrol.");
return;
}
$nap = SpecialPage::getTitleFor('Newarticleboost', $title->getPrefixedText());
$url = $nap->getFullURL() . ($this->do_newbie ? '?newbie=1' : '');
if (!$err) {
$wgOut->redirect($url);
} else {
$wgOut->addHTML("<br/><br/>Click <a href='{$nap->getFullURL()}'>here</a> to continue.");
}
}
示例6: markpatrolled
/**
* Mark this particular edit as patrolled
*/
function markpatrolled()
{
global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUser;
$wgOut->setRobotpolicy('noindex,nofollow');
# Check RC patrol config. option
if (!$wgUseRCPatrol) {
$wgOut->errorPage('rcpatroldisabled', 'rcpatroldisabledtext');
return;
}
# Check permissions
if (!$wgUser->isAllowed('patrol')) {
$wgOut->permissionRequired('patrol');
return;
}
$rcid = $wgRequest->getVal('rcid');
if (!is_null($rcid)) {
if (wfRunHooks('MarkPatrolled', array(&$rcid, &$wgUser, false))) {
RecentChange::markPatrolled($rcid);
wfRunHooks('MarkPatrolledComplete', array(&$rcid, &$wgUser, false));
$wgOut->setPagetitle(wfMsg('markedaspatrolled'));
$wgOut->addWikiText(wfMsg('markedaspatrolledtext'));
}
$rcTitle = Title::makeTitle(NS_SPECIAL, 'Recentchanges');
$wgOut->returnToMain(false, $rcTitle->getPrefixedText());
} else {
$wgOut->showErrorPage('markedaspatrollederror', 'markedaspatrollederrortext');
}
}
示例7: markRevisionsPatrolled
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);
}
}
示例8: doEditContent
//.........这里部分代码省略.........
wfProfileOut(__METHOD__);
return $status;
}
$revisionId = $revision->insertOn($dbw);
// Update page
//
// Note that we use $this->mLatest instead of fetching a value from the master DB
// during the course of this function. This makes sure that EditPage can detect
// edit conflicts reliably, either by $ok here, or by $article->getTimestamp()
// before this function is called. A previous function used a separate query, this
// creates a window where concurrent edits can cause an ignored edit conflict.
$ok = $this->updateRevisionOn($dbw, $revision, $oldid, $oldIsRedirect);
if (!$ok) {
// Belated edit conflict! Run away!!
$status->fatal('edit-conflict');
$dbw->rollback(__METHOD__);
wfProfileOut(__METHOD__);
return $status;
}
wfRunHooks('NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user));
// Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
// Mark as patrolled if the user can do so
$patrolled = $wgUseRCPatrol && !count($this->mTitle->getUserPermissionsErrors('autopatrol', $user));
// Reuben 1/29/2014: $patrolled flag may be changed by this hook
wfRunHooks('MaybeAutoPatrol', array($this, $user, &$patrolled));
// Add RC row to the DB
$rc = RecentChange::notifyEdit($now, $this->mTitle, $isminor, $user, $summary, $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId);
// Log auto-patrolled edits
// AG changed core MW code here since markPatrolled does extra things
// that we want to make sure still happen, and removed the call to log this
// change because markPatrolled will do that for us
if ($patrolled) {
RecentChange::markPatrolled($rc, true, true);
}
}
// Reuben 1/30/2014: Only increment edit count if making a
// non-NS_USER/NS_USER_TALK/KUDOS edit
global $wgIgnoreNamespacesForEditCount;
if (!in_array($this->mTitle->getNamespace(), $wgIgnoreNamespacesForEditCount)) {
$user->incEditCount();
}
$dbw->commit(__METHOD__);
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
// related variables correctly
$revision->setId($this->getLatest());
}
// Update links tables, site stats, etc.
$this->doEditUpdates($revision, $user, array('changed' => $changed, 'oldcountable' => $oldcountable));
if (!$changed) {
$status->warning('edit-no-change');
$revision = null;
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
} else {
// Create new article
$status->value['new'] = true;
$dbw->begin(__METHOD__);
$prepStatus = $content->prepareSave($this, $flags, $baseRevId, $user);
$status->merge($prepStatus);
if (!$status->isOK()) {
$dbw->rollback(__METHOD__);
wfProfileOut(__METHOD__);
示例9: revertTipOnArticle
function revertTipOnArticle($pageId, $revId)
{
global $wgParser;
// do not revert if no revId
if ($revId <= 0 || $revId == null || $revId == "") {
return false;
}
$undoRevision = Revision::newFromId($revId);
$previousRevision = $undoRevision ? $undoRevision->getPrevious() : null;
// do not revert if the page is wrong or changed..
if (is_null($undoRevision) || is_null($previousRevision) || $undoRevision->getPage() != $previousRevision->getPage() || $undoRevision->getPage() != $pageId) {
return false;
}
$title = Title::newFromID($pageId);
$article = new Article($title);
$undoRevisionText = $undoRevision->getText();
$currentText = $article->getContent();
$undoTips = Wikitext::splitTips(reset(Wikitext::getSection($undoRevisionText, "Tips", true)));
$prevTips = Wikitext::splitTips(reset(Wikitext::getSection($previousRevision->getText(), "Tips", true)));
$currentTipsSection = Wikitext::getSection($currentText, "Tips", true);
$currentTips = Wikitext::splitTips($currentTipsSection[0]);
$section = $currentTipsSection[1];
$undoTipsFormatted = array();
foreach ($undoTips as $tip) {
$undoTipsFormatted[] = self::cleanTip($tip);
}
$prevTipsFormatted = array();
foreach ($prevTips as $tip) {
$prevTipsFormatted[] = self::cleanTip($tip);
}
$badTips = array_diff($undoTipsFormatted, $prevTipsFormatted);
$resultTips = "== Tips ==";
foreach ($currentTips as $currentTip) {
$tip = self::cleanTip($currentTip);
if (in_array($tip, $badTips)) {
continue;
}
$resultTips .= "\n" . $currentTip;
}
$newText = $wgParser->replaceSection($currentText, $section, $resultTips);
$success = $article->doEdit($newText, 'reverting tip from revision ' . $revId, EDIT_UPDATE | EDIT_MINOR);
// mark the recent change as patrolled
if ($success) {
// should be ok to read from slave here because the change has been done earlier.
$dbr = wfGetDB(DB_SLAVE);
$rcid = $dbr->selectField('recentchanges', 'rc_id', array("rc_this_oldid={$revId}"));
RecentChange::markPatrolled($rcid);
PatrolLog::record($rcid, false);
}
return $success;
}
示例10: markpatrolled
/**
* Mark this particular edit as patrolled
*/
function markpatrolled()
{
global $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgUseRCPatrol, $wgUser;
$wgOut->setRobotpolicy('noindex,follow');
if (!$wgUseRCPatrol) {
$wgOut->errorpage('rcpatroldisabled', 'rcpatroldisabledtext');
return;
}
if ($wgUser->isAnon()) {
$wgOut->loginToUse();
return;
}
if ($wgOnlySysopsCanPatrol && !$wgUser->isAllowed('patrol')) {
$wgOut->sysopRequired();
return;
}
$rcid = $wgRequest->getVal('rcid');
if (!is_null($rcid)) {
RecentChange::markPatrolled($rcid);
$wgOut->setPagetitle(wfMsg('markedaspatrolled'));
$wgOut->addWikiText(wfMsg('markedaspatrolledtext'));
$rcTitle = Title::makeTitle(NS_SPECIAL, 'Recentchanges');
$wgOut->returnToMain(false, $rcTitle->getPrefixedText());
} else {
$wgOut->errorpage('markedaspatrollederror', 'markedaspatrollederrortext');
}
}
示例11: markPatrolled
public function markPatrolled()
{
global $wgUser;
$sk = $wgUser->getSkin();
$output = '';
if (wfRunHooks('MarkPatrolled', array(&$this->rcid, &$wgUser, false))) {
RecentChange::markPatrolled($this->rcid);
wfRunHooks('MarkPatrolledComplete', array(&$this->rcid, &$wgUser, false));
$output .= '<p>The selected ' . ($this->unmergeTimestamp ? 'unmerge' : 'merge') . ' has been marked as patrolled.</p>';
}
$rcTitle = Title::makeTitle(NS_SPECIAL, 'Recentchanges');
$output .= '<p>Return to ' . $sk->makeKnownLinkObj($rcTitle) . '.</p>';
return $output;
}
示例12: execute
function execute($par)
{
global $wgRequest, $wgOut, $wgUser;
$target = isset($par) ? $par : $wgRequest->getVal('target');
if ($target == $wgUser->getName()) {
$wgOut->addHTML(wfMsg('bunchpatrol_noselfpatrol'));
return;
}
$wgOut->setHTMLTitle('Bunch Patrol - wikiHow');
$sk = $wgUser->getSkin();
$dbr =& wfGetDB(DB_SLAVE);
$me = Title::makeTitle(NS_SPECIAL, "Bunchpatrol");
$unpatrolled = $dbr->selectField('recentchanges', array('count(*)'), array('rc_patrolled=0'));
if (!strlen($target)) {
$restrict = " AND (rc_namespace = 2 OR rc_namespace = 3) ";
$res = $dbr->query("SELECT rc_user, rc_user_text, COUNT(*) AS C\n\t\t\t\t\t\t\t\tFROM recentchanges\n\t\t\t\t\t\t\t\tWHERE rc_patrolled=0\n\t\t\t\t\t\t\t\t\t{$restrict}\n\t\t\t\t\t\t\t\tGROUP BY rc_user_text HAVING C > 2\n\t\t\t\t\t\t\t\tORDER BY C DESC");
$wgOut->addHTML("<table width='85%' align='center'>");
while (($row = $dbr->fetchObject($res)) != null) {
$u = User::newFromName($row->rc_user_text);
if ($u) {
$bpLink = SpecialPage::getTitleFor('Bunchpatrol', $u->getName());
$wgOut->addHTML("<tr><td>" . $sk->makeLinkObj($bpLink, $u->getName()) . "</td><td>{$row->C}</td>");
}
}
$dbr->freeResult($res);
$wgOut->addHTML("</table>");
return;
}
if ($wgRequest->wasPosted() && $wgUser->isAllowed('patrol')) {
$values = $wgRequest->getValues();
$vals = array();
foreach ($values as $key => $value) {
if (strpos($key, "rc_") === 0 && $value == 'on') {
$vals[] = str_replace("rc_", "", $key);
}
}
foreach ($vals as $val) {
RecentChange::markPatrolled($val);
PatrolLog::record($val, false);
}
$restrict = " AND (rc_namespace = 2 OR rc_namespace = 3) ";
$res = $dbr->query("SELECT rc_user, rc_user_text, COUNT(*) AS C\n\t\t\t\t\t\t\t\tFROM recentchanges\n\t\t\t\t\t\t\t\tWHERE rc_patrolled=0\n\t\t\t\t\t\t\t\t\t{$restrict}\n\t\t\t\t\t\t\t\tGROUP BY rc_user_text HAVING C > 2\n\t\t\t\t\t\t\t\tORDER BY C DESC");
$wgOut->addHTML("<table width='85%' align='center'>");
while (($row = $dbr->fetchObject($res)) != null) {
$u = User::newFromName($row->rc_user_text);
if ($u) {
$wgOut->addHTML("<tr><td>" . $sk->makeLinkObj($me, $u->getName(), "target=" . $u->getName()) . "</td><td>{$row->C}</td>");
}
}
$wgOut->addHTML("</table>");
return;
}
// don't show main namespace edits if there are < 500 total unpatrolled edits
$target = str_replace('-', ' ', $target);
$wgOut->addHTML("\n\t\t\t<script type='text/javascript'>\n\t\t\tfunction checkall(selected) {\n\t\t\t\tfor (i = 0; i < document.checkform.elements.length; i++) {\n\t\t\t\t\tvar e = document.checkform.elements[i];\n\t\t\t\t\tif (e.type=='checkbox') {\n\t\t\t\t\t\te.checked = selected;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t</script>\n\t\t\t<form method='POST' name='checkform' action='{$me->getFullURL()}'>\n\t\t\t<input type='hidden' name='target' value='{$target}'>\n\t\t\t");
if ($wgUser->isSysop()) {
$wgOut->addHTML("Select: <input type='button' onclick='checkall(true);' value='All'/>\n\t\t\t\t\t<input type='button' onclick='checkall(false);' value='None'/>\n\t\t\t\t");
}
$count = $this->writeBunchPatrolTableContent($dbr, $target, false);
if ($count > 0) {
$wgOut->addHTML("<input type='submit' value='" . wfMsg('submit') . "'>");
}
$wgOut->addHTML("</form>");
$wgOut->setPageTitle(wfMsg('bunchpatrol'));
if ($count == 0) {
$wgOut->addWikiText(wfMsg('bunchpatrol_nounpatrollededits', $target));
}
}
示例13: markPatrolledCallback
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;
}
示例14: setTags
private function setTags($titlesAndTagInfo, $tag, $userId, $rlId, $comment, $setPatrolled = false)
{
// XXX Attach a hook to delete tags from the collabwatchlistrevisiontag table as soon as the actual tags are deleted from the change_tags table
$allowedTagsAndInfo = $this->getCollabWatchlistTags($rlId);
if (!array_key_exists($tag, $allowedTagsAndInfo)) {
return false;
}
$dbw = wfGetDB(DB_MASTER);
foreach ($titlesAndTagInfo as $title => $infos) {
$rcIds = array();
// Add entries for the tag to the change_tags table
// optionally mark edit as patrolled
foreach ($infos as $infoKey => $info) {
ChangeTags::addTags($tag, $info['rc_id'], $info['rev_id']);
$rcIds[] = $info['rc_id'];
if ($setPatrolled) {
RecentChange::markPatrolled($info['rc_id']);
}
}
// Add the tagged revisions to the collaborative watchlist
$sql = 'INSERT IGNORE INTO collabwatchlistrevisiontag (ct_rc_id, ct_tag, cw_id, user_id, rrt_comment)
SELECT ct_rc_id, ct_tag, ' . $dbw->strencode($rlId) . ',' . $dbw->strencode($userId) . ',' . $dbw->addQuotes($comment) . ' FROM change_tag WHERE ct_tag = ? AND ct_rc_id ';
if (count($rcIds) > 1) {
$sql .= 'IN (' . $dbw->makeList($rcIds) . ')';
$params = array($tag);
} else {
$sql .= '= ?';
$params = array($tag, $rcIds[0]);
}
$prepSql = $dbw->prepare($sql);
$res = $dbw->execute($prepSql, $params);
$dbw->freePrepared($prepSql);
return true;
}
}
示例15: doEdit
//.........这里部分代码省略.........
# Update article, but only if changed.
# Make sure the revision is either completely inserted or not inserted at all
if (!$wgDBtransactions) {
$userAbort = ignore_user_abort(true);
}
$lastRevision = 0;
$revisionId = 0;
$changed = strcmp($text, $oldtext) != 0;
if ($changed) {
$this->mGoodAdjustment = (int) $this->isCountable($text) - (int) $this->isCountable($oldtext);
$this->mTotalAdjustment = 0;
$lastRevision = $dbw->selectField('page', 'page_latest', array('page_id' => $this->getId()));
if (!$lastRevision) {
# Article gone missing
wfDebug(__METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n");
wfProfileOut(__METHOD__);
return false;
}
$revision = new Revision(array('page' => $this->getId(), 'comment' => $summary, 'minor_edit' => $isminor, 'text' => $text));
$dbw->begin();
$revisionId = $revision->insertOn($dbw);
# Update page
$ok = $this->updateRevisionOn($dbw, $revision, $lastRevision);
if (!$ok) {
/* Belated edit conflict! Run away!! */
$good = false;
$dbw->rollback();
} else {
# Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
$rcid = RecentChange::notifyEdit($now, $this->mTitle, $isminor, $wgUser, $summary, $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId);
# Mark as patrolled if the user can do so
if ($GLOBALS['wgUseRCPatrol'] && $wgUser->isAllowed('autopatrol') && $wgUser->getOption('autopatrol') || in_array("bot", $wgUser->getGroups())) {
RecentChange::markPatrolled($rcid, $this);
PatrolLog::record($rcid, true);
}
}
//XXCHANGED - we ignore some namespace edits
if (!in_array($this->mTitle->getNamespace(), $wgIgnoreNamespacesForEditCount)) {
$wgUser->incEditCount();
}
$dbw->commit();
}
} else {
$revision = null;
// Keep the same revision ID, but do some updates on it
$revisionId = $this->getRevIdFetched();
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
if (!$wgDBtransactions) {
ignore_user_abort($userAbort);
}
if ($good) {
# Invalidate cache of this article and all pages using this article
# as a template. Partly deferred.
Article::onArticleEdit($this->mTitle);
# Update links tables, site stats, etc.
$this->editUpdates($text, $summary, $isminor, $now, $revisionId, $changed);
}
} else {
# Create new article
# Set statistics members
# We work out if it's countable after PST to avoid counter drift
# when articles are created with {{subst:}}