* (bug 2570) Add 'watch this page' checkbox on uploads, watch uploads
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 19 Sep 2005 06:10:58 +0000 (06:10 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 19 Sep 2005 06:10:58 +0000 (06:10 +0000)
  by default when 'watchdefault' option is on

RELEASE-NOTES
includes/Image.php
includes/SpecialUpload.php

index 6537359..bf454ca 100644 (file)
@@ -114,6 +114,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 2792) Update rebuildrecentchanges.inc for new schema
 * Special:Import/importDump fixes: report XML parse errors, accept <minor/>
 * (bug 3489) PHP 5.1 compat problem with captioned images
+* (bug 2570) Add 'watch this page' checkbox on uploads, watch uploads
+  by default when 'watchdefault' option is on
 
 
 === Caveats ===
index a8ff727..6622fd1 100644 (file)
@@ -1266,7 +1266,7 @@ class Image
        /**
         * Record an image upload in the upload log and the image table
         */
-       function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '' ) {
+       function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) {
                global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
                global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
 
@@ -1336,15 +1336,7 @@ class Image
                $descTitle = $this->getTitle();
                $purgeURLs = array();
 
-               if ( $dbw->affectedRows() ) {
-                       # Successfully inserted, this is a new image
-                       $id = $descTitle->getArticleID();
-
-                       if ( $id == 0 ) {
-                               $article = new Article( $descTitle );
-                               $article->insertNewArticle( $textdesc, $desc, false, false, true );
-                       }
-               } else {
+               if( $dbw->affectedRows() == 0 ) {
                        # Collision, this is an update of an image
                        # Insert previous contents into oldimage
                        $dbw->insertSelect( 'oldimage', 'image', 
@@ -1381,12 +1373,27 @@ class Image
                                        'img_name' => $this->name
                                ), $fname
                        );
+               }
+
+               $article = new Article( $descTitle );
+               $minor = false;
+               $watch = $watch || $wgUser->isWatched( $descTitle );
+               $suppressRC = true; // There's already a log entry, so don't double the RC load
+               
+               if( $descTitle->exists() ) {
+                       // TODO: insert a null revision into the page history for this update.
+                       if( $watch ) {
+                               $wgUser->addWatch( $descTitle );
+                       }
                        
                        # Invalidate the cache for the description page
                        $descTitle->invalidateCache();
                        $purgeURLs[] = $descTitle->getInternalURL();
+               } else {
+                       // New image; create the description page.
+                       $article->insertNewArticle( $textdesc, $desc, $minor, $watch, $suppressRC );
                }
-
+               
                # Invalidate cache for all pages using this image
                $linksTo = $this->getLinksTo();
                
index ec6d4c3..8273924 100644 (file)
@@ -55,7 +55,9 @@ class UploadForm {
                $this->mUploadDescription = $request->getText( 'wpUploadDescription' );
                $this->mLicense           = $request->getText( 'wpLicense' );
                $this->mUploadCopyStatus  = $request->getText( 'wpUploadCopyStatus' );
-               $this->mUploadSource      = $request->getText( 'wpUploadSource');
+               $this->mUploadSource      = $request->getText( 'wpUploadSource' );
+               $this->mWatchthis         = $request->getBool( 'wpWatchthis' );
+               wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" );
 
                $this->mAction            = $request->getVal( 'action' );
 
@@ -306,7 +308,8 @@ class UploadForm {
                                                        $this->mUploadDescription,
                                                        $this->mLicense,
                                                        $this->mUploadCopyStatus,
-                                                       $this->mUploadSource );
+                                                       $this->mUploadSource,
+                                                       $this->mWatchthis );
 
                        if ( $success ) {
                                $this->showSuccess();
@@ -516,6 +519,7 @@ class UploadForm {
                <input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars( $this->mUploadDescription ) . "\" />
                <input type='hidden' name='wpLicense' value=\"" . htmlspecialchars( $this->mLicense ) . "\" />
                <input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars( $this->mDestFile ) . "\" />
+               <input type='hidden' name='wpWatchthis' value=\"" . htmlspecialchars( intval( $this->mWatchthis ) ) . "\" />
        {$copyright}
        <table border='0'>
                <tr>
@@ -591,6 +595,10 @@ class UploadForm {
        " ;
                  }
 
+               $watchChecked = $wgUser->getOption( 'watchdefault' )
+                       ? 'checked="checked"'
+                       : '';
+               
                $wgOut->addHTML( "
        <form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
        <table border='0'><tr>
@@ -607,6 +615,11 @@ class UploadForm {
        <textarea tabindex='2' name='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>"        
          . htmlspecialchars( $this->mUploadDescription ) .
        "</textarea>
+       </td></tr><tr>
+       
+       <td></td><td align='left'>
+       <input type='checkbox' name='wpWatchthis' id='wpWatchthis' $watchChecked value='true' />
+       <label for='wpWatchthis'>" . wfMsgHtml( 'watchthis' ) . "</label>
        </td></tr><tr>" );
        
        if ( $licenseshtml != '' ) {