$wgGroupPermissions['user']['applychangetags'] = true;
$wgGroupPermissions['user']['changetags'] = true;
$wgGroupPermissions['user']['editcontentmodel'] = true;
+$wgGroupPermissions['user']['sendemail-new-users'] = true;
// Implicit group for accounts that pass $wgAutoConfirmAge
$wgGroupPermissions['autoconfirmed']['autoconfirmed'] = true;
wfDebug( "Target is invalid user.\n" );
return 'notarget';
- } elseif ( !$target->isEmailConfirmed() ) {
+ }
+
+ if ( !$target->isEmailConfirmed() ) {
wfDebug( "User has no valid email.\n" );
return 'noemail';
- } elseif ( !$target->canReceiveEmail() ) {
+ }
+
+ if ( !$target->canReceiveEmail() ) {
wfDebug( "User does not allow user emails.\n" );
return 'nowikiemail';
- } elseif ( $sender !== null ) {
+ }
+
+ if (
+ $target->getEditCount() === 0
+ && ( $sender === null || !$sender->isAllowed( 'sendemail-new-users' ) )
+ ) {
+ // Determine if target has any other logged actions.
+ $dbr = wfGetDB( DB_REPLICA );
+ $log_id = $dbr->selectField(
+ 'logging',
+ 'log_id',
+ [
+ 'log_user' => $target->getId(),
+ "NOT (log_type = 'newusers' AND log_action = 'autocreate')",
+ ],
+ __METHOD__,
+ [ 'LIMIT' => 1 ]
+ );
+
+ if ( !$log_id ) {
+ wfDebug( "User has no logged actions on this wiki.\n" );
+
+ return 'nowikiemail';
+ }
+ }
+
+ if ( $sender !== null ) {
$blacklist = $target->getOption( 'email-blacklist', [] );
if ( $blacklist ) {
$lookup = CentralIdLookup::factory();
'reupload-shared',
'rollback',
'sendemail',
+ 'sendemail-new-users',
'siteadmin',
'suppressionlog',
'suppressredirect',
"right-siteadmin": "Lock and unlock the database",
"right-override-export-depth": "Export pages including linked pages up to a depth of 5",
"right-sendemail": "Send email to other users",
+ "right-sendemail-new-users": "Send email to users with no logged actions",
"right-managechangetags": "Create and (de)activate [[Special:Tags|tags]]",
"right-applychangetags": "Apply [[Special:Tags|tags]] along with one's changes",
"right-changetags": "Add and remove arbitrary [[Special:Tags|tags]] on individual revisions and log entries",
"right-siteadmin": "{{doc-right|siteadmin}}",
"right-override-export-depth": "{{doc-right|override-export-depth}}",
"right-sendemail": "{{doc-right|sendemail}}",
+ "right-sendemail-new-users": "{{doc-right|sendemail-new-users}}",
"right-managechangetags": "{{doc-right|managechangetags}}",
"right-applychangetags": "{{doc-right|applychangetags}}",
"right-changetags": "{{doc-right|changetags}}",