VitaliyFilippov has uploaded a new change for review. https://gerrit.wikimedia.org/r/249156
Change subject: Add option to include diffs in page change notification emails ...................................................................... Add option to include diffs in page change notification emails Also add option to send separate emails for each change instead of only one email for all changes since the last page visit. Bug: T15303 Change-Id: I36bcb26580fbba924fc49a1d4f5245aee7189434 --- M includes/DefaultSettings.php M includes/Preferences.php M includes/mail/EmailNotification.php M languages/i18n/en.json M languages/i18n/ru.json 5 files changed, 46 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/56/249156/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c8da21e..ada1598 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4538,6 +4538,8 @@ 'enotifrevealaddr' => 0, 'enotifusertalkpages' => 1, 'enotifwatchlistpages' => 1, + 'enotifsenddiffs' => 0, + 'enotifsendmultiple' => 0, 'extendwatchlist' => 1, 'fancysig' => 0, 'forceeditsummary' => 0, diff --git a/includes/Preferences.php b/includes/Preferences.php index 0f8dcc3..2eb382c 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -551,7 +551,18 @@ 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs, ); - + $defaultPreferences['enotifsenddiffs'] = array( + 'type' => 'toggle', + 'section' => 'personal/email', + 'label-message' => 'tog-enotifsenddiffs', + 'disabled' => $disableEmailPrefs, + ); + $defaultPreferences['enotifsendmultiple'] = array( + 'type' => 'toggle', + 'section' => 'personal/email', + 'label-message' => 'tog-enotifsendmultiple', + 'disabled' => $disableEmailPrefs, + ); if ( $config->get( 'EnotifRevealEditorAddress' ) ) { $defaultPreferences['enotifrevealaddr'] = array( 'type' => 'toggle', diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 29a19be..cf4b39d 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -86,13 +86,15 @@ } $dbw = wfGetDB( DB_MASTER ); + $tbl = $dbw->tableName( 'user_properties' ); $res = $dbw->select( array( 'watchlist' ), array( 'wl_user' ), array( 'wl_user != ' . intval( $editor->getID() ), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), - 'wl_notificationtimestamp IS NULL', + "(wl_notificationtimestamp IS NULL OR EXISTS (SELECT * FROM $tbl". + " WHERE up_user=wl_user AND up_property IN ('enotifsendmultiple', 'enotifsenddiff') AND up_value=1))", ), __METHOD__ ); @@ -395,6 +397,18 @@ Skin::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() ) ); + // Generate diff + $context = new DerivativeContext( RequestContext::getMain() ); + $out = new OutputPage( $context ); + $context->setOutput( $out ); + $de = new DifferenceEngine( $context, $keys['$OLDID'], 'next' ); + $de->showDiffPage( true ); + $diff = $out->getHTML(); + $diff = preg_replace( '#^(.*?)<tr[^<>]*>.*?</tr\s*>#is', '\1', $diff, 1 ); + $diff = preg_replace( '#class=[\"\']?diff-deletedline[\"\']?#is', 'style="background-color: #ffffaa"', $diff ); + $diff = preg_replace( '#class=[\"\']?diff-addedline[\"\']?#is', 'style="background-color: #ccffcc"', $diff ); + $this->diff = preg_replace( '#class=[\"\']?diffchange\s*diffchange-inline[\"\']?#is', 'style="color: red; font-weight: bold"', $diff ); + # Replace this after transforming the message, bug 35019 $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? wfMessage( 'enotif_empty_summary' )->text() : $this->summary; @@ -504,6 +518,10 @@ // this properly while talking with the MTA. $to = MailAddress::newFromUser( $watchingUser ); + $nofurther = $watchingUser->getOption( 'enotifsenddiffs' ) || + $watchingUser->getOption( 'enotifsendmultiple' ) + ? '' : wfMessage( 'enotif_no_further_notice' )->inContentLanguage()->text(); + # $PAGEEDITDATE is the time and date of the page change # expressed in terms of individual local time of the notification # recipient, i.e. watching user @@ -512,9 +530,12 @@ ? $watchingUser->getRealName() : $watchingUser->getName(), '$PAGEEDITDATE' => $wgContLang->userDate( $this->timestamp, $watchingUser ), '$PAGEEDITTIME' => $wgContLang->userTime( $this->timestamp, $watchingUser ), + '$NOFURTHERNOTICE' => $nofurther ? "\n\n$nofurther" : '', ); $body = strtr( $this->body, $repl ); $repl['$WATCHINGUSERNAME'] = htmlspecialchars( $repl['$WATCHINGUSERNAME'] ); + $repl['$NOFURTHERNOTICE'] = $nofurther ? "\n<p>$nofurther</p>" : ''; + $repl['$DIFF'] = $watchingUser->getOption( 'enotifsenddiffs' ) ? $this->diff : ''; $bodyHtml = strtr( $this->bodyHtml, $repl ); $body = array( 'text' => $body, diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 110c694..f971935 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -25,6 +25,8 @@ "tog-enotifwatchlistpages": "Email me when a page or a file on my watchlist is changed", "tog-enotifusertalkpages": "Email me when my user talk page is changed", "tog-enotifminoredits": "Email me also for minor edits of pages and files", + "tog-enotifsenddiffs": "Include page differences in notification e-mails", + "tog-enotifsendmultiple": "Send multiple notifications instead of one after each visit", "tog-enotifrevealaddr": "Reveal my email address in notification emails", "tog-shownumberswatching": "Show the number of watching users", "tog-oldsig": "Existing signature:", @@ -1946,8 +1948,9 @@ "enotif_lastdiff_html": "<a href='$1'>Show this change</a>", "enotif_empty_summary": "empty summary", "enotif_anon_editor": "anonymous user $1", - "enotif_body": "Dear $WATCHINGUSERNAME,\n\n$PAGEINTRO $NEWPAGE\n\nEditor's summary: $PAGESUMMARY $PAGEMINOREDIT\n\nContact the editor:\nmail: $PAGEEDITOR_EMAIL\nwiki: $PAGEEDITOR_WIKI\n\nThere will be no other notifications in case of further activity unless you visit this page while logged in. You could also reset the notification flags for all your watched pages on your watchlist.\n\nYour friendly {{SITENAME}} notification system\n\n--\nTo change your email notification settings, visit\n{{canonicalurl:{{#special:Preferences}}}}\n\nTo change your watchlist settings, visit\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nTo delete the page from your watchlist, visit\n$UNWATCHURL\n\nFeedback and further assistance:\n$HELPPAGE", - "enotif_body_html": "<p>Dear <b>$WATCHINGUSERNAME</b>,</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Editor's summary: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>Contact the editor: <a href='$PAGEEDITOR_EMAIL'>mail</a>, <a href='$PAGEEDITOR_WIKI'>wiki</a>.</p>\n<p>There will be no other notifications in case of further activity unless you visit this page while logged in. You could also reset the notification flags for all your watched pages on your watchlist.</p>\n<p style='font-size: 12px'><i>\n-- \n<br><b>Your friendly {{SITENAME}} notification system</b>\n<br>To change your email notification settings, visit <a href='{{canonicalurl:{{#special:Preferences}}}}'>Special:Preferences</a>\n<br>To change your watchlist settings, visit <a href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Special:EditWatchlist</a>\n<br><a href='$UNWATCHURL'>Delete this page from your watchlist</a>\n<br><a href='$HELPPAGE'>Feedback and further assistance</a>\n</i></p>", + "enotif_no_further_notice": "There will be no other notifications in case of further activity unless you visit this page while logged in. You could also reset the notification flags for all your watched pages on your watchlist.", + "enotif_body": "Dear $WATCHINGUSERNAME,\n\n$PAGEINTRO $NEWPAGE\n\nEditor's summary: $PAGESUMMARY $PAGEMINOREDIT\n\nContact the editor:\nmail: $PAGEEDITOR_EMAIL\nwiki: $PAGEEDITOR_WIKI$NOFURTHERNOTICE\n\nYour friendly {{SITENAME}} notification system\n\n--\nTo change your email notification settings, visit\n{{canonicalurl:{{#special:Preferences}}}}\n\nTo change your watchlist settings, visit\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nTo delete the page from your watchlist, visit\n$UNWATCHURL\n\nFeedback and further assistance:\n$HELPPAGE", + "enotif_body_html": "<p>Dear <b>$WATCHINGUSERNAME</b>,</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Editor's summary: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>Contact the editor: <a href='$PAGEEDITOR_EMAIL'>mail</a>, <a href='$PAGEEDITOR_WIKI'>wiki</a>.</p>$NO_FURTHER_NOTICE $DIFF\n<p style='font-size: 12px'><i>\n-- \n<br><b>Your friendly {{SITENAME}} notification system</b>\n<br>To change your email notification settings, visit <a href='{{canonicalurl:{{#special:Preferences}}}}'>Special:Preferences</a>\n<br>To change your watchlist settings, visit <a href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Special:EditWatchlist</a>\n<br><a href='$UNWATCHURL'>Delete this page from your watchlist</a>\n<br><a href='$HELPPAGE'>Feedback and further assistance</a>\n</i></p>", "created": "created", "changed": "changed", "deletepage": "Delete page", diff --git a/languages/i18n/ru.json b/languages/i18n/ru.json index 204be4e..f5783a2 100644 --- a/languages/i18n/ru.json +++ b/languages/i18n/ru.json @@ -110,6 +110,8 @@ "tog-enotifwatchlistpages": "Уведомлять по электронной почте об изменениях страниц и файлов из списка наблюдения", "tog-enotifusertalkpages": "Уведомлять по электронной почте об изменении персональной страницы обсуждения", "tog-enotifminoredits": "Уведомлять даже при незначительных изменениях страниц и файлов", + "tog-enotifsenddiffs": "Включать в оповещения различия (diff'ы) страниц", + "tog-enotifsendmultiple": "Отправлять новое оповещение при каждом изменении, а не одно для всех с момента посещения", "tog-enotifrevealaddr": "Показывать мой почтовый адрес в сообщениях оповещения", "tog-shownumberswatching": "Показывать число участников, включивших страницу в свой список наблюдения", "tog-oldsig": "Текущая подпись:", @@ -1898,8 +1900,9 @@ "enotif_lastdiff_html": "<a href='$1'>Просмотреть данное изменение</a>", "enotif_empty_summary": "нет описания", "enotif_anon_editor": "анонимный участник $1", - "enotif_body": "Здравствуйте, $WATCHINGUSERNAME!\n\n$PAGEINTRO $NEWPAGE\n\nКраткое описание изменения: $PAGESUMMARY $PAGEMINOREDIT\n\nОбратиться к изменившему:\nэл. почта: $PAGEEDITOR_EMAIL\nвики: $PAGEEDITOR_WIKI\n\nЕсли вы не зайдёте на эту страницу под своей учётной записью, в случае её дальнейших изменений уведомлений больше не будет. Вы можете также отключить опцию уведомления для всех страниц в вашем списке наблюдения.\n\nСистема оповещения {{grammar:genitive|{{SITENAME}}}}\n\n--\nИзменение настройки уведомлений\n{{canonicalurl:{{#special:Preferences}}}}\n\nИзменение настройки вашего списка наблюдения\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nУдалить страницы из вашего списка наблюдения\n$UNWATCHURL\n\nОбратная связь и помощь\n$HELPPAGE", - "enotif_body_html": "<p>Здравствуйте, <b>$WATCHINGUSERNAME</b>!</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Краткое описание изменения: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>\nОбратиться к изменившему: <a href='$PAGEEDITOR_EMAIL'>эл. почта</a>, <a href='$PAGEEDITOR_WIKI'>вики</a></p>\n<p>Если вы не зайдёте на эту страницу под своей учётной записью, в случае её дальнейших изменений уведомлений больше не будет. Вы можете также отключить опцию уведомления для всех страниц в вашем списке наблюдения.</p>\n<p style='font-size: 12px'><i>\n-- \n<br>Система оповещения {{grammar:genitive|{{SITENAME}}}}\n<br><a href='{{canonicalurl:{{#special:Preferences}}}}'>Изменение настройки уведомлений</a>\n<br><a href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Изменение настройки вашего списка наблюдения</a>\n<br><a href='$UNWATCHURL'>Удалить данную страницу из вашего списка наблюдения</a>\n<br><a href='$HELPPAGE'>Обратная связь и помощь</a>\n</i></p>", + "enotif_no_further_notice": "Если вы не зайдёте на эту страницу под своей учётной записью, в случае её дальнейших изменений уведомлений больше не будет. Вы можете также отключить опцию уведомления для всех страниц в вашем списке наблюдения.", + "enotif_body": "Здравствуйте, $WATCHINGUSERNAME!\n\n$PAGEINTRO $NEWPAGE\n\nКраткое описание изменения: $PAGESUMMARY $PAGEMINOREDIT\n\nОбратиться к изменившему:\nэл. почта: $PAGEEDITOR_EMAIL\nвики: $PAGEEDITOR_WIKI $NOFURTHERNOTICE\n\nСистема оповещения {{grammar:genitive|{{SITENAME}}}}\n\n--\nИзменение настройки уведомлений\n{{canonicalurl:{{#special:Preferences}}}}\n\nИзменение настройки вашего списка наблюдения\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nУдалить страницы из вашего списка наблюдения\n$UNWATCHURL\n\nОбратная связь и помощь\n$HELPPAGE", + "enotif_body_html": "<p>Здравствуйте, <b>$WATCHINGUSERNAME</b>!</p>\n<p>$PAGEINTRO</p>\n$NEWPAGE\n<p>Краткое описание изменения: <b>$PAGESUMMARY $PAGEMINOREDIT</b><br>\nОбратиться к изменившему: <a href='$PAGEEDITOR_EMAIL'>эл. почта</a>, <a href='$PAGEEDITOR_WIKI'>вики</a></p>$NOFURTHERNOTICE $DIFF\n<p style='font-size: 12px'><i>\n-- \n<br>Система оповещения {{grammar:genitive|{{SITENAME}}}}\n<br><a href='{{canonicalurl:{{#special:Preferences}}}}'>Изменение настройки уведомлений</a>\n<br><a href='{{canonicalurl:{{#special:EditWatchlist}}}}'>Изменение настройки вашего списка наблюдения</a>\n<br><a href='$UNWATCHURL'>Удалить данную страницу из вашего списка наблюдения</a>\n<br><a href='$HELPPAGE'>Обратная связь и помощь</a>\n</i></p>", "created": "создана", "changed": "изменена", "deletepage": "Удалить страницу", -- To view, visit https://gerrit.wikimedia.org/r/249156 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I36bcb26580fbba924fc49a1d4f5245aee7189434 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: VitaliyFilippov <vita...@yourcmc.ru> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits