+
+ global $wgUser, $wgOut;
+
+ if ( 0 == $wgUser->getID() ) {
+ $wgOut->errorpage( 'watchnologin', 'watchnologintext' );
+ return;
+ }
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+
+ if (wfRunHooks('UnwatchArticle', $wgUser, $this)) {
+
+ $wgUser->removeWatch( $this->mTitle );
+ $wgUser->saveSettings();
+
+ wfRunHooks('UnwatchArticleComplete', $wgUser, $this);
+
+ $wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
+ $wgOut->setRobotpolicy( 'noindex,follow' );
+
+ $link = $this->mTitle->getPrefixedText();
+ $text = wfMsg( 'removedwatchtext', $link );
+ $wgOut->addWikiText( $text );
+ }
+
+ $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );