Index: trunk/extensions/NssMySQLAuth/SpecialAccountManager.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | foreach( $wgUserProperties as $key ) { |
74 | 74 | $value = isset( $props[$key] ) ? $props[$key] : ''; |
75 | 75 | $row .= "<td>".Xml::input( |
76 | | - "am-{$name}-{$key}", 30, $value |
| 76 | + "am-{$name}-".str_replace( ' ', '_', $key ), 30, $value |
77 | 77 | )."</td>"; |
78 | 78 | } |
79 | 79 | $row .= "</tr>\n"; |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | $msg = 'am-'.$i; |
110 | 110 | $wgOut->addHTML( "\t<tr><th>". |
111 | 111 | (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 ). |
113 | 113 | "</td></tr>\n" |
114 | 114 | ); |
115 | 115 | } |
— | — | @@ -131,8 +131,25 @@ |
132 | 132 | 'type' => 'submit', |
133 | 133 | 'value' => wfMsg( 'nss-create-account' ) |
134 | 134 | ) ). |
135 | | - "</div>\n</form>" |
| 135 | + "</div>\n</form>\n" |
136 | 136 | ); |
| 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 | + |
137 | 154 | } |
138 | 155 | |
139 | 156 | function processData() { |
— | — | @@ -149,13 +166,13 @@ |
150 | 167 | continue; |
151 | 168 | |
152 | 169 | $username = strtolower( $parts[1] ); |
153 | | - $keyname = strtolower( $parts[2] ); |
| 170 | + $keyname = str_replace( '_', ' ', strtolower( $parts[2] ) ); |
154 | 171 | |
155 | 172 | if( !isset( $this->users[$username] ) ) |
156 | 173 | continue; |
157 | 174 | |
158 | 175 | if( !in_array( $keyname, $wgUserProperties ) && |
159 | | - !in_array( $keyname, array( 'email', 'active' )) ) |
| 176 | + !in_array( $keyname, array( 'email', 'active' ) ) ) |
160 | 177 | continue; |
161 | 178 | |
162 | 179 | $this->users[$username]->set( $keyname, $value ); |
— | — | @@ -181,9 +198,36 @@ |
182 | 199 | if( count( $parts ) != 2 ) |
183 | 200 | continue; |
184 | 201 | |
185 | | - $keyname = strtolower( $parts[1] ); |
| 202 | + $keyname = str_replace( '_', '-', strtolower( $parts[1] ) ); |
186 | 203 | $options[$keyname] = $value; |
187 | 204 | } |
| 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 ) { |
188 | 232 | if( empty( $options['username'] ) ) { |
189 | 233 | $this->mErrors[] = 'noname'; |
190 | 234 | return false; |
— | — | @@ -201,7 +245,7 @@ |
202 | 246 | } |
203 | 247 | $this->users[$userprops->getName()] = $userprops; |
204 | 248 | |
205 | | - if ( $wgRequest->getCheck( 'nss-no-mail' ) ) |
| 249 | + if ( $nomail ) |
206 | 250 | return true; |
207 | 251 | |
208 | 252 | global $wgPasswordSender; |