Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -20,7 +20,10 @@ |
21 | 21 | $wgMathDirectory = "{$wgUploadDirectory}/math"; |
22 | 22 | $wgTmpDirectory = "{$wgUploadDirectory}/tmp"; |
23 | 23 | $wgEmergencyContact = "wikiadmin@" . getenv( "SERVER_NAME" ); |
| 24 | +#$wgPasswordSender = "Wikipedia Mail <apache@www.wikipedia.org>"; |
| 25 | +$wgPasswordSender = "Wikipedia Mail <apache@www.wikipedia.org>\r\nReply-To: webmaster@www.wikipedia.org"; |
24 | 26 | |
| 27 | + |
25 | 28 | # MySQL settings |
26 | 29 | # |
27 | 30 | $wgDBserver = "localhost"; |
— | — | @@ -62,10 +65,36 @@ |
63 | 66 | $wgLogQueries = false; |
64 | 67 | $wgUseBetterLinksUpdate = true; |
65 | 68 | |
| 69 | + |
| 70 | +# The following three config variables are used to define |
| 71 | +# the rights of users in your system. |
| 72 | +# |
66 | 73 | # If wgWhitelistEdit is set to true, only logged in users |
67 | 74 | # are allowed to edit articles. |
68 | | -# $wgWhitelistEdit = true; |
| 75 | +# If wgWhitelistRead is set to true, only logged in users |
| 76 | +# are allowed to read articles. |
| 77 | +# |
| 78 | +# wgWhitelistAccount lists user types that can add user accounts: |
| 79 | +# "key" => 1 defines permission if user has right "key". |
| 80 | +# |
| 81 | +# Typical setups are: |
| 82 | +# |
| 83 | +# Everything goes (this is the default behaviour): |
| 84 | +# $wgWhitelistEdit = false; |
| 85 | +# $wgWhitelistRead = false; |
| 86 | +# $wgWhitelistAccount = array ( "user" => 1, "sysop" => 1, "developer" => 1 ); |
| 87 | +# |
| 88 | +# Invitation-only closed shop type of system |
| 89 | +# $wgWhitelistEdit = true; |
| 90 | +# $wgWhitelistRead = true; |
| 91 | +# $wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 ); |
| 92 | +# |
| 93 | +# Public website, closed editorial team |
| 94 | +# $wgWhitelistEdit = true; |
| 95 | +# $wgWhitelistRead = false; |
| 96 | +# $wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 ); |
69 | 97 | |
| 98 | + |
70 | 99 | # Client-side caching: |
71 | 100 | $wgCachePages = true; # Allow client-side caching of pages |
72 | 101 | |
Index: trunk/phase3/includes/SpecialUserlogin.php |
— | — | @@ -2,7 +2,8 @@ |
3 | 3 | |
4 | 4 | function wfSpecialUserlogin() |
5 | 5 | { |
6 | | - global $wpCreateaccount, $wpLoginattempt, $wpMailmypassword; |
| 6 | + global $wpCreateaccount, $wpCreateaccountMail; |
| 7 | + global $wpLoginattempt, $wpMailmypassword; |
7 | 8 | global $action; |
8 | 9 | |
9 | 10 | $fields = array( "wpName", "wpPassword", "wpName", |
— | — | @@ -11,6 +12,8 @@ |
12 | 13 | |
13 | 14 | if ( isset( $wpCreateaccount ) ) { |
14 | 15 | addNewAccount(); |
| 16 | + } else if ( isset( $wpCreateaccountMail ) ) { |
| 17 | + addNewAccountMailPassword(); |
15 | 18 | } else if ( isset( $wpMailmypassword ) ) { |
16 | 19 | mailPassword(); |
17 | 20 | } else if ( "submit" == $action || isset( $wpLoginattempt ) ) { |
— | — | @@ -20,11 +23,66 @@ |
21 | 24 | } |
22 | 25 | } |
23 | 26 | |
| 27 | + |
| 28 | +/* private */ function addNewAccountMailPassword() |
| 29 | +{ |
| 30 | + global $wgOut, $wpEmail, $wpName; |
| 31 | + |
| 32 | + if ("" == $wpEmail) { |
| 33 | + $m = str_replace( "$1", $wpName, wfMsg( "noemail" ) ); |
| 34 | + mainLoginForm( $m ); |
| 35 | + return; |
| 36 | + } |
| 37 | + |
| 38 | + $u = addNewaccountInternal(); |
| 39 | + |
| 40 | + if ($u == NULL) { |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + $u->saveSettings(); |
| 45 | + mailPasswordInternal($u); |
| 46 | + |
| 47 | + $wgOut->setPageTitle( wfMsg( "accmailtitle" ) ); |
| 48 | + $wgOut->setRobotpolicy( "noindex,nofollow" ); |
| 49 | + $wgOut->setArticleFlag( false ); |
| 50 | + |
| 51 | + $m = str_replace( "$1", $u->getName(), wfMsg( "accmailtext" ) ); |
| 52 | + $m = str_replace( "$2", $u->getEmail(), $m ); |
| 53 | + $wgOut->addWikiText( $m ); |
| 54 | + $wgOut->returnToMain( false ); |
| 55 | + |
| 56 | + $u = 0; |
| 57 | +} |
| 58 | + |
| 59 | + |
24 | 60 | /* private */ function addNewAccount() |
25 | 61 | { |
26 | 62 | global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember; |
27 | 63 | global $wpEmail, $wgDeferredUpdateList; |
28 | 64 | |
| 65 | + $u = addNewAccountInternal(); |
| 66 | + |
| 67 | + if ($u == NULL) { |
| 68 | + return; |
| 69 | + } |
| 70 | + |
| 71 | + $wgUser = $u; |
| 72 | + $m = str_replace( "$1", $wgUser->getName(), wfMsg( "welcomecreation" ) ); |
| 73 | + successfulLogin( $m ); |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | +/* private */ function addNewAccountInternal() |
| 78 | +{ |
| 79 | + global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember; |
| 80 | + global $wpEmail, $wgDeferredUpdateList; |
| 81 | + |
| 82 | + if (!userAllowedToCreateAccount()) { |
| 83 | + userNotPrivilegedMessage(); |
| 84 | + return; |
| 85 | + } |
| 86 | + |
29 | 87 | if ( 0 != strcmp( $wpPassword, $wpRetype ) ) { |
30 | 88 | mainLoginForm( wfMsg( "badretype" ) ); |
31 | 89 | return; |
— | — | @@ -33,7 +91,7 @@ |
34 | 92 | if ( ( "" == $wpName ) || |
35 | 93 | preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) || |
36 | 94 | (strpos( $wpName, "/" ) !== false) ) |
37 | | -{ |
| 95 | + { |
38 | 96 | mainLoginForm( wfMsg( "noname" ) ); |
39 | 97 | return; |
40 | 98 | } |
— | — | @@ -53,12 +111,13 @@ |
54 | 112 | if ( 1 == $wpRemember ) { $r = 1; } |
55 | 113 | else { $r = 0; } |
56 | 114 | $u->setOption( "rememberpassword", $r ); |
57 | | - |
58 | | - $wgUser = $u; |
59 | | - $m = str_replace( "$1", $wgUser->getName(), wfMsg( "welcomecreation" ) ); |
60 | | - successfulLogin( $m ); |
| 115 | + |
| 116 | + return $u; |
61 | 117 | } |
62 | 118 | |
| 119 | + |
| 120 | + |
| 121 | + |
63 | 122 | /* private */ function processLogin() |
64 | 123 | { |
65 | 124 | global $wgUser, $wpName, $wpPassword, $wpRemember; |
— | — | @@ -118,6 +177,20 @@ |
119 | 178 | $u->setId( $id ); |
120 | 179 | $u->loadFromDatabase(); |
121 | 180 | |
| 181 | + if (mailPasswordInternal($u) == NULL) { |
| 182 | + return; |
| 183 | + } |
| 184 | + |
| 185 | + $m = str_replace( "$1", $u->getName(), wfMsg( "passwordsent" ) ); |
| 186 | + mainLoginForm( $m ); |
| 187 | +} |
| 188 | + |
| 189 | + |
| 190 | +/* private */ function mailPasswordInternal( $u ) |
| 191 | +{ |
| 192 | + global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding; |
| 193 | + global $wgPasswordSender; |
| 194 | + |
122 | 195 | if ( "" == $u->getEmail() ) { |
123 | 196 | $m = str_replace( "$1", $u->getName(), wfMsg( "noemail" ) ); |
124 | 197 | mainLoginForm( $m ); |
— | — | @@ -136,17 +209,19 @@ |
137 | 210 | $m = str_replace( "$2", $u->getName(), $m ); |
138 | 211 | $m = str_replace( "$3", $np, $m ); |
139 | 212 | |
140 | | - #FIXME: Generilize the email addresses for 3rd party sites... |
141 | 213 | mail( $u->getEmail(), wfMsg( "passwordremindertitle" ), $m, |
142 | 214 | "MIME-Version: 1.0\r\n" . |
143 | 215 | "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" . |
144 | 216 | "Content-transfer-encoding: 8bit\r\n" . |
145 | | - "From: Wikipedia Mail <apache@www.wikipedia.org>\r\n" . |
146 | | - "Reply-To: webmaster@www.wikipedia.org" ); |
147 | | - $m = str_replace( "$1", $u->getName(), wfMsg( "passwordsent" ) ); |
148 | | - mainLoginForm( $m ); |
| 217 | + "From: $wgPasswordSender" ); |
| 218 | + |
| 219 | + return $u; |
149 | 220 | } |
150 | 221 | |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
151 | 226 | /* private */ function successfulLogin( $msg ) |
152 | 227 | { |
153 | 228 | global $wgUser, $wgOut, $returnto; |
— | — | @@ -163,6 +238,37 @@ |
164 | 239 | $wgOut->returnToMain(); |
165 | 240 | } |
166 | 241 | |
| 242 | + |
| 243 | + |
| 244 | +/* private */ function userAllowedToCreateAccount() |
| 245 | +{ |
| 246 | + global $wgUser, $wgWhitelistAccount; |
| 247 | + $allowed = false; |
| 248 | + |
| 249 | + if (!$wgWhitelistAccount) { return 1; }; // default behaviour |
| 250 | + foreach ($wgWhitelistAccount as $right => $ok) { |
| 251 | + $userHasRight = (!strcmp($right, "user") || in_array($right, $wgUser->getRights())); |
| 252 | + $allowed |= ($ok && $userHasRight); |
| 253 | + } |
| 254 | + return $allowed; |
| 255 | +} |
| 256 | + |
| 257 | + |
| 258 | +function userNotPrivilegedMessage() |
| 259 | +{ |
| 260 | + global $wgOut, $wgUser, $wgLang; |
| 261 | + |
| 262 | + $wgOut->setPageTitle( wfMsg( "whitelistacctitle" ) ); |
| 263 | + $wgOut->setRobotpolicy( "noindex,nofollow" ); |
| 264 | + $wgOut->setArticleFlag( false ); |
| 265 | + |
| 266 | + $wgOut->addWikiText( wfMsg( "whitelistacctext" ) ); |
| 267 | + $wgOut->returnToMain( false ); |
| 268 | +} |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
167 | 273 | /* private */ function mainLoginForm( $err ) |
168 | 274 | { |
169 | 275 | global $wgUser, $wgOut, $wgLang, $returnto; |
— | — | @@ -178,6 +284,7 @@ |
179 | 285 | $nuo = wfMsg( "newusersonly" ); |
180 | 286 | $li = wfMsg( "login" ); |
181 | 287 | $ca = wfMsg( "createaccount" ); |
| 288 | + $cam = wfMsg( "createaccountmail" ); |
182 | 289 | $ye = wfMsg( "youremail" ); |
183 | 290 | $efl = wfMsg( "emailforlost" ); |
184 | 291 | $mmp = wfMsg( "mailmypassword" ); |
— | — | @@ -216,6 +323,10 @@ |
217 | 324 | $wpRetype = wfEscapeHTML( $wpRetype ); |
218 | 325 | $wpEmail = wfEscapeHTML( $wpEmail ); |
219 | 326 | |
| 327 | + if ($wgUser->getID() != 0) { |
| 328 | + $cambutton = "<input tabindex=6 type=submit name=\"wpCreateaccountMail\" value=\"{$cam}\">"; |
| 329 | + } |
| 330 | + |
220 | 331 | $wgOut->addHTML( " |
221 | 332 | <form id=\"userlogin\" method=\"post\" action=\"{$action}\"> |
222 | 333 | <table border=0><tr> |
— | — | @@ -229,8 +340,11 @@ |
230 | 341 | </td> |
231 | 342 | <td align=left> |
232 | 343 | <input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\"> |
233 | | -</td></tr> |
234 | | -<tr><td colspan=3> </td></tr><tr> |
| 344 | +</td></tr>"); |
| 345 | + |
| 346 | + if (userAllowedToCreateAccount($wgUser)) { |
| 347 | + |
| 348 | +$wgOut->addHTML("<tr><td colspan=3> </td></tr><tr> |
235 | 349 | <td align=right>$ypa:</td> |
236 | 350 | <td align=left> |
237 | 351 | <input tabindex=4 type=password name=\"wpRetype\" value=\"{$wpRetype}\" |
— | — | @@ -242,7 +356,11 @@ |
243 | 357 | <input tabindex=5 type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20> |
244 | 358 | </td><td align=left> |
245 | 359 | <input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\"> |
246 | | -</td></tr> |
| 360 | +$cambutton |
| 361 | +</td></tr>"); |
| 362 | + } |
| 363 | + |
| 364 | + $wgOut->addHTML(" |
247 | 365 | <tr> |
248 | 366 | <td colspan=3 align=left> |
249 | 367 | <input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\"$checked>$rmp |
— | — | @@ -253,6 +371,9 @@ |
254 | 372 | <input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\"> |
255 | 373 | </td></tr></table> |
256 | 374 | </form>\n" ); |
| 375 | + |
| 376 | + |
| 377 | + |
257 | 378 | } |
258 | 379 | |
259 | 380 | ?> |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -467,6 +467,7 @@ |
468 | 468 | "userlogout" => "Log out", |
469 | 469 | "notloggedin" => "Not logged in", |
470 | 470 | "createaccount" => "Create new account", |
| 471 | +"createaccountmail" => "by eMail", |
471 | 472 | "badretype" => "The passwords you entered do not match.", |
472 | 473 | "userexists" => "The user name you entered is already in use. Please choose a different name.", |
473 | 474 | "youremail" => "Your e-mail*", |
— | — | @@ -506,8 +507,14 @@ |
507 | 508 | "blockedtext" => "Your user name or IP address has been blocked by $1. |
508 | 509 | The reason given is this:<br>''$2''<p>You may contact $1 or one of the other |
509 | 510 | [[Wikipedia:administrators|administrators]] to discuss the block.", |
510 | | -"whitelistedittitle" => "User not logged in", |
511 | | -"whitelistedittext" => "You have to [[Spezial:Userlogin|login]] to edit articles.", |
| 511 | +"whitelistedittitle" => "Login required to edit", |
| 512 | +"whitelistedittext" => "You have to [[Special:Userlogin|login]] to edit articles.", |
| 513 | +"whitelistreadtitle" => "Login required to read", |
| 514 | +"whitelistreadtext" => "You have to [[Special:Userlogin|login]] to read articles.", |
| 515 | +"whitelistacctitle" => "You are not allowed to create an account", |
| 516 | +"whitelistacctext" => "To be allowed to create accounts in this Wiki you have to [[Special:Userlogin|log]] in and have the appropriate permissions.", |
| 517 | +"accmailtitle" => "Password sent.", |
| 518 | +"accmailtext" => "The Password for '$1' has been sent to $2.", |
512 | 519 | "newarticle" => "(New)", |
513 | 520 | "newarticletext" => |
514 | 521 | "You've followed a link to a page that doesn't exist yet. |