Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1265,6 +1265,9 @@ |
1266 | 1266 | 'upload-wasdeleted', |
1267 | 1267 | 'filename-bad-prefix', |
1268 | 1268 | 'filename-prefix-blacklist', |
| 1269 | + 'upload-successful-msg', |
| 1270 | + 'upload-failure-subj', |
| 1271 | + 'upload-failure-msg', |
1269 | 1272 | ), |
1270 | 1273 | 'upload-errors' => array( |
1271 | 1274 | 'upload-proto-error', |
— | — | @@ -1696,6 +1699,10 @@ |
1697 | 1700 | 'emailsenttext', |
1698 | 1701 | 'emailuserfooter', |
1699 | 1702 | ), |
| 1703 | + 'usermessage' => array( |
| 1704 | + 'usermessage-summary', |
| 1705 | + 'usermessage-editor', |
| 1706 | + ), |
1700 | 1707 | 'watchlist' => array( |
1701 | 1708 | 'watchlist', |
1702 | 1709 | 'mywatchlist', |
— | — | @@ -3258,6 +3265,7 @@ |
3259 | 3266 | 'newuserlog' => 'Special:Log/newusers', |
3260 | 3267 | 'listgrouprights' => 'Special:ListGroupRights', |
3261 | 3268 | 'emailuser' => 'E-mail user', |
| 3269 | + 'usermessage' => 'User Messenger', |
3262 | 3270 | 'watchlist' => 'Watchlist', |
3263 | 3271 | 'watching' => 'Displayed when you click the "watch" button and it is in the process of watching', |
3264 | 3272 | 'enotif' => '', |
Index: trunk/phase3/includes/upload/UploadFromUrl.php |
— | — | @@ -143,12 +143,12 @@ |
144 | 144 | } |
145 | 145 | |
146 | 146 | $status = $this->saveTempFile( $req ); |
147 | | - $this->mRemoveTempFile = true; |
148 | | - |
149 | | - if( !$status->isOk() ) { |
| 147 | + if ( !$status->isGood() ) { |
150 | 148 | return $status; |
151 | 149 | } |
152 | 150 | |
| 151 | + $this->mRemoveTempFile = true; |
| 152 | + |
153 | 153 | $v = $this->verifyUpload(); |
154 | 154 | if( $v['status'] !== UploadBase::OK ) { |
155 | 155 | return $this->convertVerifyErrorToStatus( $v['status'], $v['details'] ); |
— | — | @@ -162,13 +162,18 @@ |
163 | 163 | // This comes from ApiBase |
164 | 164 | /* $watch = $this->getWatchlistValue( $this->mParams['watchlist'], $file->getTitle() ); */ |
165 | 165 | |
166 | | - if ( !$status->isGood() ) { |
167 | | - return $status; |
168 | | - } |
169 | | - |
170 | 166 | $status = $this->getLocalFile()->upload( $this->mTempPath, $this->comment, |
171 | 167 | $this->comment, File::DELETE_SOURCE, $this->mFileProps, false, $wgUser ); |
172 | 168 | |
| 169 | + if ( $status->isGood() ) { |
| 170 | + $url = $this->getLocalFile()->getDescriptionUrl(); |
| 171 | + $wgUser->leaveUserMessage( wfMsg( 'successfulupload' ), |
| 172 | + wfMsg( 'upload-success-msg', $url ) ); |
| 173 | + } else { |
| 174 | + $wgUser->leaveUserMessage( wfMsg( 'upload-failure-subj' ), |
| 175 | + wfMsg( 'upload-failure-msg', $status->getWikiText() ) ); |
| 176 | + } |
| 177 | + |
173 | 178 | return $status; |
174 | 179 | } |
175 | 180 | } |
Index: trunk/phase3/includes/User.php |
— | — | @@ -3748,4 +3748,64 @@ |
3749 | 3749 | |
3750 | 3750 | return $ret; |
3751 | 3751 | } |
| 3752 | + |
| 3753 | + /** |
| 3754 | + * Leave a user a message |
| 3755 | + * @param $text String the message to leave |
| 3756 | + * @param $summary String the summary for this change, defaults to |
| 3757 | + * "Leave system message." |
| 3758 | + * @param $article Article The article to update, defaults to the |
| 3759 | + * user's talk page. |
| 3760 | + * @param $editor User The user leaving the message, defaults to |
| 3761 | + * "SystemMessage" |
| 3762 | + * @param $flags Int default edit flags |
| 3763 | + * |
| 3764 | + * @return boolean true if it was successful |
| 3765 | + */ |
| 3766 | + public function leaveUserMessage( $subject, $text, $signature = "", |
| 3767 | + $summary = null, $editor = null, $flags = 0 ) { |
| 3768 | + if ( !isset( $summary ) ) { |
| 3769 | + $summary = wfMsgForContent( 'usermessage-summary' ); |
| 3770 | + } |
| 3771 | + |
| 3772 | + if ( !isset( $editor ) ) { |
| 3773 | + $editor = User::newFromName( wfMsgForContent( 'usermessage-editor' ) ); |
| 3774 | + if ( !$editor->isLoggedIn() ) { |
| 3775 | + $editor->addToDatabase(); |
| 3776 | + } |
| 3777 | + } |
| 3778 | + |
| 3779 | + $article = new Article( $this->getTalkPage() ); |
| 3780 | + wfRunHooks( 'SetupUserMessageArticle', |
| 3781 | + array( &$article, $subject, $this, $editor ) ); |
| 3782 | + |
| 3783 | + $flags = $article->checkFlags( $flags ); |
| 3784 | + |
| 3785 | + if ( $flags & EDIT_UPDATE ) { |
| 3786 | + $text .= $article->getContent(); |
| 3787 | + } |
| 3788 | + |
| 3789 | + $dbw = wfGetDB( DB_MASTER ); |
| 3790 | + $dbw->begin(); |
| 3791 | + |
| 3792 | + try { |
| 3793 | + $status = $article->doEdit( $text, $summary, $flags, false, $editor ); |
| 3794 | + } catch ( DBQueryError $e ) { |
| 3795 | + $status = Status::newFatal("DB Error"); |
| 3796 | + } |
| 3797 | + |
| 3798 | + if ( $status->isGood() ) { |
| 3799 | + // Set newtalk with the right user ID |
| 3800 | + $this->setNewtalk( true ); |
| 3801 | + wfRunHooks( 'AfterUserMessage', |
| 3802 | + array( $this, $article, $summary, $signature, $editor, $text ) ); |
| 3803 | + $dbw->commit(); |
| 3804 | + } else { |
| 3805 | + // The article was concurrently created |
| 3806 | + wfDebug( __METHOD__ . ": Error ".$status->getWikiText() ); |
| 3807 | + $dbw->rollback(); |
| 3808 | + } |
| 3809 | + |
| 3810 | + return $status->isGood(); |
| 3811 | + } |
3752 | 3812 | } |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1871,6 +1871,22 @@ |
1872 | 1872 | } |
1873 | 1873 | |
1874 | 1874 | /** |
| 1875 | + * Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed. |
| 1876 | + * @param $flags Int |
| 1877 | + * @return Int updated $flags |
| 1878 | + */ |
| 1879 | + function checkFlags( $flags ) { |
| 1880 | + if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) { |
| 1881 | + if ( $this->mTitle->getArticleID() ) { |
| 1882 | + $flags |= EDIT_UPDATE; |
| 1883 | + } else { |
| 1884 | + $flags |= EDIT_NEW; |
| 1885 | + } |
| 1886 | + } |
| 1887 | + |
| 1888 | + return $flags; |
| 1889 | + } |
| 1890 | + /** |
1875 | 1891 | * Article::doEdit() |
1876 | 1892 | * |
1877 | 1893 | * Change an existing article or create a new article. Updates RC and all necessary caches, |
— | — | @@ -1936,14 +1952,7 @@ |
1937 | 1953 | # Load $this->mTitle->getArticleID() and $this->mLatest if it's not already |
1938 | 1954 | $this->loadPageData(); |
1939 | 1955 | |
1940 | | - if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) { |
1941 | | - $aid = $this->mTitle->getArticleID(); |
1942 | | - if ( $aid ) { |
1943 | | - $flags |= EDIT_UPDATE; |
1944 | | - } else { |
1945 | | - $flags |= EDIT_NEW; |
1946 | | - } |
1947 | | - } |
| 1956 | + $flags = $this->checkFlags( $flags ); |
1948 | 1957 | |
1949 | 1958 | if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary, |
1950 | 1959 | $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) ) |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2149,6 +2149,9 @@ |
2150 | 2150 | MGP # Pentax |
2151 | 2151 | PICT # misc. |
2152 | 2152 | #</pre> <!-- leave this line exactly as it is -->', # only translate this message to other languages if you have to change it |
| 2153 | +'upload-successful-msg' => 'Your upload is available here: $1', |
| 2154 | +'upload-failure-subj' => 'Upload Problem', |
| 2155 | +'upload-failure-msg' => 'There was a problem with your upload:\n $1', |
2153 | 2156 | |
2154 | 2157 | 'upload-proto-error' => 'Incorrect protocol', |
2155 | 2158 | 'upload-proto-error-text' => 'Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.', |
— | — | @@ -2602,6 +2605,10 @@ |
2603 | 2606 | 'emailsenttext' => 'Your e-mail message has been sent.', |
2604 | 2607 | 'emailuserfooter' => 'This e-mail was sent by $1 to $2 by the "E-mail user" function at {{SITENAME}}.', |
2605 | 2608 | |
| 2609 | +# User Message |
| 2610 | +'usermessage-summary' => 'Leave system message.', |
| 2611 | +'usermessage-editor' => 'System messenger', |
| 2612 | + |
2606 | 2613 | # Watchlist |
2607 | 2614 | 'watchlist' => 'My watchlist', |
2608 | 2615 | 'mywatchlist' => 'My watchlist', |