r97865 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97864‎ | r97865 | r97866 >
Date:22:35, 22 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix more whitespace etc
Modified paths:
  • /trunk/extensions/SignupAPI/includes/ApiSignup.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/ApiValidateSignup.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/SignupAPI.hooks.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/SpecialUserSignup.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/verification.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SignupAPI/includes/ApiValidateSignup.php
@@ -25,21 +25,22 @@
2626 case "username":
2727 $mUser = User::newFromName( $params['inputVal'], 'creatable' );
2828 if ( !is_object( $mUser ) ) {
29 - $result['result'] = wfMsg( 'signupapi-noname' );
30 - $result['icon'] = 'MW-Icon-AlertMark.png';
 29+ $result['result'] = wfMsg( 'signupapi-noname' );
 30+ $result['icon'] = 'MW-Icon-AlertMark.png';
3131 }
3232
3333 if ( 0 != $mUser->idForName() ) {
34 - $result['result'] = wfMsg( 'signupapi-userexists' );
35 - $result['icon'] = "MW-Icon-NoMark.png";
 34+ $result['result'] = wfMsg( 'signupapi-userexists' );
 35+ $result['icon'] = "MW-Icon-NoMark.png";
3636 } else {
37 - $result['result'] = wfMsg( 'signupapi-ok' );
38 - $result['icon'] = "MW-Icon-CheckMark.png";
 37+ $result['result'] = wfMsg( 'signupapi-ok' );
 38+ $result['icon'] = "MW-Icon-CheckMark.png";
3939 }
4040 break;
4141
4242 case "email" :
43 - if ( $valid = User::isValidEmailAddr( $params['inputVal'] ) ) {
 43+ $valid = User::isValidEmailAddr( $params['inputVal'] );
 44+ if ( $valid ) {
4445 $result['result']= wfMsg( 'signupapi-ok' );
4546 $result['icon'] = "MW-Icon-CheckMark.png";
4647 } else {
@@ -70,7 +71,7 @@
7172
7273 public function getAllowedParams() {
7374 return array(
74 - 'field' => null,
 75+ 'field' => null,
7576 'inputVal' => null,
7677 'password' => null,
7778 'retype' => null,
Index: trunk/extensions/SignupAPI/includes/ApiSignup.php
@@ -27,10 +27,10 @@
2828 'wpRetype' => $params['retype'],
2929 'wpEmail' => $params['email'],
3030 'wpDomain' => $params['domain'],
31 - 'wpReason' => $params['realname'],
32 - 'wpSourceAction' => $params['source_action'],
33 - 'wpSourceNS' => $params['source_ns'],
34 - 'wpSourceArticle' => $params['source_article'],
 31+ 'wpReason' => $params['realname'],
 32+ 'wpSourceAction' => $params['source_action'],
 33+ 'wpSourceNS' => $params['source_ns'],
 34+ 'wpSourceArticle' => $params['source_article'],
3535 'wpRemember' => ''
3636 ) );
3737
Index: trunk/extensions/SignupAPI/includes/SignupAPI.hooks.php
@@ -79,7 +79,6 @@
8080 'href' => SkinTemplate::makeSpecialUrl( 'UserSignup', "$returnto&type=signup&wpSourceAction=$sourceAction&wpSourceNS=$sourceNS&wpSourceArticle=$sourceArticle" ),
8181 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
8282 );
83 -
8483 if ( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
8584 $title = SpecialPage::getTitleFor( 'UserSignup' );
8685 $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL( "type=signup" ) );
Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php
@@ -243,6 +243,8 @@
244244
245245 /**
246246 * @private
 247+ *
 248+ * @return User|int If int, it is a returned constant
247249 */
248250 function addNewAccountInternal() {
249251 global $wgUser;
@@ -905,6 +907,10 @@
906908 }
907909 }
908910
 911+ /**
 912+ * @param $tempUser User
 913+ * @return bool
 914+ */
