From: Bryan Tong Minh Date: Sun, 6 Feb 2011 22:44:01 +0000 (+0000) Subject: Per CR r66438 and IRC, revert User::leaveNewMessage for now. Copied the function... X-Git-Tag: 1.31.0-rc.0~32150 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=e942dc69fcc6c6acb5d0b94c6e3f6459796dac33;p=lhc%2Fweb%2Fwiklou.git Per CR r66438 and IRC, revert User::leaveNewMessage for now. Copied the function and stripped it down for use in NewUserMessage. Could probably need some cleanup. --- diff --git a/includes/User.php b/includes/User.php index d89e45e3e7..1af15eabbf 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3767,91 +3767,7 @@ class User { return $ret; } - /** - * Format the user message using a hook, a template, or, failing these, a static format. - * @param $subject String the subject of the message - * @param $text String the content of the message - * @param $signature String the signature, if provided. - */ - static protected function formatUserMessage( $subject, $text, $signature ) { - if ( wfRunHooks( 'FormatUserMessage', - array( $subject, &$text, $signature ) ) ) { - - $signature = empty($signature) ? "~~~~~" : "{$signature} ~~~~~"; - - $template = Title::newFromText( wfMsgForContent( 'usermessage-template' ) ); - if ( !$template - || $template->getNamespace() !== NS_TEMPLATE - || !$template->exists() ) { - $text = "\n== $subject ==\n\n$text\n\n-- $signature"; - } else { - $text = '{{'. $template->getText() - . " | subject=$subject | body=$text | signature=$signature }}"; - } - } - return $text; - } - /** - * Leave a user a message - * @param $subject String the subject of the message - * @param $text String the message to leave - * @param $signature String Text to leave in the signature - * @param $summary String the summary for this change, defaults to - * "Leave system message." - * @param $editor User The user leaving the message, defaults to - * "{{MediaWiki:usermessage-editor}}" - * @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( $this, &$article, $subject, $text, $signature, $summary, $editor ) ); - - - $text = self::formatUserMessage( $subject, $text, $signature ); - $flags = $article->checkFlags( $flags ); - - if ( $flags & EDIT_UPDATE ) { - $text = $article->getContent() . $text; - } - - $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, $subject, $text, $signature, $summary, $editor ) ); - $dbw->commit(); - } else { - // The article was concurrently created - wfDebug( __METHOD__ . ": Error ".$status->getWikiText() ); - $dbw->rollback(); - } - - return $status->isGood(); - } }