accidentially removed the test for
[lhc/web/wiklou.git] / includes / SpecialLockdb.php
1 <?php
2
3 function wfSpecialLockdb()
4 {
5 global $wgUser, $wgOut, $wgRequest;
6
7 if ( ! $wgUser->isDeveloper() ) {
8 $wgOut->developerRequired();
9 return;
10 }
11 $action = $wgRequest->getText( 'action' );
12 $f = new DBLockForm();
13
14 if ( "success" == $action ) { $f->showSuccess(); }
15 else if ( "submit" == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
16 else { $f->showForm( "" ); }
17 }
18
19 class DBLockForm {
20 var $reason = "";
21
22 function DBLockForm() {
23 global $wgRequest;
24 $this->reason = $wgRequest->getText( 'wpLockReason' );
25 }
26
27 function showForm( $err )
28 {
29 global $wgOut, $wgUser, $wgLang;
30
31 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
32 $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
33
34 if ( "" != $err ) {
35 $wgOut->setSubtitle( wfMsg( "formerror" ) );
36 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
37 }
38 $lc = wfMsg( "lockconfirm" );
39 $lb = wfMsg( "lockbtn" );
40 $elr = wfMsg( "enterlockreason" );
41 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
42 $action = $titleObj->escapeLocalURL( "action=submit" );
43
44 $wgOut->addHTML( "<p>
45 <form id=\"lockdb\" method=\"post\" action=\"{$action}\">
46 {$elr}:
47 <textarea name=\"wpLockReason\" rows=10 cols=60 wrap=virtual>
48 </textarea>
49 <table border=0><tr>
50 <td align=right>
51 <input type=checkbox name=\"wpLockConfirm\">
52 </td>
53 <td align=left>{$lc}<td>
54 </tr><tr>
55 <td>&nbsp;</td><td align=left>
56 <input type=submit name=\"wpLock\" value=\"{$lb}\">
57 </td></tr></table>
58 </form>\n" );
59
60 }
61
62 function doSubmit()
63 {
64 global $wgOut, $wgUser, $wgLang, $wgRequest;
65 global $wgReadOnlyFile;
66
67 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) {
68 $this->showForm( wfMsg( "locknoconfirm" ) );
69 return;
70 }
71 $fp = fopen( $wgReadOnlyFile, "w" );
72
73 if ( false === $fp ) {
74 $wgOut->fileNotFoundError( $wgReadOnlyFile );
75 return;
76 }
77 fwrite( $fp, $this->reason );
78 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
79 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
80 fclose( $fp );
81
82 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
83 $wgOut->redirect( $titleObj->getFullURL( "action=success" ) );
84 }
85
86 function showSuccess()
87 {
88 global $wgOut, $wgUser;
89
90 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
91 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
92 $wgOut->addWikiText( wfMsg( "lockdbsuccesstext" ) );
93 }
94 }
95
96 ?>