Exemplo n.º 1
0
 /**
  * Enables commenting for a blog post that has been moved from another namespace
  * @param Title $oOldTitle An object for the old article's name
  * @param Title $oNewTitle An object for the new article's name
  * @param User $oUser
  * @param integer $iOldId
  * @param integer $iNewId
  * @return bool
  */
 public static function onTitleMoveComplete(Title $oOldTitle, Title $oNewTitle, User $oUser, $iOldId, $iNewId)
 {
     global $wgArticleCommentsNamespaces;
     wfProfileIn(__METHOD__);
     // Enables comments if an article has been moved to
     // a Blog namespace from a non-blog one
     // and if the new namespace has comments enabled.
     if (ArticleComment::isBlog($oNewTitle) && in_array($oNewTitle->getNamespace(), $wgArticleCommentsNamespaces) && $oOldTitle->getNamespace() !== $oNewTitle->getNamespace()) {
         BlogArticle::setProps($oNewTitle->getArticleID(), ['commenting' => '1']);
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * Hook handler
  *
  * @static
  * @param Title $title
  * @param User $user
  * @param $action
  * @param $result
  * @return bool
  */
 public static function userCan($title, $user, $action, &$result)
 {
     $namespace = $title->getNamespace();
     // we only care if this is a talk namespace
     if (MWNamespace::getSubject($namespace) == $namespace) {
         return true;
     }
     //for blog comments BlogLockdown is checking rights
     if (ArticleComment::isBlog()) {
         return true;
     }
     $parts = ArticleComment::explode($title->getText());
     //not article comment
     if (count($parts['partsStripped']) == 0) {
         return true;
     }
     $firstRev = $title->getFirstRevision();
     if ($firstRev && $user->getName() == $firstRev->getUserText()) {
         return true;
     }
     switch ($action) {
         case 'move':
         case 'move-target':
             return $user->isAllowed('commentmove');
             break;
         case 'edit':
             return $user->isAllowed('commentedit');
             break;
         case 'delete':
             return $user->isAllowed('commentdelete');
             break;
     }
     return true;
 }
 /**
  * TODO: Document what the parameters are.
  */
 static function ChangesListInsertArticleLink($changeList, &$articlelink, &$s, $rc, $unpatrolled, $watched)
 {
     $rcTitle = $rc->getAttribute('rc_title');
     $rcNamespace = $rc->getAttribute('rc_namespace');
     $title = Title::newFromText($rcTitle, $rcNamespace);
     if (MWNamespace::isTalk($rcNamespace) && ArticleComment::isTitleComment($title)) {
         $parts = ArticleComment::explode($rcTitle);
         $titleMainArticle = Title::newFromText($parts['title'], MWNamespace::getSubject($rcNamespace));
         //fb#15143
         if ($titleMainArticle instanceof Title) {
             if (ArticleComment::isBlog()) {
                 $messageKey = 'article-comments-rc-blog-comment';
             } else {
                 $messageKey = 'article-comments-rc-comment';
             }
             $articleId = $title->getArticleId();
             $articlelink = wfMsgExt($messageKey, array('parseinline'), $title->getFullURL("permalink={$articleId}#comm-{$articleId}"), $titleMainArticle->getText());
         } else {
             //it should never happened because $rcTitle is never empty,
             //ArticleComment::explode() always returns an array with not-empty 'title' element,
             //(both files: ArticleComments/classes/ArticleComments.class.php
             //and WallArticleComment/classes/ArticleComments.class.php have
             //the same definition of explode() method)
             //and static constructor newFromText() should create a Title instance for $parts['title']
             Wikia::log(__METHOD__, false, 'WALL_ARTICLE_COMMENT_ERROR: no main article title: ' . print_r($parts, true) . ' namespace: ' . $rcNamespace);
         }
     }
     return true;
 }