https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106277
Revision: 106277
Author: bsitu
Date: 2011-12-14 23:09:21 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
adding a new temp function trySetUserEmail()
Modified Paths:
--------------
trunk/extensions/MoodBar/ApiMoodBarSetUserEmail.php
Modified: trunk/extensions/MoodBar/ApiMoodBarSetUserEmail.php
===================================================================
--- trunk/extensions/MoodBar/ApiMoodBarSetUserEmail.php 2011-12-14 23:02:31 UTC
(rev 106276)
+++ trunk/extensions/MoodBar/ApiMoodBarSetUserEmail.php 2011-12-14 23:09:21 UTC
(rev 106277)
@@ -28,7 +28,7 @@
$error = wfMsgExt(
'invalidemailaddress', 'parseinline' ) ;
}
else {
- list( $status, $info )
= Preferences::trySetUserEmail( $wgUser, $params['email'] );
+ list( $status, $info )
= self::trySetUserEmail( $wgUser, $params['email'] );
// Status Object
if ( $status !== true )
{
@@ -68,6 +68,35 @@
$this->getResult()->addValue( null, $this->getModuleName(),
$result );
}
+ /**
+ * Tempoarary solution, will use Preference::trySetUserEmail in 1.19
+ */
+ private static function trySetUserEmail( User $user, $newaddr ) {
+ global $wgEnableEmail, $wgEmailAuthentication;
+ $info = ''; // none
+
+ if ( $wgEnableEmail ) {
+ $oldaddr = $user->getEmail();
+ if ( ( $newaddr != '' ) && ( $newaddr != $oldaddr ) ) {
+ $user->setEmail( $newaddr );
+ if ( $wgEmailAuthentication ) {
+ $type = $oldaddr != '' ? 'changed' :
'set';
+ $result = $user->sendConfirmationMail(
$type );
+ if ( !$result->isGood() ) {
+ return array( $result,
'mailerror' );
+ }
+ $info = 'eauth';
+ }
+ } elseif ( $newaddr != $oldaddr ) { // if the address
is the same, don't change it
+ $user->setEmail( $newaddr );
+ }
+ }
+
+ return array( true, $info );
+ }
+
+
+
public function needsToken() {
return true;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs