Add site-wide options to disable all e-mail functions or only user-to-user email.
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 25 Nov 2004 06:20:01 +0000 (06:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 25 Nov 2004 06:20:01 +0000 (06:20 +0000)
includes/DefaultSettings.php
includes/Skin.php
includes/SpecialEmailuser.php
includes/SpecialPreferences.php
includes/SpecialUserlogin.php
includes/templates/Userlogin.php
skins/CologneBlue.php
skins/Standard.php

index 3805fff..aa46220 100644 (file)
@@ -158,6 +158,20 @@ $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
  */
 $wgPasswordSender      = 'Wikipedia Mail <apache@' . $wgServerName . '>';
 
+/**
+ * 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
index f0bb25b..a923e88 100644 (file)
@@ -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;
 
index dbe6532..8aed0f2 100644 (file)
 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" );
index b93c7fc..dd4905c 100644 (file)
@@ -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("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
                }
+               
+               global $wgEnableEmail, $wgEnableUserEmail;
+               if( $wgEnableEmail ) {
+                       $wgOut->addHTML("
+                       <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
+                       if( $wgEnableUserEmail ) {
+                               $wgOut->addHTML("
+                               <div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>" );
+                       }
+               }
+               
                $wgOut->addHTML("
-               <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>
-               <div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf</label></div>
                <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='12' /></label></div>
                <div><label>$yl: <select name=\"wpUserLanguage\">\n");
 
index b36c28b..b888186 100644 (file)
@@ -35,7 +35,7 @@ class LoginForm {
        var $mLoginattempt, $mRemember, $mEmail;
        
        function LoginForm( &$request ) {
-               global $wgLang, $wgAllowRealName;
+               global $wgLang, $wgAllowRealName, $wgEnableEmail;
 
                $this->mName = $request->getText( 'wpName' );
                $this->mPassword = $request->getText( 'wpPassword' );
@@ -44,13 +44,19 @@ class LoginForm {
                $this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
                $this->mPosted = $request->wasPosted();
                $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' );
-               $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' );
-               $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' );
+               $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' )
+                                           && $wgEnableEmail;
+               $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' )
+                                        && $wgEnableEmail;
                $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
                $this->mAction = $request->getVal( 'action' );
                $this->mRemember = $request->getCheck( 'wpRemember' );
                
-               $this->mEmail = $request->getText( 'wpEmail' );
+               if( $wgEnableEmail ) {
+                       $this->mEmail = $request->getText( 'wpEmail' );
+               } else {
+                       $this->mEmail = '';
+               }
                if( $wgAllowRealName ) {
                    $this->mRealName = $request->getText( 'wpRealName' );
                } else {
@@ -379,7 +385,7 @@ class LoginForm {
         */
        function mainLoginForm( $err ) {
                global $wgUser, $wgOut, $wgLang;
-               global $wgDBname, $wgAllowRealName;
+               global $wgDBname, $wgAllowRealName, $wgEnableEmail;
 
                if ( '' == $this->mName ) {
                        if ( 0 != $wgUser->getID() ) {
@@ -408,8 +414,9 @@ class LoginForm {
                $template->set( 'action', $titleObj->getLocalUrl( $q ) );
                $template->set( 'error', $err );
                $template->set( 'create', $wgUser->isAllowedToCreateAccount() );
-               $template->set( 'createemail', $wgUser->getID() != 0 );
+               $template->set( 'createemail', $wgEnableEmail && $wgUser->getID() != 0 );
                $template->set( 'userealname', $wgAllowRealName );
+               $template->set( 'useemail', $wgEnableEmail );
                $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) );
                
                $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
index 746d5a7..05da76a 100644 (file)
@@ -55,22 +55,22 @@ class UserloginTemplate extends QuickTemplate {
                        <td><?php $this->msg('newusersonly') ?></td>
                </tr>
                <tr>
-                       <td align='right'><?php $this->msg('youremail') ?>:</td>
-                       <td align='left'>
-                               <input tabindex='7' type='text' name="wpEmail"
-                                       value="<?php $this->text('email') ?>" size='20' />
-                       </td>
-               <?php if( $this->data['userealname'] ) { ?>
-                       <td>&nbsp;</td>
-               </tr>
-               <tr>
-                       <td align='right'><?php $this->msg('yourrealname') ?>:</td>
-                       <td align='left'>
-                               <input tabindex='8' type='text' name="wpRealName" 
-                                       value="<?php $this->text('realname') ?>" size='20' />
-                       </td>
-               <?php } ?>
-
+                       <?php if( $this->data['useemail'] ) { ?>
+                               <td align='right'><?php $this->msg('youremail') ?>:</td>
+                               <td align='left'>
+                                       <input tabindex='7' type='text' name="wpEmail"
+                                               value="<?php $this->text('email') ?>" size='20' />
+                               </td>
+                       <?php } ?>
+                       <?php if( $this->data['userealname'] ) { ?>
+                               </tr>
+                               <tr>
+                                       <td align='right'><?php $this->msg('yourrealname') ?>:</td>
+                                       <td align='left'>
+                                               <input tabindex='8' type='text' name="wpRealName" 
+                                                       value="<?php $this->text('realname') ?>" size='20' />
+                                       </td>
+                       <?php } ?>
                        <td align='left'>
                                <input tabindex='9' type='submit' name="wpCreateaccount"
                                        value="<?php $this->msg('createaccount') ?>" />
@@ -81,6 +81,7 @@ class UserloginTemplate extends QuickTemplate {
                        </td>
                </tr>
        <?php } ?>
+       <?php if( $this->data['useemail'] ) { ?>
                <tr>
                        <td colspan='3'>&nbsp;</td>
                </tr>
@@ -93,6 +94,7 @@ class UserloginTemplate extends QuickTemplate {
                                </p>
                        </td>
                </tr>
+       <?php } ?>
        </table>
 </form>
 <?php
index 7b709cf..729739b 100644 (file)
@@ -218,7 +218,7 @@ class SkinCologneBlue extends Skin {
                                $id=User::idFromName($wgTitle->getText());
                                if ($id != 0) {
                                        $s .= $sep . $this->userContribsLink();
-                                       if ( 0 != $wgUser->getID() ) {
+                                       if( $this->showEmailUser( $id ) ) {
                                                $s .= $sep . $this->emailUserLink();
                                        }
                                }
index 6c71c66..6698cf2 100644 (file)
@@ -251,10 +251,8 @@ class SkinStandard extends Skin {
                                if($id||$ip) {
                                        $s .= $sep . $this->userContribsLink();
                                }
-                               if ( 0 != $wgUser->getID() ) {
-                                       if($id) { # can only email real users
-                                               $s .= $sep . $this->emailUserLink();
-                                       }
+                               if( $this->showEmailUser( $id ) ) {
+                                       $s .= $sep . $this->emailUserLink();
                                }
                        }
                        $s .= "\n<br /><hr class='sep' />";