Deprecated Title::userIsWatching(); use User::isWatched() instead.
[lhc/web/wiklou.git] / includes / ProtectionForm.php
index 5341fe5..31ed87f 100644 (file)
@@ -236,11 +236,8 @@ class ProtectionForm {
                                wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
                }
 
-               $titleLink = Linker::link( $this->mTitle );
-               $wgOut->setSubtitle( wfMsg( 'protect-backlink', $titleLink ) );
-
+               $wgOut->addBacklinkSubtitle( $this->mTitle );
                $wgOut->addHTML( $this->buildForm() );
-
                $this->showLogExtract( $wgOut );
        }
 
@@ -250,7 +247,7 @@ class ProtectionForm {
         * @return Boolean: success
         */
        function save() {
-               global $wgRequest, $wgUser;
+               global $wgRequest, $wgUser, $wgOut;
 
                # Permission check!
                if ( $this->disabled ) {
@@ -297,14 +294,11 @@ class ProtectionForm {
                        !(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) )
                        $this->mCascade = false;
 
-               if ($this->mTitle->exists()) {
-                       $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $reasonstr, $this->mCascade, $expiry );
-               } else {
-                       $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $reasonstr, $expiry['create'] );
-               }
+               $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
 
-               if( !$ok ) {
-                       throw new FatalError( "Unknown error at restriction save time." );
+               if ( !$status->isOK() ) {
+                       $this->show( $wgOut->parseInline( $status->getWikiText() ) );
+                       return false;
                }
 
                /**
@@ -324,12 +318,14 @@ class ProtectionForm {
                        return false;
                }
 
-               if ( $wgRequest->getCheck( 'mwProtectWatch' ) && $wgUser->isLoggedIn() ) {
-                       WatchAction::doWatch( $this->mTitle, $wgUser );
-               } elseif ( $this->mTitle->userIsWatching() ) {
-                       WatchAction::doUnwatch( $this->mTitle, $wgUser );
+               if ( $wgUser->isLoggedIn() && $wgRequest->getCheck( 'mwProtectWatch' ) != $wgUser->isWatched( $this->mTitle ) ) {
+                       if ( $wgRequest->getCheck( 'mwProtectWatch' ) ) {
+                               WatchAction::doWatch( $this->mTitle, $wgUser );
+                       } else {
+                               WatchAction::doUnwatch( $this->mTitle, $wgUser );
+                       }
                }
-               return $ok;
+               return true;
        }
 
        /**