Merge "In LinkHolderArray::doVariants(), redlinks need to be checked as well."
[lhc/web/wiklou.git] / includes / Article.php
index fdf0820..3b259e2 100644 (file)
@@ -496,7 +496,7 @@ class Article extends Page {
                if ( $outputPage->isPrintable() ) {
                        $parserOptions->setIsPrintable( true );
                        $parserOptions->setEditSection( false );
-               } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit' ) ) {
+               } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
                        $parserOptions->setEditSection( false );
                }
 
@@ -956,7 +956,7 @@ class Article extends Page {
                $user = $this->getContext()->getUser();
                $rcid = $request->getVal( 'rcid' );
 
-               if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) {
+               if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol', $user ) ) {
                        return;
                }
 
@@ -1050,16 +1050,12 @@ class Article extends Page {
                } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
                        // Use the default message text
                        $text = $this->getTitle()->getDefaultMessageText();
+               } elseif ( $this->getTitle()->quickUserCan( 'create', $this->getContext()->getUser() )
+                       && $this->getTitle()->quickUserCan( 'edit', $this->getContext()->getUser() )
+               ) {
+                       $text = wfMsgNoTrans( 'noarticletext' );
                } else {
-                       $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $this->getContext()->getUser() );
-                       $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getContext()->getUser() );
-                       $errors = array_merge( $createErrors, $editErrors );
-
-                       if ( !count( $errors ) ) {
-                               $text = wfMsgNoTrans( 'noarticletext' );
-                       } else {
-                               $text = wfMsgNoTrans( 'noarticletext-nopermission' );
-                       }
+                       $text = wfMsgNoTrans( 'noarticletext-nopermission' );
                }
                $text = "<div class='noarticletext'>\n$text\n</div>";
 
@@ -1137,9 +1133,11 @@ class Article extends Page {
 
                $current = ( $oldid == $this->mPage->getLatest() );
                $language = $this->getContext()->getLanguage();
-               $td = $language->timeanddate( $timestamp, true );
-               $tddate = $language->date( $timestamp, true );
-               $tdtime = $language->time( $timestamp, true );
+               $user = $this->getContext()->getUser();
+
+               $td = $language->userTimeAndDate( $timestamp, $user );
+               $tddate = $language->userDate( $timestamp, $user );
+               $tdtime = $language->userTime( $timestamp, $user );
 
                # Show user links if allowed to see them. If hidden, then show them only if requested...
                $userlinks = Linker::revUserTools( $revision, !$unhide );
@@ -1224,7 +1222,7 @@ class Article extends Page {
                                array( 'known', 'noclasses' )
                        );
 
-               $cdel = Linker::getRevDeleteLink( $this->getContext()->getUser(), $revision, $this->getTitle() );
+               $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
                if ( $cdel !== '' ) {
                        $cdel .= ' ';
                }
@@ -1371,10 +1369,12 @@ class Article extends Page {
 
                        $this->doDelete( $reason, $suppress );
 
-                       if ( $request->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
-                               WatchAction::doWatch( $title, $user );
-                       } elseif ( $title->userIsWatching() ) {
-                               WatchAction::doUnwatch( $title, $user );
+                       if ( $user->isLoggedIn() && $request->getCheck( 'wpWatch' ) != $user->isWatched( $title ) ) {
+                               if ( $request->getCheck( 'wpWatch' ) ) {
+                                       WatchAction::doWatch( $title, $user );
+                               } else {
+                                       WatchAction::doUnwatch( $title, $user );
+                               }
                        }
 
                        return;
@@ -1406,7 +1406,7 @@ class Article extends Page {
                        }
                }
 
-               return $this->confirmDelete( $reason );
+               $this->confirmDelete( $reason );
        }
 
        /**
@@ -1438,7 +1438,7 @@ class Article extends Page {
                } else {
                        $suppress = '';
                }
-               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
+               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $this->getTitle() );
 
                $form = Xml::openElement( 'form', array( 'method' => 'post',
                        'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
@@ -1522,7 +1522,8 @@ class Article extends Page {
        public function doDelete( $reason, $suppress = false ) {
                $error = '';
                $outputPage = $this->getContext()->getOutput();
-               if ( $this->mPage->doDeleteArticle( $reason, $suppress, 0, true, $error ) ) {
+               $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
+               if ( $status->isGood() ) {
                        $deleted = $this->getTitle()->getPrefixedText();
 
                        $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
@@ -1535,8 +1536,9 @@ class Article extends Page {
                } else {
                        $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
                        if ( $error == '' ) {
+                               $errors = $status->getErrorsArray();
                                $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
-                                       array( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
+                                       $errors[0]
                                );
                                $outputPage->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );