r45056 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45055‎ | r45056 | r45057 >
Date:18:57, 26 December 2008
Author:btongminh
Status:deferred
Tags:
Comment:
Commit fixes that were live applied on our wiki.
Modified paths:
  • /trunk/extensions/NssMySQLAuth/SpecialAccountManager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NssMySQLAuth/SpecialAccountManager.php
@@ -72,7 +72,7 @@
7373 foreach( $wgUserProperties as $key ) {
7474 $value = isset( $props[$key] ) ? $props[$key] : '';
7575 $row .= "<td>".Xml::input(
76 - "am-{$name}-{$key}", 30, $value
 76+ "am-{$name}-".str_replace( ' ', '_', $key ), 30, $value
7777 )."</td>";
7878 }
7979 $row .= "</tr>\n";
@@ -108,7 +108,7 @@
109109 $msg = 'am-'.$i;
110110 $wgOut->addHTML( "\t<tr><th>".
111111 (wfEmptyMsg( $msg, wfMsg( $msg ) ) ? $i : wfMsgHtml( $msg )).
112 - "</th><td>".Xml::input( "am-{$i}", 40 ).
 112+ "</th><td>".Xml::input( "am-".str_replace( ' ', '_', $i ), 40 ).
113113 "</td></tr>\n"
114114 );
115115 }
@@ -131,8 +131,25 @@
132132 'type' => 'submit',
133133 'value' => wfMsg( 'nss-create-account' )
134134 ) ).
135 - "</div>\n</form>"
 135+ "</div>\n</form>\n"
136136 );
 137+
 138+ $wgOut->addHTML( Xml::openElement( 'form', array(
 139+ 'action' => $this->getTitle()->getLocalURL(),
 140+ 'method' => 'post' )
 141+ ) );
 142+ $wgOut->addHTML( "<div id=\"newaccount-raw\">\n".
 143+ Xml::textarea( 'nss-create-account-raw', '' )."\n".
 144+ Xml::hidden( 'action', 'create-raw' ).
 145+ Xml::checkLabel( wfMsg( 'nss-no-mail' ), 'nss-no-mail', 'nss-no-mail' ).
 146+ "<br />\n".
 147+ Xml::element( 'input', array(
 148+ 'type' => 'submit',
 149+ 'value' => wfMsg( 'nss-create-account' )
 150+ ) ).
 151+ "</div>\n</form>\n"
 152+ );
 153+
137154 }
138155
139156 function processData() {
@@ -149,13 +166,13 @@
150167 continue;
151168
152169 $username = strtolower( $parts[1] );
153 - $keyname = strtolower( $parts[2] );
 170+ $keyname = str_replace( '_', ' ', strtolower( $parts[2] ) );
154171
155172 if( !isset( $this->users[$username] ) )
156173 continue;
157174
158175 if( !in_array( $keyname, $wgUserProperties ) &&
159 - !in_array( $keyname, array( 'email', 'active' )) )
 176+ !in_array( $keyname, array( 'email', 'active' ) ) )
160177 continue;
161178
162179 $this->users[$username]->set( $keyname, $value );
@@ -181,9 +198,36 @@
182199 if( count( $parts ) != 2 )
183200 continue;
184201
185 - $keyname = strtolower( $parts[1] );
 202+ $keyname = str_replace( '_', '-', strtolower( $parts[1] ) );
186203 $options[$keyname] = $value;
187204 }
 205+ return $this->internalProcessCreateAccount( $options,
 206+ $wgRequest->getCheck( 'nss-no-mail') );
 207+
 208+ }
 209+ function processCreateAccountRaw() {
 210+ global $wgRequest, $wgUserProperties;
 211+ if( !$wgRequest->wasPosted() || $wgRequest->getVal('action') != 'create-raw' )
 212+ return;
 213+
 214+ $data = $wgRequest->getText( 'nss-create-account-raw' );
 215+ $nomail = $wgRequest->getCheck( 'nss-no-mail');
 216+ $lines = explode( "\n", $data );
 217+ foreach ( $lines as $line ) {
 218+ $line = trim( $line );
 219+ $items = explode( "\t", $line );
 220+ if ( count( $items ) == $wgUserProperties + 1 ) {
 221+ $username = array_shift( $items );
 222+ $options = array_combine( $wgUserProperties, $items );
 223+ $options['username'] = $username;
 224+ $this->internalProcessCreateAccount( $options, $nomail );
 225+ }
 226+
 227+ }
 228+
 229+ }
 230+
 231+ function internalProcessCreateAccount( $options, $nomail = false ) {
188232 if( empty( $options['username'] ) ) {
189233 $this->mErrors[] = 'noname';
190234 return false;
@@ -201,7 +245,7 @@
202246 }
203247 $this->users[$userprops->getName()] = $userprops;
204248
205 - if ( $wgRequest->getCheck( 'nss-no-mail' ) )
 249+ if ( $nomail )
206250 return true;
207251
208252 global $wgPasswordSender;

Status & tagging log