From 5f0e289eb7fd78e434b6ec0db93307c9f6f5629c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 25 Nov 2004 06:20:01 +0000 Subject: [PATCH] Add site-wide options to disable all e-mail functions or only user-to-user email. --- includes/DefaultSettings.php | 14 +++++++++++++ includes/Skin.php | 14 +++++++++---- includes/SpecialEmailuser.php | 7 ++++++- includes/SpecialPreferences.php | 23 +++++++++++++++++---- includes/SpecialUserlogin.php | 19 ++++++++++++------ includes/templates/Userlogin.php | 34 +++++++++++++++++--------------- skins/CologneBlue.php | 2 +- skins/Standard.php | 6 ++---- 8 files changed, 83 insertions(+), 36 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3805fff617..aa46220a59 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -158,6 +158,20 @@ $wgEmergencyContact = 'wikiadmin@' . $wgServerName; */ $wgPasswordSender = 'Wikipedia Mail '; +/** + * Set to true to enable the e-mail basic features: + * Password reminders, etc. If sending e-mail on your + * server doesn't work, you might want to disable this. + * @global bool $wgEnableEmail + */ +$wgEnableEmail = true; + +/** + * Set to true to enable user-to-user e-mail. + * This can potentially be abused, as it's hard to track. + * @global bool $wgEnableUserEmail + */ +$wgEnableUserEmail = true; /** * SMTP Mode diff --git a/includes/Skin.php b/includes/Skin.php index f0bb25b726..a923e881c0 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -774,10 +774,8 @@ class Skin { if($id || $ip) { # both anons and non-anons have contri list $s .= $sep . $this->userContribsLink(); } - if ( 0 != $wgUser->getID() ) { # show only to signed in users - if($id) { # can only email non-anons - $s .= $sep . $this->emailUserLink(); - } + if( $this->showEmailUser( $id ) ) { + $s .= $sep . $this->emailUserLink(); } } if ( $wgTitle->getArticleId() ) { @@ -1091,6 +1089,14 @@ class Skin { return $s; } + function showEmailUser( $id ) { + global $wgEnableEmail, $wgEnableUserEmail, $wgUser; + return $wgEnableEmail && + $wgEnableUserEmail && + 0 != $wgUser->getID() && # show only to signed in users + 0 != $id; # can only email non-anons + } + function emailUserLink() { global $wgTitle, $wgContLang; diff --git a/includes/SpecialEmailuser.php b/includes/SpecialEmailuser.php index dbe6532eaa..8aed0f2022 100644 --- a/includes/SpecialEmailuser.php +++ b/includes/SpecialEmailuser.php @@ -11,8 +11,13 @@ require_once('UserMailer.php'); function wfSpecialEmailuser( $par ) { - global $wgUser, $wgOut, $wgRequest; + global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgEnableUserEmail; + if( !( $wgEnableEmail && $wgEnableUserEmail ) ) { + $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); + return; + } + if ( 0 == $wgUser->getID() || ( false === strpos( $wgUser->getEmail(), "@" ) ) ) { $wgOut->errorpage( "mailnologin", "mailnologintext" ); diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index b93c7fc69a..dd4905cea9 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -176,7 +176,10 @@ class PreferencesForm { } $wgUser->setPassword( $this->mNewpass ); } - $wgUser->setEmail( $this->mUserEmail ); + global $wgEnableEmail; + if( $wgEnableEmail ) { + $wgUser->setEmail( $this->mUserEmail ); + } $wgUser->setRealName( $this->mRealName ); $wgUser->setOption( 'language', $this->mUserLanguage ); $wgUser->setOption( 'variant', $this->mUserVariant ); @@ -200,7 +203,10 @@ class PreferencesForm { $wgUser->setOption( "searchNs{$i}", $value ); } - $wgUser->setOption( 'disablemail', $this->mEmailFlag ); + global $wgEnableUserEmail; + if( $wgEnableEmail && $wgEnableUserEmail ) { + $wgUser->setOption( 'disablemail', $this->mEmailFlag ); + } # Set user toggles foreach ( $this->mToggles as $tname => $tvalue ) { @@ -388,9 +394,18 @@ class PreferencesForm { if ($wgAllowRealName) { $wgOut->addHTML("
"); } + + global $wgEnableEmail, $wgEnableUserEmail; + if( $wgEnableEmail ) { + $wgOut->addHTML(" +
" ); + if( $wgEnableUserEmail ) { + $wgOut->addHTML(" +
" ); + } + } + $wgOut->addHTML(" -
-