public static function doWatch(Title $title, User $user) { $page = WikiPage::factory($title); if (wfRunHooks('WatchArticle', array(&$user, &$page))) { $user->addWatch($title); wfRunHooks('WatchArticleComplete', array(&$user, &$page)); } return true; }
/** * @deprecated since 1.27 Use User::addWatch() * @return bool */ public function addWatch() { wfDeprecated(__METHOD__, '1.27'); $this->user->addWatch($this->getTitle(), $this->checkRights); return true; }
/** * Watch a page * @since 1.22 Returns Status, $checkRights parameter added * @param Title $title Page to watch/unwatch * @param User $user User who is watching/unwatching * @param int $checkRights Passed through to $user->addWatch() * @return Status */ public static function doWatch(Title $title, User $user, $checkRights = WatchedItem::CHECK_USER_RIGHTS) { if ($checkRights !== WatchedItem::IGNORE_USER_RIGHTS && !$user->isAllowed('editmywatchlist')) { return User::newFatalPermissionDeniedStatus('editmywatchlist'); } $page = WikiPage::factory($title); $status = Status::newFatal('hookaborted'); if (wfRunHooks('WatchArticle', array(&$user, &$page, &$status))) { $status = Status::newGood(); $user->addWatch($title, $checkRights); wfRunHooks('WatchArticleComplete', array(&$user, &$page)); } return $status; }
/** * Watch a page * @since 1.22 Returns Status, $checkRights parameter added * @param Title $title Page to watch/unwatch * @param User $user User who is watching/unwatching * @param bool $checkRights Passed through to $user->addWatch() * Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS. * @return Status */ public static function doWatch(Title $title, User $user, $checkRights = User::CHECK_USER_RIGHTS) { if ($checkRights && !$user->isAllowed('editmywatchlist')) { return User::newFatalPermissionDeniedStatus('editmywatchlist'); } $page = WikiPage::factory($title); $status = Status::newFatal('hookaborted'); if (Hooks::run('WatchArticle', [&$user, &$page, &$status])) { $status = Status::newGood(); $user->addWatch($title, $checkRights); Hooks::run('WatchArticleComplete', [&$user, &$page]); } return $status; }
public function addWatch(User $user) { if (!$this->isMain()) { $parent = $this->getTopParentObj(); if ($parent) { $user->addWatch($parent->getTitle()); } } else { $user->addWatch($this->title); } }
private function watch() { $this->user->addWatch(Title::newFromID($this->params['page_id'])); }
/** * Do standard deferred updates after page edit. * Every 1000th edit, prune the recent changes table. * @private * @param string $text */ function editUpdates($text) { global $wgDeferredUpdateList, $wgDBname, $wgMemc; global $wgMessageCache, $wgUser, $wgUseEnotif; wfSeedRandom(); if (0 == mt_rand(0, 999)) { # Periodically flush old entries from the recentchanges table. global $wgRCMaxAge; $dbw =& wfGetDB(DB_MASTER); $cutoff = $dbw->timestamp(time() - $wgRCMaxAge); $recentchanges = $dbw->tableName('recentchanges'); $sql = "DELETE FROM {$recentchanges} WHERE rc_timestamp < '{$cutoff}'"; //$dbw->query( $sql ); // HACK: disabled for now, slowness // re-enabled for commit of unrelated live changes -- TS $dbw->query($sql); } $id = $this->getID(); $title = $this->mTitle->getPrefixedDBkey(); $shortTitle = $this->mTitle->getDBkey(); if (0 != $id) { $u = new LinksUpdate($id, $title); array_push($wgDeferredUpdateList, $u); $u = new SiteStatsUpdate(0, 1, $this->mGoodAdjustment, $this->mTotalAdjustment); array_push($wgDeferredUpdateList, $u); $u = new SearchUpdate($id, $title, $text); array_push($wgDeferredUpdateList, $u); # If this is another user's page or talk page, update newtalk global $wgShowNewtalkForUserOrUserTalkPage; if (($this->mTitle->getNamespace() == NS_USER_TALK || $wgShowNewtalkForUserOrUserTalkPage && $this->mTitle->getNamespace() == NS_USER) && $shortTitle != $wgUser->getName()) { $other = User::newFromName($shortTitle); if (is_null($other) && User::isIP($shortTitle)) { // An anonymous user $other = new User(); $other->setName($shortTitle); } if ($other) { $other->addWatch($this->mTitle); $other->setNewtalk(1); $other->saveNewtalk(); } } if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { $wgMessageCache->replace($shortTitle, $text); } } }
/** * @param User $user * @return bool */ function fnQuestionAttribution($user) { global $wgMemc; $dbw = wfGetDB(DB_MASTER); $title = Title::newFromText($_SESSION['wsQuestionAsk']); $page_title_id = $title->getArticleID(); //watchlist page for them $user->addWatch($title); //get first revisionID $s = $dbw->selectRow('revision', array('rev_id'), array('rev_page' => $page_title_id), __METHOD__, array("ORDER BY" => "rev_id ASC", "LIMIT" => 1)); $revision_id = $s->rev_id; //change neccessary tables $dbw->update('revision', array('rev_user' => $user->getID(), 'rev_user_text' => $user->getName()), array('rev_id' => $revision_id), __METHOD__); $dbw->commit(__METHOD__); $dbw->update('recentchanges', array('rc_user' => $user->getID(), 'rc_user_text' => $user->getName()), array('rc_cur_id ' => $page_title_id, 'rc_new' => 1), __METHOD__); $dbw->commit(__METHOD__); //if the page happens to get deleted in between the anon asking a question //and registration, we have to also update the archive $dbw->update('archive', array('ar_user' => $user->getID(), 'ar_user_text' => $user->getName()), array('ar_title ' => $title->getDBKey()), __METHOD__); $dbw->commit(__METHOD__); //clear cache $title->invalidateCache(); $title->purgeSquid(); $key = wfMemcKey('answer_author', $page_title_id); $wgMemc->delete($key); return true; }