当前位置: 首页>>代码示例>>PHP>>正文


PHP WatchAction::doWatch方法代码示例

本文整理汇总了PHP中WatchAction::doWatch方法的典型用法代码示例。如果您正苦于以下问题:PHP WatchAction::doWatch方法的具体用法?PHP WatchAction::doWatch怎么用?PHP WatchAction::doWatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WatchAction的用法示例。


在下文中一共展示了WatchAction::doWatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     $user = $this->getUser();
     if (!$user->isLoggedIn()) {
         $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
     }
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['title']);
     if (!$title || $title->getNamespace() < 0) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $res['unwatched'] = '';
         $res['message'] = $this->msg('removedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         $success = UnwatchAction::doUnwatch($title, $user);
     } else {
         $res['watched'] = '';
         $res['message'] = $this->msg('addedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         $success = WatchAction::doWatch($title, $user);
     }
     if (!$success) {
         $this->dieUsageMsg('hookaborted');
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:26,代码来源:ApiWatch.php

示例2: execute

	public function execute() {
		$user = $this->getUser();
		if ( !$user->isLoggedIn() ) {
			$this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
		}
		if ( !$user->isAllowed( 'editmywatchlist' ) ) {
			$this->dieUsage( 'You don\'t have permission to edit your watchlist', 'permissiondenied' );
		}

		$params = $this->extractRequestParams();
		$title = Title::newFromText( $params['title'] );

		if ( !$title || $title->isExternal() || !$title->canExist() ) {
			$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
		}

		$res = array( 'title' => $title->getPrefixedText() );

		// Currently unnecessary, code to act as a safeguard against any change in current behavior of uselang
		// Copy from ApiParse
		$oldLang = null;
		if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) {
			$oldLang = $this->getContext()->getLanguage(); // Backup language
			$this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
		}

		if ( $params['unwatch'] ) {
			$res['unwatched'] = '';
			$res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
			$status = UnwatchAction::doUnwatch( $title, $user );
		} else {
			$res['watched'] = '';
			$res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
			$status = WatchAction::doWatch( $title, $user );
		}

		if ( !is_null( $oldLang ) ) {
			$this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
		}

		if ( !$status->isOK() ) {
			$this->dieStatus( $status );
		}
		$this->getResult()->addValue( null, $this->getModuleName(), $res );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:45,代码来源:ApiWatch.php

示例3: move

 public function move($params)
 {
     global $wgUser;
     $currentUser = $wgUser;
     $wgUser = User::newFromId($this->createdBy);
     $currentPageName = $this->title->getText();
     if ($params['use_regex']) {
         $newPageName = preg_replace("/{$params['target_str']}/U", $params['replacement_str'], $currentPageName);
     } else {
         $newPageName = str_replace($params['target_str'], $params['replacement_str'], $currentPageName);
     }
     $newTitle = Title::newFromText($newPageName, $this->title->getNamespace());
     $result = $this->title->moveTo($newTitle, true, $params['edit_summary'], $params['create_redirect']);
     if ($result == true && $params['watch_page']) {
         WatchAction::doWatch($newTitle, $wgUser);
     }
     $wgUser = $currentUser;
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ReplaceTextTask.php

示例4: addUserToDefaultWatchlistTask

 /**
  * Adds a user to watchlists of all articles defined in the
  * global $wgAutoFollowWatchlist variable.
  * @param integer $iUserId The user's ID
  */
 public function addUserToDefaultWatchlistTask($iUserId)
 {
     global $wgAutoFollowWatchlist;
     if (!empty($wgAutoFollowWatchlist)) {
         $oUser = \User::newFromId($iUserId);
         $aWatchSuccess = $aWatchFail = [];
         foreach ($wgAutoFollowWatchlist as $sTitleText) {
             $oTitle = \Title::newFromText($sTitleText);
             if ($oTitle instanceof \Title) {
                 \WatchAction::doWatch($oTitle, $oUser);
                 $aWatchSuccess[] = $sTitleText;
             } else {
                 $aWatchFail[] = $sTitleText;
             }
         }
         if (count($aWatchFail) === 0) {
             $this->setFlag($oUser);
         }
         $this->logResults($oUser, $aWatchSuccess, $aWatchFail);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:AutoFollowTask.class.php

示例5: delete

 function delete()
 {
     global $wgUser, $wgOut, $wgRequest;
     $confirm = $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'));
     $reason = $wgRequest->getText('wpReason');
     # This code desperately needs to be totally rewritten
     # Check permissions
     $permission_errors = $this->mTitle->getUserPermissionsErrors('mv_delete_mvd', $wgUser);
     if (count($permission_errors) > 0) {
         $wgOut->showPermissionsErrorPage($permission_errors);
         return;
     }
     $wgOut->setPagetitle(wfMsg('confirmdelete'));
     # Better double-check that it hasn't been deleted yet!
     $dbw = wfGetDB(DB_MASTER);
     $conds = $this->mTitle->pageCond();
     $latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
     if ($latest === false) {
         $wgOut->showFatalError(wfMsg('cannotdelete'));
         return;
     }
     if ($confirm) {
         $this->doDelete($reason);
         if ($wgRequest->getCheck('wpWatch')) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } elseif ($this->mTitle->userIsWatching()) {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
         return;
     }
     // Generate deletion reason
     $hasHistory = false;
     $reason = $this->generateReason($hasHistory);
     // If the page has a history, insert a warning
     if ($hasHistory && !$confirm) {
         $skin = $wgUser->getSkin();
         $wgOut->addHTML('<strong>' . wfMsg('historywarning') . ' ' . $skin->historyLink() . '</strong>');
     }
     return $this->confirmDelete('', $reason);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:40,代码来源:MV_DataPage.php

示例6: doWatch

 /**
  * Add this page to $wgUser's watchlist
  *
  * This is safe to be called multiple times
  *
  * @return bool true on successful watch operation
  * @deprecated since 1.18
  */
 public function doWatch()
 {
     global $wgUser;
     wfDeprecated(__METHOD__, '1.18');
     return WatchAction::doWatch($this->getTitle(), $wgUser);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:Article.php

示例7: run

 /**
  * Run a replaceText job
  * @return boolean success
  */
 function run()
 {
     wfProfileIn(__METHOD__);
     if (is_null($this->title)) {
         $this->error = "replaceText: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     if (array_key_exists('move_page', $this->params)) {
         global $wgUser;
         $actual_user = $wgUser;
         $wgUser = User::newFromId($this->params['user_id']);
         $cur_page_name = $this->title->getText();
         if ($this->params['use_regex']) {
             $new_page_name = preg_replace("/" . $this->params['target_str'] . "/U", $this->params['replacement_str'], $cur_page_name);
         } else {
             $new_page_name = str_replace($this->params['target_str'], $this->params['replacement_str'], $cur_page_name);
         }
         $new_title = Title::newFromText($new_page_name, $this->title->getNamespace());
         $reason = $this->params['edit_summary'];
         $create_redirect = $this->params['create_redirect'];
         $this->title->moveTo($new_title, true, $reason, $create_redirect);
         if ($this->params['watch_page']) {
             if (class_exists('WatchAction')) {
                 // Class was added in MW 1.19
                 WatchAction::doWatch($new_title, $wgUser);
             } else {
                 Action::factory('watch', new WikiPage($new_title))->execute();
             }
         }
         $wgUser = $actual_user;
     } else {
         // WikiPage::getContent() replaced
         // Article::fetchContent() starting in MW 1.21.
         if (method_exists('WikiPage', 'getContent')) {
             if ($this->title->getContentModel() !== CONTENT_MODEL_WIKITEXT) {
                 $this->error = 'replaceText: Wiki page "' . $this->title->getPrefixedDBkey() . '" does not hold regular wikitext.';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $wikiPage = new WikiPage($this->title);
             // Is this check necessary?
             if (!$wikiPage) {
                 $this->error = 'replaceText: Wiki page not found for "' . $this->title->getPrefixedDBkey() . '."';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $article_text = $wikiPage->getContent()->getNativeData();
         } else {
             $article = new Article($this->title, 0);
             if (!$article) {
                 $this->error = 'replaceText: Article not found for "' . $this->title->getPrefixedDBkey() . '"';
                 wfProfileOut(__METHOD__);
                 return false;
             }
             $article_text = $article->fetchContent();
         }
         wfProfileIn(__METHOD__ . '-replace');
         $target_str = $this->params['target_str'];
         $replacement_str = $this->params['replacement_str'];
         // @todo FIXME eh?
         $num_matches;
         if ($this->params['use_regex']) {
             $new_text = preg_replace('/' . $target_str . '/U', $replacement_str, $article_text, -1, $num_matches);
         } else {
             $new_text = str_replace($target_str, $replacement_str, $article_text, $num_matches);
         }
         // If there's at least one replacement, modify the page,
         // using the passed-in edit summary.
         if ($num_matches > 0) {
             // Change global $wgUser variable to the one
             // specified by the job only for the extent of
             // this replacement.
             global $wgUser;
             $actual_user = $wgUser;
             $wgUser = User::newFromId($this->params['user_id']);
             $edit_summary = $this->params['edit_summary'];
             $flags = EDIT_MINOR;
             if ($wgUser->isAllowed('bot')) {
                 $flags |= EDIT_FORCE_BOT;
             }
             if (method_exists('WikiPage', 'getContent')) {
                 $new_content = new WikitextContent($new_text);
                 $wikiPage->doEditContent($new_content, $edit_summary, $flags);
             } else {
                 $article->doEdit($new_text, $edit_summary, $flags);
             }
             $wgUser = $actual_user;
         }
         wfProfileOut(__METHOD__ . '-replace');
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:98,代码来源:ReplaceTextJob.php

示例8: watchTitle

 private function watchTitle(Title $title, User $user, array $params, $compatibilityMode = false)
 {
     if (!$title->isWatchable()) {
         return array('title' => $title->getPrefixedText(), 'watchable' => 0);
     }
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $status = UnwatchAction::doUnwatch($title, $user);
         $res['unwatched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('removedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     } else {
         $status = WatchAction::doWatch($title, $user);
         $res['watched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('addedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     }
     if (!$status->isOK()) {
         if ($compatibilityMode) {
             $this->dieStatus($status);
         }
         $res['error'] = $this->getErrorFromStatus($status);
     }
     return $res;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:27,代码来源:ApiWatch.php

示例9: performUpload

 /**
  * Really perform the upload. Stores the file in the local repo, watches
  * if necessary and runs the UploadComplete hook.
  *
  * @param $comment
  * @param $pageText
  * @param $watch
  * @param $user User
  *
  * @return Status indicating the whether the upload succeeded.
  */
 public function performUpload($comment, $pageText, $watch, $user)
 {
     wfProfileIn(__METHOD__);
     $status = $this->getLocalFile()->upload($this->mTempPath, $comment, $pageText, File::DELETE_SOURCE, $this->mFileProps, false, $user);
     if ($status->isGood()) {
         if ($watch) {
             WatchAction::doWatch($this->getLocalFile()->getTitle(), $user, WatchedItem::IGNORE_USER_RIGHTS);
         }
         wfRunHooks('UploadComplete', array(&$this));
     }
     wfProfileOut(__METHOD__);
     return $status;
 }
开发者ID:elf-pavlik,项目名称:web-payments.org,代码行数:24,代码来源:UploadBase.php

示例10: commitWatch

 /**
  * Commit the change of watch status
  */
 protected function commitWatch()
 {
     global $wgUser;
     if ($this->watchthis xor $this->mTitle->userIsWatching()) {
         $dbw = wfGetDB(DB_MASTER);
         $dbw->begin();
         if ($this->watchthis) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } else {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
         $dbw->commit();
     }
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:17,代码来源:EditPage.php

示例11: processForm


//.........这里部分代码省略.........
             # Disallow hiding users with many edits for performance.
             return array(array('ipb_hide_invalid', Message::numParam($wgHideUserContribLimit)));
         } elseif (!$data['Confirm']) {
             return array('ipb-confirmhideuser', 'ipb-confirmaction');
         }
     }
     # Create block object.
     $block = new Block();
     $block->setTarget($target);
     $block->setBlocker($performer);
     # Truncate reason for whole multibyte characters
     $block->mReason = $wgContLang->truncate($data['Reason'][0], 255);
     $block->mExpiry = self::parseExpiryInput($data['Expiry']);
     $block->prevents('createaccount', $data['CreateAccount']);
     $block->prevents('editownusertalk', !$wgBlockAllowsUTEdit || $data['DisableUTEdit']);
     $block->prevents('sendemail', $data['DisableEmail']);
     $block->isHardblock($data['HardBlock']);
     $block->isAutoblocking($data['AutoBlock']);
     $block->mHideName = $data['HideUser'];
     $reason = array('hookaborted');
     if (!Hooks::run('BlockIp', array(&$block, &$performer, &$reason))) {
         return $reason;
     }
     # Try to insert block. Is there a conflicting block?
     $status = $block->insert();
     if (!$status) {
         # Indicates whether the user is confirming the block and is aware of
         # the conflict (did not change the block target in the meantime)
         $blockNotConfirmed = !$data['Confirm'] || array_key_exists('PreviousTarget', $data) && $data['PreviousTarget'] !== $target;
         # Special case for API - bug 32434
         $reblockNotAllowed = array_key_exists('Reblock', $data) && !$data['Reblock'];
         # Show form unless the user is already aware of this...
         if ($blockNotConfirmed || $reblockNotAllowed) {
             return array(array('ipb_already_blocked', $block->getTarget()));
             # Otherwise, try to update the block...
         } else {
             # This returns direct blocks before autoblocks/rangeblocks, since we should
             # be sure the user is blocked by now it should work for our purposes
             $currentBlock = Block::newFromTarget($target);
             if ($block->equals($currentBlock)) {
                 return array(array('ipb_already_blocked', $block->getTarget()));
             }
             # If the name was hidden and the blocking user cannot hide
             # names, then don't allow any block changes...
             if ($currentBlock->mHideName && !$performer->isAllowed('hideuser')) {
                 return array('cant-see-hidden-user');
             }
             $currentBlock->isHardblock($block->isHardblock());
             $currentBlock->prevents('createaccount', $block->prevents('createaccount'));
             $currentBlock->mExpiry = $block->mExpiry;
             $currentBlock->isAutoblocking($block->isAutoblocking());
             $currentBlock->mHideName = $block->mHideName;
             $currentBlock->prevents('sendemail', $block->prevents('sendemail'));
             $currentBlock->prevents('editownusertalk', $block->prevents('editownusertalk'));
             $currentBlock->mReason = $block->mReason;
             $status = $currentBlock->update();
             $logaction = 'reblock';
             # Unset _deleted fields if requested
             if ($currentBlock->mHideName && !$data['HideUser']) {
                 RevisionDeleteUser::unsuppressUserName($target, $userId);
             }
             # If hiding/unhiding a name, this should go in the private logs
             if ((bool) $currentBlock->mHideName) {
                 $data['HideUser'] = true;
             }
         }
     } else {
         $logaction = 'block';
     }
     Hooks::run('BlockIpComplete', array($block, $performer));
     # Set *_deleted fields if requested
     if ($data['HideUser']) {
         RevisionDeleteUser::suppressUserName($target, $userId);
     }
     # Can't watch a rangeblock
     if ($type != Block::TYPE_RANGE && $data['Watch']) {
         WatchAction::doWatch(Title::makeTitle(NS_USER, $target), $performer, WatchedItem::IGNORE_USER_RIGHTS);
     }
     # Block constructor sanitizes certain block options on insert
     $data['BlockEmail'] = $block->prevents('sendemail');
     $data['AutoBlock'] = $block->isAutoblocking();
     # Prepare log parameters
     $logParams = array();
     $logParams['5::duration'] = $data['Expiry'];
     $logParams['6::flags'] = self::blockLogFlags($data, $type);
     # Make log entry, if the name is hidden, put it in the suppression log
     $log_type = $data['HideUser'] ? 'suppress' : 'block';
     $logEntry = new ManualLogEntry($log_type, $logaction);
     $logEntry->setTarget(Title::makeTitle(NS_USER, $target));
     $logEntry->setComment($data['Reason'][0]);
     $logEntry->setPerformer($performer);
     $logEntry->setParameters($logParams);
     # Relate log ID to block IDs (bug 25763)
     $blockIds = array_merge(array($status['id']), $status['autoIds']);
     $logEntry->setRelations(array('ipb_id' => $blockIds));
     $logId = $logEntry->insert();
     $logEntry->publish($logId);
     # Report to the user
     return true;
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:101,代码来源:SpecialBlock.php

示例12: performUpload

 /**
  * Really perform the upload. Stores the file in the local repo, watches
  * if necessary and runs the UploadComplete hook.
  *
  * @param string $comment
  * @param string $pageText
  * @param bool $watch Whether the file page should be added to user's watchlist.
  *   (This doesn't check $user's permissions.)
  * @param User $user
  * @param string[] $tags Change tags to add to the log entry and page revision.
  *   (This doesn't check $user's permissions.)
  * @return Status Indicating the whether the upload succeeded.
  */
 public function performUpload($comment, $pageText, $watch, $user, $tags = [])
 {
     $this->getLocalFile()->load(File::READ_LATEST);
     $props = $this->mFileProps;
     $error = null;
     Hooks::run('UploadVerifyUpload', [$this, $user, $props, $comment, $pageText, &$error]);
     if ($error) {
         if (!is_array($error)) {
             $error = [$error];
         }
         return call_user_func_array('Status::newFatal', $error);
     }
     $status = $this->getLocalFile()->upload($this->mTempPath, $comment, $pageText, File::DELETE_SOURCE, $props, false, $user, $tags);
     if ($status->isGood()) {
         if ($watch) {
             WatchAction::doWatch($this->getLocalFile()->getTitle(), $user, User::IGNORE_USER_RIGHTS);
         }
         Hooks::run('UploadComplete', [&$this]);
         $this->postProcessUpload();
     }
     return $status;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:UploadBase.php

示例13: save

 /**
  * @author Federico "Lox" Lucignano
  *
  * overrides TopListBase::save
  */
 public function save($mode = TOPLISTS_SAVE_AUTODETECT)
 {
     global $wgMemc, $wgUser;
     $errors = array();
     $mode = $this->_detectProcessingMode($mode);
     $checkResult = $this->checkForProcessing($mode);
     if ($checkResult === true) {
         $contentText = '';
         $relatedArticle = $this->getRelatedArticle();
         if (!empty($relatedArticle)) {
             $contentText .= ' ' . TOPLIST_ATTRIBUTE_RELATED . '="' . htmlspecialchars($relatedArticle->getPrefixedText()) . '"';
         }
         $picture = $this->getPicture();
         if (!empty($picture)) {
             $contentText .= ' ' . TOPLIST_ATTRIBUTE_PICTURE . '="' . htmlspecialchars($picture->getText()) . '"';
         }
         $description = $this->getDescription();
         if (!empty($description)) {
             $contentText .= ' ' . TOPLIST_ATTRIBUTE_DESCRIPTION . '="' . htmlspecialchars($description) . '"';
         }
         $contentText .= ' ' . TOPLIST_ATTRIBUTE_LASTUPDATE . '="' . wfTimestampNow() . '"';
         $summaryMsg = null;
         $editMode = null;
         if ($mode == TOPLISTS_SAVE_CREATE) {
             //$summaryMsg = 'toplists-list-creation-summary';
             $editMode = EDIT_NEW;
         } else {
             //$summaryMsg = 'toplists-list-update-summary';
             $editMode = EDIT_UPDATE;
         }
         $article = $this->getArticle();
         $status = $article->doEdit('<' . TOPLIST_TAG . "{$contentText} />[[Category:" . wfMsgForContent('toplists-category') . "]]", $this->_getItemsSummaryStatusMsg(), $editMode);
         if ($editMode == EDIT_NEW) {
             WatchAction::doWatch($article->mTitle, $wgUser);
         }
         if (!$status->isOK()) {
             foreach ($status->getErrorsArray() as $msg) {
                 $errors[] = array('msg' => $msg, 'params' => null);
             }
         } else {
             //reset vote counters for each items, to avoid caching issues
             foreach ($this->getItems(true) as $item) {
                 $item->resetVotesCount();
             }
             $wgMemc->set($this->_getNeedRefreshCacheKey(), true);
         }
     } else {
         $errors = array_merge($errors, $checkResult);
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:TopList.class.php

示例14: commitWatch

 /**
  * Commit the change of watch status
  */
 protected function commitWatch()
 {
     global $wgUser;
     if ($wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched($this->mTitle)) {
         $dbw = wfGetDB(DB_MASTER);
         $dbw->begin(__METHOD__);
         if ($this->watchthis) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } else {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
         $dbw->commit(__METHOD__);
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:17,代码来源:EditPage.php

示例15: foreach

        continue;
    }
    if ($user->getGlobalPreference('marketingallowed') != 1) {
        continue;
    }
    if (!$user->isEmailConfirmed()) {
        continue;
    }
    if ($user->getEditCount() == 0) {
        continue;
    }
    foreach ($textsToWatch[$wgLanguageCode] as $text) {
        $titlesToWatch[] = Title::newFromText($text);
    }
    $status = false;
    foreach ($titlesToWatch as $title) {
        $logParams = ['user_id' => $row['user_id'], 'user_name' => $user->getName(), 'user_lang' => $userLanguage, 'title' => $title->getPrefixedText()];
        if ($title instanceof Title) {
            WatchAction::doWatch($title, $user);
            $status = true;
            \Wikia\Logger\WikiaLogger::instance()->info("AutoFollow: User {$user->getName()} added to watchlist of {$title->getPrefixedText()}.", $logParams);
        } else {
            // Log error to check for typos etc. Can be deleted when tested in production enviroment.
            \Wikia\Logger\WikiaLogger::instance()->error("AutoFollow: Invalid article name in {$userLanguage}", $logParams);
        }
    }
    if ($status) {
        $user->setGlobalFlag($alreadyWatchedKey, 1);
        $user->saveSettings();
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:AutoFollow.php


注:本文中的WatchAction::doWatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。