In the end, we should probably use a template if its around and do something sane with the subject line if not.
return true;
}
+ /**
+ * Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
+ * @param $flags Int
+ * @return Int updated $flags
+ */
+ function checkFlags( $flags ) {
+ if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
+ if ( $this->mTitle->getArticleID() ) {
+ $flags |= EDIT_UPDATE;
+ } else {
+ $flags |= EDIT_NEW;
+ }
+ }
+
+ return $flags;
+ }
/**
* Article::doEdit()
*
# Load $this->mTitle->getArticleID() and $this->mLatest if it's not already
$this->loadPageData();
- if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
- $aid = $this->mTitle->getArticleID();
- if ( $aid ) {
- $flags |= EDIT_UPDATE;
- } else {
- $flags |= EDIT_NEW;
- }
- }
+ $flags = $this->checkFlags( $flags );
if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
$flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
return $ret;
}
+
+ /**
+ * Leave a user a message
+ * @param $text String the message to leave
+ * @param $summary String the summary for this change, defaults to
+ * "Leave system message."
+ * @param $article Article The article to update, defaults to the
+ * user's talk page.
+ * @param $editor User The user leaving the message, defaults to
+ * "SystemMessage"
+ * @param $flags Int default edit flags
+ *
+ * @return boolean true if it was successful
+ */
+ public function leaveUserMessage( $subject, $text, $signature = "",
+ $summary = null, $editor = null, $flags = 0 ) {
+ if ( !isset( $summary ) ) {
+ $summary = wfMsgForContent( 'usermessage-summary' );
+ }
+
+ if ( !isset( $editor ) ) {
+ $editor = User::newFromName( wfMsgForContent( 'usermessage-editor' ) );
+ if ( !$editor->isLoggedIn() ) {
+ $editor->addToDatabase();
+ }
+ }
+
+ $article = new Article( $this->getTalkPage() );
+ wfRunHooks( 'SetupUserMessageArticle',
+ array( &$article, $subject, $this, $editor ) );
+
+ $flags = $article->checkFlags( $flags );
+
+ if ( $flags & EDIT_UPDATE ) {
+ $text .= $article->getContent();
+ }
+
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->begin();
+
+ try {
+ $status = $article->doEdit( $text, $summary, $flags, false, $editor );
+ } catch ( DBQueryError $e ) {
+ $status = Status::newFatal("DB Error");
+ }
+
+ if ( $status->isGood() ) {
+ // Set newtalk with the right user ID
+ $this->setNewtalk( true );
+ wfRunHooks( 'AfterUserMessage',
+ array( $this, $article, $summary, $signature, $editor, $text ) );
+ $dbw->commit();
+ } else {
+ // The article was concurrently created
+ wfDebug( __METHOD__ . ": Error ".$status->getWikiText() );
+ $dbw->rollback();
+ }
+
+ return $status->isGood();
+ }
}
}
$status = $this->saveTempFile( $req );
- $this->mRemoveTempFile = true;
-
- if( !$status->isOk() ) {
+ if ( !$status->isGood() ) {
return $status;
}
+ $this->mRemoveTempFile = true;
+
$v = $this->verifyUpload();
if( $v['status'] !== UploadBase::OK ) {
return $this->convertVerifyErrorToStatus( $v['status'], $v['details'] );
// This comes from ApiBase
/* $watch = $this->getWatchlistValue( $this->mParams['watchlist'], $file->getTitle() ); */
- if ( !$status->isGood() ) {
- return $status;
- }
-
$status = $this->getLocalFile()->upload( $this->mTempPath, $this->comment,
$this->comment, File::DELETE_SOURCE, $this->mFileProps, false, $wgUser );
+ if ( $status->isGood() ) {
+ $url = $this->getLocalFile()->getDescriptionUrl();
+ $wgUser->leaveUserMessage( wfMsg( 'successfulupload' ),
+ wfMsg( 'upload-success-msg', $url ) );
+ } else {
+ $wgUser->leaveUserMessage( wfMsg( 'upload-failure-subj' ),
+ wfMsg( 'upload-failure-msg', $status->getWikiText() ) );
+ }
+
return $status;
}
}
MGP # Pentax
PICT # misc.
#</pre> <!-- leave this line exactly as it is -->', # only translate this message to other languages if you have to change it
+'upload-successful-msg' => 'Your upload is available here: $1',
+'upload-failure-subj' => 'Upload Problem',
+'upload-failure-msg' => 'There was a problem with your upload:\n $1',
'upload-proto-error' => 'Incorrect protocol',
'upload-proto-error-text' => 'Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.',
'emailsenttext' => 'Your e-mail message has been sent.',
'emailuserfooter' => 'This e-mail was sent by $1 to $2 by the "E-mail user" function at {{SITENAME}}.',
+# User Message
+'usermessage-summary' => 'Leave system message.',
+'usermessage-editor' => 'System messenger',
+
# Watchlist
'watchlist' => 'My watchlist',
'mywatchlist' => 'My watchlist',
'upload-wasdeleted',
'filename-bad-prefix',
'filename-prefix-blacklist',
+ 'upload-successful-msg',
+ 'upload-failure-subj',
+ 'upload-failure-msg',
),
'upload-errors' => array(
'upload-proto-error',
'emailsenttext',
'emailuserfooter',
),
+ 'usermessage' => array(
+ 'usermessage-summary',
+ 'usermessage-editor',
+ ),
'watchlist' => array(
'watchlist',
'mywatchlist',
'newuserlog' => 'Special:Log/newusers',
'listgrouprights' => 'Special:ListGroupRights',
'emailuser' => 'E-mail user',
+ 'usermessage' => 'User Messenger',
'watchlist' => 'Watchlist',
'watching' => 'Displayed when you click the "watch" button and it is in the process of watching',
'enotif' => '',