909915 private function addToSourceTracking( $tempUser ) {
910916 $sourcetracking_data = array(
911917 'userid' => $tempUser->getId(),
Index: trunk/extensions/SignupAPI/includes/verification.js
@@ -1,63 +1,61 @@
22 //setup verification fields on the form
33
44 function validateInput( fieldtype,fieldid ) {
5 - var inputVal = document.getElementById(fieldid).value;
6 - var valresult = document.getElementById(fieldid+'val');
7 - $.ajax({
8 - type: "POST",
9 - url: mw.util.wikiScript('api'),
10 - data: {'action':'validatesignup', 'format':'json', 'field':fieldtype, 'inputVal':inputVal },
11 - dataType: 'json',
12 - success: function( jsondata ){
13 - var image = "<img src='"+ imagePath + jsondata.signup.icon +"'>";
14 - var message = jsondata.signup.result;
15 - valresult.innerHTML = image+message;
16 - }
17 - });
 5+ var inputVal = document.getElementById(fieldid).value;
 6+ var valresult = document.getElementById(fieldid+'val');
 7+ $.ajax({
 8+ type: "POST",
 9+ url: mw.util.wikiScript('api'),
 10+ data: {'action':'validatesignup', 'format':'json', 'field':fieldtype, 'inputVal':inputVal },
 11+ dataType: 'json',
 12+ success: function( jsondata ){
 13+ var image = "<img src='"+ imagePath + jsondata.signup.icon +"'>";
 14+ var message = jsondata.signup.result;
 15+ valresult.innerHTML = image+message;
 16+ }
 17+ });
1818 }
1919
2020 function passwordStrength() {
 21+ var strength = document.getElementById('wpPassword2val');
 22+ var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
 23+ var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
 24+ var enoughRegex = new RegExp("(?=.{6,}).*", "g");
 25+ var pwd = document.getElementById("wpPassword2");
2126
22 - var strength = document.getElementById('wpPassword2val');
23 - var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
24 - var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
25 - var enoughRegex = new RegExp("(?=.{6,}).*", "g");
26 - var pwd = document.getElementById("wpPassword2");
27 -
28 - if (pwd.value.length==0) {
29 - strength.innerHTML = mw.message( 'signupapi-enterpassword' );
30 - } else if (pwd.value.length<minlength) {
31 - strength.innerHTML = mw.message( 'signupapi-passwordtooshort', minlength );
32 - $("#progress").progressbar({value: 10});
33 - $("div.ui-progressbar-value").css("background","red");
34 - } else if (strongRegex.test(pwd.value)) {
35 - strength.innerHTML = '<span style="color:green">'+mw.message( 'signupapi-strong' )+'</span>';
36 - $("#progress").progressbar({value: 100});
37 - $("div.ui-progressbar-value").css("background","green");
38 - } else if (mediumRegex.test(pwd.value)) {
39 - strength.innerHTML = '<span style="color:orange">'+mw.message( 'signupapi-medium' )+'</span>';
40 - $("#progress").progressbar({value: 60});
41 - $("div.ui-progressbar-value").css("background","orange");
42 - } else {
43 - strength.innerHTML = '<span style="color:red">'+mw.message( 'signupapi-weak' )+'</span>';
44 - $("#progress").progressbar({value: 30});
45 - $("div.ui-progressbar-value").css("background","red");
46 - }
 27+ if (pwd.value.length==0) {
 28+ strength.innerHTML = mw.message( 'signupapi-enterpassword' );
 29+ } else if (pwd.value.length<minlength) {
 30+ strength.innerHTML = mw.message( 'signupapi-passwordtooshort', minlength );
 31+ $("#progress").progressbar({value: 10});
 32+ $("div.ui-progressbar-value").css("background","red");
 33+ } else if (strongRegex.test(pwd.value)) {
 34+ strength.innerHTML = '<span style="color:green">'+mw.message( 'signupapi-strong' )+'</span>';
 35+ $("#progress").progressbar({value: 100});
 36+ $("div.ui-progressbar-value").css("background","green");
 37+ } else if (mediumRegex.test(pwd.value)) {
 38+ strength.innerHTML = '<span style="color:orange">'+mw.message( 'signupapi-medium' )+'</span>';
 39+ $("#progress").progressbar({value: 60});
 40+ $("div.ui-progressbar-value").css("background","orange");
 41+ } else {
 42+ strength.innerHTML = '<span style="color:red">'+mw.message( 'signupapi-weak' )+'</span>';
 43+ $("#progress").progressbar({value: 30});
 44+ $("div.ui-progressbar-value").css("background","red");
 45+ }
4746 }
4847
49 -
5048 function checkRetype( pass,retype ) {
51 - var valresult = document.getElementById('wpRetypeval');
52 - var image = "";
53 - var message = "";
54 - if ( pass==retype ) {
55 - image = "<img src='"+ imagePath +"MW-Icon-CheckMark.png'>";
56 - message = mw.message( 'signupapi-passwordsmatch' );
57 - }else {
58 - image = "<img src='"+ imagePath +"MW-Icon-NoMark.png'>";
59 - message = mw.message( 'signupapi-badretype' );
60 - }
61 - valresult.innerHTML = image+message;
 49+ var valresult = document.getElementById('wpRetypeval');
 50+ var image = "";
 51+ var message = "";
 52+ if ( pass==retype ) {
 53+ image = "<img src='"+ imagePath +"MW-Icon-CheckMark.png'>";
 54+ message = mw.message( 'signupapi-passwordsmatch' );
 55+ }else {
 56+ image = "<img src='"+ imagePath +"MW-Icon-NoMark.png'>";
 57+ message = mw.message( 'signupapi-badretype' );
 58+ }
 59+ valresult.innerHTML = image+message;
6260 }
6361
6462 $('#wpName2').change(function() {validateInput("username","wpName2");});

Status & tagging log