r26205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26204‎ | r26205 | r26206 >
Date:12:11, 28 September 2007
Author:jvelezv
Status:old
Tags:
Comment:
SpecialUserlogin merged. Small updates in ApiRegUser.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/SpecialUserlogin.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/api/ApiRegUser.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/SpecialUserlogin.php
@@ -55,7 +55,8 @@
5656 const NO_COOKIES_LOGIN = 29;
5757 const ERROR = 30;
5858 const SUCCESFUL_LOGIN = 31;
59 -
 59+ const USER_BLOCKED = 32;
 60+
6061 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
6162 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
6263 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
@@ -111,7 +112,6 @@
112113 function execute() {
113114 $resultDetails = null;
114115 $value = null;
115 -
116116 if ( !is_null( $this->mCookieCheck ) ) {
117117 $value = $this->onCookieRedirectCheck( $this->mCookieCheck, $resultDetails );
118118 return $this->processRest($value, $resultDetails);
@@ -163,7 +163,6 @@
164164 }
165165 }
166166
167 -
168167 /**
169168 * @private
170169 */
@@ -208,8 +207,7 @@
209208 } else {
210209 # Confirm that the account was created
211210 $results['user'] = $u;
212 -
213 -
 211+
214212 wfRunHooks( 'AddNewAccount', array( $u ) );
215213 return self::SUCCESS;
216214 }
@@ -223,7 +221,7 @@
224222 global $wgEnableSorbs, $wgProxyWhitelist;
225223 global $wgMemc, $wgAccountCreationThrottle;
226224 global $wgAuth, $wgMinimalPasswordLength;
227 -
 225+
228226 // If the user passes an invalid domain, something is fishy
229227 if( !$wgAuth->validDomain( $this->mDomain ) ) {
230228 return self::WRONG_PASS;
@@ -245,9 +243,11 @@
246244 return self::READ_ONLY;
247245 }
248246
249 - # Check anonymous user ($wgUser) limitations :
250 - if (!$wgUser->isAllowedToCreateAccount()) {
 247+ # Check permissions
 248+ if ( !$wgUser->isAllowed( 'createaccount' ) ) {
251249 return self::NOT_ALLOWED;
 250+ } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
 251+ return self::USER_BLOCKED;
252252 }
253253
254254 $ip = wfGetIP();
@@ -297,7 +297,6 @@
298298 $wgMemc->set( $key, 1, 86400 );
299299 }
300300 if ( $value > $wgAccountCreationThrottle ) {
301 -
302301 return self::ILLEGAL;
303302 }
304303 }
@@ -447,7 +446,6 @@
448447 $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $this->mName ) );
449448 $wgOut->returnToMain( $self->getPrefixedText() );
450449 break;
451 -
452450 case self::COOKIE:
453451 $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
454452 break;
@@ -463,6 +461,9 @@
464462 case self::NOT_ALLOWED:
465463 $this->userNotPrivilegedMessage();
466464 break;
 465+ case self::USER_BLOCKED:
 466+ $this->userBlockedMessage();
 467+ break;
467468 case self::SORBS:
468469 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $results['ip'] ) . ')' );
469470 break;
Index: branches/ApiEdit_Vodafone/includes/api/ApiRegUser.php
@@ -42,19 +42,34 @@
4343 parent :: __construct($query, $moduleName, 'ru');
4444 }
4545
 46+ /**
 47+ * Return the link to the captcha generated
 48+ */
 49+ function captchaSupport($myCaptcha, &$result) {
 50+ $info = $myCaptcha->pickImage();
 51+ if( !$info ) {
 52+ return -1;
 53+ } else {
 54+ $index = $myCaptcha->storeCaptcha( $info );
 55+ $title = Title::makeTitle( NS_SPECIAL, 'Captcha/image' );
 56+ $result['captchaId'] = $index;
 57+ $result['captchaURL'] = $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) );
 58+ }
 59+ }
 60+
4661 public function process($value,$results = null) {
4762 switch ($value) {
4863 case ApiRegUser::GET_CAPTCHA :
4964 $myCaptcha = new FancyCaptcha();
5065 $myCaptcha->storage->clearAll();
5166 $result['result'] = 'CaptchaIdGenerated';
52 - $myCaptcha->getXML($result);
 67+ $this->captchaSupport($myCaptcha, $result);
5368 break;
5469 case ApiRegUser::MISSING_CAPTCHA :
5570 $myCaptcha = new FancyCaptcha();
5671 $myCaptcha->storage->clearAll();
5772 $result['result'] = 'MissingCaptcha';
58 - $myCaptcha->getXML($result);
 73+ $this->captchaSupport($myCaptcha, $result);
5974 break;
6075 case LoginForm::SUCCESS :
6176 $result['result'] = 'Success';
@@ -80,6 +95,9 @@
8196 case LoginForm::NOT_ALLOWED :
8297 $result['result'] = 'NotAllowed';
8398 break;
 99+ case LoginForm::USER_BLOCKED :
 100+ $result['result'] = 'UserBlocked';
 101+ break;
84102 case LoginForm::SORBS :
85103 $result['result'] = 'Sorbs';
86104 $result['blockedIp'] = $results['ip'];

Status & tagging log