From f854edfe876ff7097eb0b139fdedbcb27a34aa5c Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 26 Sep 2009 23:11:45 +0000 Subject: [PATCH] New permission 'sendemail' added. Default right for all registered users. Can for example be used to prevent new accounts from sending spam. * hide some user settings if user is not allowed to send e-mail, but can receive e-mail * update API 'cannot send e-mail' message * FIXME: gives 'mailnologin'/'mailnologintext' as error. Error handling should be made more fine grained --- RELEASE-NOTES | 22 ++++++++++++---------- includes/DefaultSettings.php | 1 + includes/Preferences.php | 2 +- includes/User.php | 4 ++-- includes/api/ApiBase.php | 2 +- includes/specials/SpecialEmailuser.php | 4 ++++ languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ff4f76a211..2a1e5ad2c6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -230,16 +230,18 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added $wgUseAJAXCategories allow enabling AJAX based categories system. This works on all namespaces. Enabled namespaces can be reduces using $wgAJAXCategoriesNamespaces. -* Admins could disable some variants using $wgDisabledVariants now. ONLY apply on - wikis enabled LanguageConverter. -* A new permission, 'root', is created. Analogous to root users on Unix systems, - the root permission effectively grants all other permissions on a wiki. Useful - for debugging and administration. -* New configuration variable $wgShowPageOnRedlink that can be set to show the page - instead of an edit interface when visiting a red link. The value can be specified - for specific usergroups and namespaces. +* Admins could disable some variants using $wgDisabledVariants now. ONLY apply + on wikis enabled LanguageConverter. +* A new permission, 'root', is created. Analogous to root users on Unix + systems, the root permission effectively grants all other permissions on a + wiki. Useful for debugging and administration. +* New configuration variable $wgShowPageOnRedlink that can be set to show the + page instead of an edit interface when visiting a red link. The value can be + specified for specific usergroups and namespaces. * (bug 16310) Credits page now lists IP addresses rather than saying the number of anonymous users that edited the page +* New permission 'sendemail' added. Default right for all registered users. Can + for example be used to prevent new accounts from sending spam. === Bug fixes in 1.16 === @@ -530,10 +532,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 20702) Parser functions can now be used correctly in MediaWiki:Missing-article * (bug 14117) "redirected from" is now also shown on foreign file redirects -* (bug 18436) JavaScript-added AJAX messages (from the JS watch/unwatch, for +* (bug 18436) JavaScript-added AJAX messages (from the JS watch/unwatch, for instance) no longer include a redundant "display:block" hardcoded style. * (bug 20802) Fixed thumb.php redirect handling -* (bug 17747) Only display thumbnail column in file history if the image can +* (bug 17747) Only display thumbnail column in file history if the image can be rendered. * (bug 3421) Live preview no longer breaks user CSS/JS previews * (bug 11264) The file logo on a file description page for documents (PDF, ...) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a4050d27ef..e90b156c2d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1332,6 +1332,7 @@ $wgGroupPermissions['user']['reupload'] = true; $wgGroupPermissions['user']['reupload-shared'] = true; $wgGroupPermissions['user']['minoredit'] = true; $wgGroupPermissions['user']['purge'] = true; // can use ?action=purge without clicking "ok" +$wgGroupPermissions['user']['sendemail'] = true; // Implicit group for accounts that pass $wgAutoConfirmAge $wgGroupPermissions['autoconfirmed']['autoconfirmed'] = true; diff --git a/includes/Preferences.php b/includes/Preferences.php index 92a91419a0..196b83b54f 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -389,7 +389,7 @@ class Preferences { } - if( $wgEnableUserEmail ) { + if( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) { $defaultPreferences['disablemail'] = array( 'type' => 'toggle', diff --git a/includes/User.php b/includes/User.php index f599d7647c..4b1972e5c6 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2983,8 +2983,8 @@ class User { * @return \bool True if allowed */ function canSendEmail() { - global $wgEnableEmail, $wgEnableUserEmail; - if( !$wgEnableEmail || !$wgEnableUserEmail ) { + global $wgEnableEmail, $wgEnableUserEmail, $wgUser; + if( !$wgEnableEmail || !$wgEnableUserEmail || !$wgUser->isAllowed( 'sendemail' ) ) { return false; } $canSend = $this->isEmailConfirmed(); diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index ecefe84a6a..04c141ac45 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -792,7 +792,7 @@ abstract class ApiBase { 'ipb_already_blocked' => array('code' => 'alreadyblocked', 'info' => "The user you tried to block was already blocked"), 'ipb_blocked_as_range' => array('code' => 'blockedasrange', 'info' => "IP address ``\$1'' was blocked as part of range ``\$2''. You can't unblock the IP invidually, but you can unblock the range as a whole."), 'ipb_cant_unblock' => array('code' => 'cantunblock', 'info' => "The block you specified was not found. It may have been unblocked already"), - 'mailnologin' => array('code' => 'cantsend', 'info' => "You're not logged in or you don't have a confirmed e-mail address, so you can't send e-mail"), + 'mailnologin' => array('code' => 'cantsend', 'info' => "You are not logged in, you do not have a confirmed e-mail address, or you are not allowed to send e-mail to other users, so you cannot send e-mail"), 'usermaildisabled' => array('code' => 'usermaildisabled', 'info' => "User email has been disabled"), 'blockedemailuser' => array('code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail"), 'notarget' => array('code' => 'notarget', 'info' => "You have not specified a valid target for this action"), diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 5bf2b579a1..def16c0fc8 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -290,6 +290,10 @@ class EmailUserForm { static function getPermissionsError ( $user, $editToken ) { if( !$user->canSendEmail() ) { wfDebug( "User can't send.\n" ); + // FIXME: this is also the error if user is in a group + // that is not allowed to send e-mail (no right + // 'sendemail'). Error messages should probably + // be more fine grained. return "mailnologin"; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 284a5bec59..72773f22a3 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1931,6 +1931,7 @@ You can also choose to let others contact you through your user or talk page wit 'right-override-export-depth' => 'Export pages including linked pages up to a depth of 5', 'right-versiondetail' => 'Show the extended software version information', 'right-root' => 'Perform all actions on the wiki', +'right-sendemail' => 'Send e-mail to other users', # User rights log 'rightslog' => 'User rights log', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 86aa8d4a33..42e5c9a30d 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1111,6 +1111,7 @@ $wgMessageStructure = array( 'right-override-export-depth', 'right-versiondetail', 'right-root', + 'right-sendemail', ), 'rightslog' => array( 'rightslog', -- 2.20.1