Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/78344
Change subject: Allow users to opt-out of receiving messages by adding the page to a category ...................................................................... Allow users to opt-out of receiving messages by adding the page to a category Change-Id: I1f7d84b0962e00418c0c895570d5bf14b6c79f6d --- M MassMessage.i18n.php M MassMessageJob.php 2 files changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/44/78344/1 diff --git a/MassMessage.i18n.php b/MassMessage.i18n.php index 52d85ed..4b73456 100644 --- a/MassMessage.i18n.php +++ b/MassMessage.i18n.php @@ -32,6 +32,7 @@ 'massmessage-form-header' => 'Use the form below to send messages to a specified list. All fields are required.', 'massmessage-target' => '[//$1$2?title={{urlencode:$3|WIKI}} $3]', 'massmessage-queued-count' => 'Queued [[Special:MassMessage|mass messages]]', + 'massmessage-optout-category' => 'Opted-out of message delivery', 'right-massmessage' => 'Send a message to multiple users at once', 'action-massmessage' => 'send a message to multiple users at once', 'right-massmessage-global' => 'Send a message to multiple users on different wikis at once', @@ -77,6 +78,7 @@ * $2 is <code>$wgScriptPath</code> (example: "/w/index.php") * $3 the page name (example: "User talk:Example")', 'massmessage-queued-count' => 'Text for row on Special:Statistics', + 'massmessage-optout-category' => 'Name of category which users add pages to that will opt-it out of receiving messages.', 'right-massmessage' => '{{doc-right|massmessage}} See also: * {{msg-mw|Right-massmessage-global}}', diff --git a/MassMessageJob.php b/MassMessageJob.php index c8b39c9..ac9517f 100644 --- a/MassMessageJob.php +++ b/MassMessageJob.php @@ -50,6 +50,19 @@ } /** + * Checks whether the target page is in an opt-out category + * + * @param $title Title + * @return bool + */ + function isOptedOut( $title) { + $wikipage = WikiPage::factory( $title ); + $categories = $wikipage->getCategories(); + $category = Title::makeTitle( NS_CATEGORY, wfMessage( 'massmessage-optout-category')->inContentLanguage()->text() ); + return in_array( $category, $categories ); + } + + /** * Log any message failures on the submission site. * * @param $title Title @@ -82,6 +95,10 @@ return true; // Skip it } + if ( $this->isOptedOut( $this->title ) ) { + return true; // Oh well. + } + $text = "== " . $this->params['subject'] . " ==\n\n" . $this->params['message']; $talkPage = WikiPage::factory( $title ); -- To view, visit https://gerrit.wikimedia.org/r/78344 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1f7d84b0962e00418c0c895570d5bf14b6c79f6d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits