GF | 8 May 14:41
Picon

enable email but disable email change.

I am creating a custom authentication plugin.
The user email is loaded from an external source and it is stored in the
mediawiki DB.

The problem is that if  a user go to his preferences page, it will have the
chance to change his email address.

Looking in specialPreferences.php I have found this:

        if ( $wgEnableEmail ) {

            $moreEmail = '';
            if ($wgEnableUserEmail) {
                $emf = wfMsg( 'allowemail' );
                $disabled = $disableEmailPrefs ? ' disabled="disabled"' :
'';
                $moreEmail =
                "<input type='checkbox' $emfc $disabled value='1'
name='wpEmailFlag' id='wpEmailFlag' /> <label
for='wpEmailFlag'>$emf</label>";
            }

            $wgOut->addHTML(
                $this->tableRow( Xml::element( 'h2', null, wfMsg( 'email' )
) ) .
                $this->tableRow(
                    $emailauthenticated.
                    $enotifrevealaddr.
                    $enotifwatchlistpages.
                    $enotifusertalkpages.
(Continue reading)

Alexis Moinet | 8 May 16:21
Picon

Re: enable email but disable email change.

GF wrote :
> IS there any way for doing what I need (apart modifying brutally the
> specialPreferences.php?

I would suggest to add the appropriate Hook (http://www.mediawiki.org/wiki/Hook) in LocalSettings.php.

Someone with more experience with hooks and SpecialPreferences.php might tell you which hook to use.

my guess would be the "InitPreferencesForm" Hook (with something like $foo->mUserEmail =
$wgUser->getEmail(); )
Alexis Moinet | 9 May 11:13
Picon

Re: enable email but disable email change.

fyi, this, added at the end of LocalSettings.php, worked on a local install (1.11) :

$wgHooks['InitPreferencesForm'][] = 'fnMyHook';

function fnMyHook($prefs, $request) {
  global $wgUser;

  $prefs->mUserEmail = $wgUser->getEmail();

  return false;
}

Alexis Moinet wrote :
> GF wrote :
>> IS there any way for doing what I need (apart modifying brutally the
>> specialPreferences.php?
> 
> I would suggest to add the appropriate Hook (http://www.mediawiki.org/wiki/Hook) in LocalSettings.php.
> 
> Someone with more experience with hooks and SpecialPreferences.php might tell you which hook to use.
> 
> my guess would be the "InitPreferencesForm" Hook (with something like $foo->mUserEmail =
$wgUser->getEmail(); )

Gmane