Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1702,6 +1702,7 @@ |
1703 | 1703 | 'usermessage' => array( |
1704 | 1704 | 'usermessage-summary', |
1705 | 1705 | 'usermessage-editor', |
| 1706 | + 'usermessage-template', |
1706 | 1707 | ), |
1707 | 1708 | 'watchlist' => array( |
1708 | 1709 | 'watchlist', |
Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -785,6 +785,12 @@ |
786 | 786 | $user: user who performed the undeletion |
787 | 787 | $reason: reason |
788 | 788 | |
| 789 | +'FormatUserMessage': Hook to format a message if you want to override |
| 790 | +the internal formatter. |
| 791 | +$subject: Title of the message. |
| 792 | +&$text: Text of the message. |
| 793 | +$signature: Signature that they would like to leave. |
| 794 | + |
789 | 795 | 'GetAutoPromoteGroups': When determining which autopromote groups a user |
790 | 796 | is entitled to be in. |
791 | 797 | &$user: user to promote. |
Index: trunk/phase3/includes/User.php |
— | — | @@ -3750,8 +3750,36 @@ |
3751 | 3751 | } |
3752 | 3752 | |
3753 | 3753 | /** |
| 3754 | + * Format the user message using a hook, a template, or, failing these, a static format. |
| 3755 | + * @param $subject String the subject of the message |
| 3756 | + * @param $text String the content of the message |
| 3757 | + * @param $signature String the signature, if provided. |
| 3758 | + */ |
| 3759 | + static protected function formatUserMessage( $subject, $text, $signature ) { |
| 3760 | + if ( wfRunHooks( 'FormatUserMessage', |
| 3761 | + array( $subject, &$text, $signature ) ) ) { |
| 3762 | + |
| 3763 | + $signature = empty($signature) ? "~~~~~" : "{$signature} ~~~~~"; |
| 3764 | + |
| 3765 | + $template = Title::newFromText( wfMsg( 'usermessage-template' ) ); |
| 3766 | + if ( !$template |
| 3767 | + || $template->getNamespace() !== NS_TEMPLATE |
| 3768 | + || !$template->exists() ) { |
| 3769 | + $text = "== $subject ==\n\n$text\n\n-- $signature" |
| 3770 | + } else { |
| 3771 | + $text = '{{'. $template->getText() |
| 3772 | + . " | subject=$subject | body=$text | signature=$signature }}"; |
| 3773 | + } |
| 3774 | + } |
| 3775 | + |
| 3776 | + return $text; |
| 3777 | + } |
| 3778 | + |
| 3779 | + /** |
3754 | 3780 | * Leave a user a message |
| 3781 | + * @param $subject String the subject of the message |
3755 | 3782 | * @param $text String the message to leave |
| 3783 | + * @param $signature String Text to leave in the signature |
3756 | 3784 | * @param $summary String the summary for this change, defaults to |
3757 | 3785 | * "Leave system message." |
3758 | 3786 | * @param $article Article The article to update, defaults to the |
— | — | @@ -3779,6 +3807,8 @@ |
3780 | 3808 | wfRunHooks( 'SetupUserMessageArticle', |
3781 | 3809 | array( $this, &$article, $subject, $text, $signature, $summary, $editor ) ); |
3782 | 3810 | |
| 3811 | + |
| 3812 | + $text = self::formatUserMessage( $subject, $text, $signature ); |
3783 | 3813 | $flags = $article->checkFlags( $flags ); |
3784 | 3814 | |
3785 | 3815 | if ( $flags & EDIT_UPDATE ) { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2610,6 +2610,7 @@ |
2611 | 2611 | # User Messenger |
2612 | 2612 | 'usermessage-summary' => 'Leaving system message.', |
2613 | 2613 | 'usermessage-editor' => 'System messenger', |
| 2614 | +'usermessage-template' => 'Template:UserMessage', |
2614 | 2615 | |
2615 | 2616 | # Watchlist |
2616 | 2617 | 'watchlist' => 'My watchlist', |