Exemplo n.º 1
0
 /**
  * Set the User object.
  *
  * @access	public
  * @param	object	Mediawiki User
  * @return	boolean Success
  */
 public function setUser(User $user)
 {
     $this->user = $user;
     $this->redisListKey = 'globalwatchlist:list:' . \CurseAuthUser::getInstance($this->user)->getId();
     $this->redisSitesKey = 'globalwatchlist:visibleSites:' . \CurseAuthUser::getInstance($this->user)->getId();
 }
 /**
  * Handles removed watched articles to the global watch list.
  *
  * @access	public
  * @param	object	User object of the user who unwatched this page.
  * @param	object	Article object of the unwatched page.
  * @return	boolean	True
  */
 public static function onUnwatchArticleComplete(User $user, WikiPage $article)
 {
     if (!$article->mDataLoaded) {
         $article->loadPageData();
     }
     $curseUser = \CurseAuthUser::getInstance($user);
     if (!$curseUser->getId() || $article->mTitle->mArticleID < 1) {
         return true;
     }
     //The newFromUser function will check if the user is valid.  False will be return if not.
     $gwl = globalWatchlist::newFromUser($user);
     if ($gwl !== false && $gwl->removeArticle($article) === true) {
         //If removing the specific page the user requested to unwatch was successful then we need to remove the associated namespace page.
         $title = Title::newFromText($article->mTitle->getText(), MWNamespace::getAssociated($article->mTitle->mNamespace));
         $associated = new WikiPage($title);
         if (!$associated->mDataLoaded) {
             $associated->loadPageData();
         }
         $gwl->removeArticle($associated);
         //Save since at least the requested page to unwatch was successful lets save it.  If the $associated page is not removed successfully we do not want it to stop the process.
         $success = $gwl->save();
     }
     return true;
 }