Index: branches/ApiEdit_Vodafone/includes/SpecialUserlogin.php |
— | — | @@ -55,7 +55,8 @@ |
56 | 56 | const NO_COOKIES_LOGIN = 29; |
57 | 57 | const ERROR = 30; |
58 | 58 | const SUCCESFUL_LOGIN = 31; |
59 | | - |
| 59 | + const USER_BLOCKED = 32; |
| 60 | + |
60 | 61 | var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
61 | 62 | var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword; |
62 | 63 | var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage; |
— | — | @@ -111,7 +112,6 @@ |
112 | 113 | function execute() { |
113 | 114 | $resultDetails = null; |
114 | 115 | $value = null; |
115 | | - |
116 | 116 | if ( !is_null( $this->mCookieCheck ) ) { |
117 | 117 | $value = $this->onCookieRedirectCheck( $this->mCookieCheck, $resultDetails ); |
118 | 118 | return $this->processRest($value, $resultDetails); |
— | — | @@ -163,7 +163,6 @@ |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | | - |
168 | 167 | /** |
169 | 168 | * @private |
170 | 169 | */ |
— | — | @@ -208,8 +207,7 @@ |
209 | 208 | } else { |
210 | 209 | # Confirm that the account was created |
211 | 210 | $results['user'] = $u; |
212 | | - |
213 | | - |
| 211 | + |
214 | 212 | wfRunHooks( 'AddNewAccount', array( $u ) ); |
215 | 213 | return self::SUCCESS; |
216 | 214 | } |
— | — | @@ -223,7 +221,7 @@ |
224 | 222 | global $wgEnableSorbs, $wgProxyWhitelist; |
225 | 223 | global $wgMemc, $wgAccountCreationThrottle; |
226 | 224 | global $wgAuth, $wgMinimalPasswordLength; |
227 | | - |
| 225 | + |
228 | 226 | // If the user passes an invalid domain, something is fishy |
229 | 227 | if( !$wgAuth->validDomain( $this->mDomain ) ) { |
230 | 228 | return self::WRONG_PASS; |
— | — | @@ -245,9 +243,11 @@ |
246 | 244 | return self::READ_ONLY; |
247 | 245 | } |
248 | 246 | |
249 | | - # Check anonymous user ($wgUser) limitations : |
250 | | - if (!$wgUser->isAllowedToCreateAccount()) { |
| 247 | + # Check permissions |
| 248 | + if ( !$wgUser->isAllowed( 'createaccount' ) ) { |
251 | 249 | return self::NOT_ALLOWED; |
| 250 | + } elseif ( $wgUser->isBlockedFromCreateAccount() ) { |
| 251 | + return self::USER_BLOCKED; |
252 | 252 | } |
253 | 253 | |
254 | 254 | $ip = wfGetIP(); |
— | — | @@ -297,7 +297,6 @@ |
298 | 298 | $wgMemc->set( $key, 1, 86400 ); |
299 | 299 | } |
300 | 300 | if ( $value > $wgAccountCreationThrottle ) { |
301 | | - |
302 | 301 | return self::ILLEGAL; |
303 | 302 | } |
304 | 303 | } |
— | — | @@ -447,7 +446,6 @@ |
448 | 447 | $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $this->mName ) ); |
449 | 448 | $wgOut->returnToMain( $self->getPrefixedText() ); |
450 | 449 | break; |
451 | | - |
452 | 450 | case self::COOKIE: |
453 | 451 | $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false ); |
454 | 452 | break; |
— | — | @@ -463,6 +461,9 @@ |
464 | 462 | case self::NOT_ALLOWED: |
465 | 463 | $this->userNotPrivilegedMessage(); |
466 | 464 | break; |
| 465 | + case self::USER_BLOCKED: |
| 466 | + $this->userBlockedMessage(); |
| 467 | + break; |
467 | 468 | case self::SORBS: |
468 | 469 | $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $results['ip'] ) . ')' ); |
469 | 470 | break; |
Index: branches/ApiEdit_Vodafone/includes/api/ApiRegUser.php |
— | — | @@ -42,19 +42,34 @@ |
43 | 43 | parent :: __construct($query, $moduleName, 'ru');
|
44 | 44 | }
|
45 | 45 |
|
| 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 | +
|
46 | 61 | public function process($value,$results = null) {
|
47 | 62 | switch ($value) {
|
48 | 63 | case ApiRegUser::GET_CAPTCHA :
|
49 | 64 | $myCaptcha = new FancyCaptcha();
|
50 | 65 | $myCaptcha->storage->clearAll();
|
51 | 66 | $result['result'] = 'CaptchaIdGenerated';
|
52 | | - $myCaptcha->getXML($result);
|
| 67 | + $this->captchaSupport($myCaptcha, $result);
|
53 | 68 | break;
|
54 | 69 | case ApiRegUser::MISSING_CAPTCHA :
|
55 | 70 | $myCaptcha = new FancyCaptcha();
|
56 | 71 | $myCaptcha->storage->clearAll();
|
57 | 72 | $result['result'] = 'MissingCaptcha';
|
58 | | - $myCaptcha->getXML($result);
|
| 73 | + $this->captchaSupport($myCaptcha, $result);
|
59 | 74 | break;
|
60 | 75 | case LoginForm::SUCCESS :
|
61 | 76 | $result['result'] = 'Success';
|
— | — | @@ -80,6 +95,9 @@ |
81 | 96 | case LoginForm::NOT_ALLOWED :
|
82 | 97 | $result['result'] = 'NotAllowed';
|
83 | 98 | break;
|
| 99 | + case LoginForm::USER_BLOCKED :
|
| 100 | + $result['result'] = 'UserBlocked';
|
| 101 | + break;
|
84 | 102 | case LoginForm::SORBS :
|
85 | 103 | $result['result'] = 'Sorbs';
|
86 | 104 | $result['blockedIp'] = $results['ip'];
|