X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fspecials%2FSpecialEmailuser.php;h=06ca04f5cda0b24340fb2b9a6062bcbb97ec15c3;hb=08edb27f6ce31c676660a4ef89b87da79bde2cc2;hp=30eb38d04aea20057ec7630c680c9a76ebd34204;hpb=641c6d1f15f866770d44b67c1efc5f9fc0763d9e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 30eb38d04a..06ca04f5cd 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -224,15 +224,52 @@ class SpecialEmailUser extends UnlistedSpecialPage { 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 && !$target->getOption( 'email-allow-new-users' ) && + $sender->isNewbie() + ) { + wfDebug( "User does not allow user emails from new users.\n" ); + + return 'nowikiemail'; + } + + if ( $sender !== null ) { $blacklist = $target->getOption( 'email-blacklist', [] ); if ( $blacklist ) { $lookup = CentralIdLookup::factory();