Index: trunk/extensions/SignDocument/SignDocument.php |
— | — | @@ -3,19 +3,15 @@ |
4 | 4 | /** |
5 | 5 | * Sets up the extension. |
6 | 6 | */ |
7 | | - |
| 7 | + |
8 | 8 | if (!defined('MEDIAWIKI')) { |
9 | | - echo <<<EOT |
| 9 | + echo <<<EOT |
10 | 10 | To install my extension, put the following line in LocalSettings.php: |
11 | 11 | require_once( "\$IP/extensions/SignDocument/SignDocument.php.php" ); |
12 | 12 | EOT; |
13 | | - exit( 1 ); |
| 13 | + exit( 1 ); |
14 | 14 | } |
15 | 15 | |
16 | | -if ( !function_exists( 'extAddSpecialPage' ) ) { |
17 | | - require( dirname(__FILE__) . '/../ExtensionFunctions.php' ); |
18 | | -} |
19 | | - |
20 | 16 | /** |
21 | 17 | * Adds two special pages, Special:SignDocument and Special:CreateSignDocument, which |
22 | 18 | * enable the creation of signable documents. See the README for more information. |
— | — | @@ -26,28 +22,29 @@ |
27 | 23 | * @copyright Copyright © 2007, Daniel Cannon |
28 | 24 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
29 | 25 | */ |
30 | | - |
31 | 26 | |
32 | | -#$wgExtensionFunctions[] = 'wfSpecialSignDocument'; |
33 | | -#$wgExtensionFunctions[] = 'wfSpecialCreateSignDocument'; |
34 | 27 | $wgExtensionFunctions[] = 'wfCreateSignatureLog'; |
35 | 28 | |
36 | 29 | $wgExtensionCredits['specialpage'][] = array( |
37 | | - 'name' => 'SignDocument', |
38 | | - 'author' => 'Daniel Cannon', |
39 | | - 'description' => 'Enables document signing', |
| 30 | + 'name' => 'SignDocument', |
| 31 | + 'author' => 'Daniel Cannon', |
| 32 | + 'description' => 'Enables document signing', |
40 | 33 | 'descriptionmsg' => 'signature-desc', |
41 | | - 'svn-date' => '$LastChangedDate$', |
42 | | - 'svn-revision' => '$LastChangedRevision$', |
43 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SignDocument', |
| 34 | + 'svn-date' => '$LastChangedDate$', |
| 35 | + 'svn-revision' => '$LastChangedRevision$', |
| 36 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SignDocument', |
44 | 37 | ); |
45 | 38 | |
46 | 39 | $dir = dirname(__FILE__) . '/'; |
47 | 40 | $wgExtensionMessagesFiles['SignDocument'] = $dir . 'SignDocument.i18n.php'; |
48 | 41 | $wgExtensionMessagesFiles['SpecialSignDocument'] = $dir . 'SpecialSignDocument.i18n.php'; |
49 | 42 | $wgExtensionMessagesFiles['CreateSignDocument'] = $dir . 'SpecialCreateSignDocument.i18n.php'; |
50 | | -extAddSpecialPage( $dir . 'SpecialSignDocument.php', 'SignDocument', 'SignDocument' ); |
51 | | -extAddSpecialPage( $dir. 'SpecialCreateSignDocument.php', 'CreateSignDocument', 'CreateSignDocument' ); |
| 43 | +$wgExtensionAliasesFiles['SignDocument'] = $dir . 'SignDocument.alias.php'; |
| 44 | +$wgAutoloadClasses['SpecialSignDocument'] = $dir . 'SpecialSignDocument.php'; |
| 45 | +$wgAutoloadClasses['SpecialCreateSignDocument'] = $dir . 'SpecialCreateSignDocument.php'; |
| 46 | +$wgSpecialPages['SignDocument'] = 'SpecialSignDocument'; |
| 47 | +$wgSpecialPages['CreateSignDocument'] = 'SpecialCreateSignDocument'; |
| 48 | + |
52 | 49 | /* Set up sigadmin permissions. */ |
53 | 50 | $wgAvailableRights[] = 'sigadmin'; |
54 | 51 | $wgAvailableRights[] = 'createsigndocument'; |
— | — | @@ -61,7 +58,7 @@ |
62 | 59 | */ |
63 | 60 | function wfCreateSignatureLog() { |
64 | 61 | wfLoadExtensionMessages('SignDocument'); |
65 | | - |
| 62 | + |
66 | 63 | # Add a new log type |
67 | 64 | global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
68 | 65 | |
— | — | @@ -79,7 +76,6 @@ |
80 | 77 | function wfLogSignDocumentSignature( $sig ) { |
81 | 78 | global $wgUser; |
82 | 79 | $log = new LogPage( 'signature' ); |
83 | | - $log->addEntry( 'sign', Title::newFromId( $sig->mForm->getPageId() ), |
| 80 | + $log->addEntry( 'sign', Title::newFromId( $sig->mForm->getPageId() ), |
84 | 81 | 'id=' . $sig->mId ); |
85 | | - |
86 | 82 | } |
Index: trunk/extensions/SignDocument/SpecialSignDocument.php |
— | — | @@ -1,37 +1,38 @@ |
2 | | -<?PHP |
| 2 | +<?PHP |
3 | 3 | if (!defined('MEDIAWIKI')) die(); |
4 | 4 | require_once( 'SignDocumentHelpers.php' ); |
5 | 5 | |
6 | 6 | // TODO: Doc |
7 | | -class SignDocument extends SpecialPage { |
| 7 | +class SpecialSignDocument extends SpecialPage { |
8 | 8 | /** |
9 | 9 | * The Document the user wants to sign. |
10 | 10 | * @type int |
11 | 11 | */ |
12 | 12 | private $mDocumentId; |
13 | | - |
| 13 | + |
14 | 14 | private $mArticle; |
15 | 15 | private $mTitle; |
16 | | - |
| 16 | + |
17 | 17 | private $mCurrentSig; |
18 | 18 | private $mForm; |
19 | | - |
| 19 | + |
20 | 20 | /** |
21 | | - * Constructor |
22 | | - */ |
23 | | - function SignDocument() { |
| 21 | + * Constructor |
| 22 | + */ |
| 23 | + function __construct() { |
24 | 24 | SpecialPage::SpecialPage( 'SignDocument', 'sigadmin' ); |
25 | | - wfLoadExtensionMessages('SpecialSignDocument'); |
26 | 25 | $this->includable( true ); |
27 | 26 | } |
28 | 27 | |
29 | 28 | function execute($par = null) { |
30 | 29 | global $wgOut, $wgRequest, $wgUser; |
31 | 30 | |
| 31 | + wfLoadExtensionMessages('SpecialSignDocument'); |
| 32 | + |
32 | 33 | $this->setHeaders(); |
33 | 34 | if ( $wgUser->isAllowed( 'sigadmin' ) ) { |
34 | 35 | $this->mDocumentId = (int) $wgRequest->getVal( 'doc', null ); |
35 | | - |
| 36 | + |
36 | 37 | if ( $this->mDocumentId && !is_null($wgRequest->getVal( 'viewsigs' )) ) { |
37 | 38 | $tmp = new SignatureViewer(); |
38 | 39 | $tmp->execute(); |
— | — | @@ -57,7 +58,7 @@ |
58 | 59 | global $wgOut, $wgTitle; |
59 | 60 | |
60 | 61 | $wgOut->addWikiText( wfMsg( 'sign-nodocselected' ) ); |
61 | | - |
| 62 | + |
62 | 63 | $out = ''; |
63 | 64 | $out .= wfOpenElement( 'form', array( |
64 | 65 | 'id' => 'mw-SignDocument-SelectDoc-form', |
— | — | @@ -67,14 +68,14 @@ |
68 | 69 | $out .= '<p><strong>' . wfMsg( 'sign-selectdoc' ) . '</strong> '; |
69 | 70 | |
70 | 71 | $out .= $this->buildDocSelector(); |
71 | | - |
| 72 | + |
72 | 73 | $out .= wfElement( 'input', array( |
73 | 74 | 'id' => 'mw-SelectDoc-submit', |
74 | 75 | 'type' => 'submit', |
75 | 76 | 'value' => wfMsg( 'go' ) ) ); |
76 | | - |
| 77 | + |
77 | 78 | $out .= '</p></form>'; |
78 | | - |
| 79 | + |
79 | 80 | $wgOut->addHTML( $out ); |
80 | 81 | } |
81 | 82 | |
— | — | @@ -84,19 +85,19 @@ |
85 | 86 | $attribs = array( |
86 | 87 | 'id' => $id, |
87 | 88 | 'name' => 'doc', |
88 | | - 'size' => '1', |
| 89 | + 'size' => '1', |
89 | 90 | ); |
90 | 91 | |
91 | 92 | $out = wfOpenElement( 'select', $attribs ); |
92 | 93 | |
93 | 94 | $itms = SignDocumentForm::getNamesFromDB(); |
94 | 95 | $firstItem = null; |
95 | | - |
| 96 | + |
96 | 97 | foreach(array_keys($itms) as $itm) { |
97 | 98 | if (!$firstItem) $firstItem = $itm; |
98 | 99 | $out .= $this->buildOption( $itm, $itms[$itm], $firstItem ); |
99 | 100 | } |
100 | | - |
| 101 | + |
101 | 102 | $out .= "</select>\n"; |
102 | 103 | return $out; |
103 | 104 | } |
— | — | @@ -105,22 +106,22 @@ |
106 | 107 | $selectedAttrib = ($selected == $text) |
107 | 108 | ? array( 'selected' => 'selected' ) |
108 | 109 | : array(); |
109 | | - |
| 110 | + |
110 | 111 | return wfElement( 'option', |
111 | 112 | array( 'value' => $value ) + $selectedAttrib, |
112 | 113 | $text ); |
113 | 114 | } |
114 | | - |
| 115 | + |
115 | 116 | function showSignForm() { |
116 | 117 | global $wgOut, $wgUser, $wgRequest, $wgTitle; |
117 | | - |
| 118 | + |
118 | 119 | $this->mForm = SignDocumentForm::newFromDB( $wgRequest->getVal('doc') ); |
119 | | - |
| 120 | + |
120 | 121 | if ( !$this->mForm ) { |
121 | 122 | $wgOut->addWikiText( wfMsg( 'sign-error-nosuchdoc', $wgRequest->getVal('doc') ) ); |
122 | 123 | return; |
123 | 124 | } |
124 | | - |
| 125 | + |
125 | 126 | if ( !in_array( $this->mForm->mAllowedGroup, $wgUser->getEffectiveGroups() ) ) { |
126 | 127 | $wgOut->permissionRequired( $this->mForm->mAllowedGroup ); |
127 | 128 | return; |
— | — | @@ -130,17 +131,17 @@ |
131 | 132 | |
132 | 133 | $wgOut->addHTML( '<div style="position:absolute; top:5px; right:10px;">' . |
133 | 134 | '[<b>'. $skin->makeKnownLinkObj( SpecialPage::getTitleFor('SignDocument'), |
134 | | - wfMsg( 'sign-viewsignatures' ), 'doc=' . $wgRequest->getVal('doc') |
| 135 | + wfMsg( 'sign-viewsignatures' ), 'doc=' . $wgRequest->getVal('doc') |
135 | 136 | . '&viewsigs×tamp&realname') |
136 | 137 | . '</b>]</div>' ); |
137 | | - |
| 138 | + |
138 | 139 | if ( !$this->mForm->mOpen ) { |
139 | 140 | $wgOut->addWikiText( wfMsg( 'sign-error-closed' ) ); |
140 | 141 | $wgOut->addHTML( '<h1>' . $this->mForm->mPagename . '</h1>' ); |
141 | 142 | $wgOut->addWikiText( $this->mForm->mArticle->getContent() ); |
142 | 143 | return; |
143 | 144 | } |
144 | | - |
| 145 | + |
145 | 146 | $wgOut->addWikiText( wfMsg( 'sign-docheader', $this->mForm->mPagename ) ); |
146 | 147 | |
147 | 148 | $wgOut->addHTML( '<h1>' . $this->mForm->mPagename . '</h1>' ); |
— | — | @@ -151,7 +152,7 @@ |
152 | 153 | $wgOut->addWikiText( wfMsg( 'sign-information', $this->mForm->mIntrotext ) ); |
153 | 154 | |
154 | 155 | $wgOut->addHTML( '<br />' ); |
155 | | - |
| 156 | + |
156 | 157 | $this->addSignForm(); |
157 | 158 | } |
158 | 159 | |
— | — | @@ -162,7 +163,7 @@ |
163 | 164 | |
164 | 165 | /* We need the values the user submitted, even if they're not listed. */ |
165 | 166 | $this->mCurrentSig->setAllAccessible( true ); |
166 | | - |
| 167 | + |
167 | 168 | $out = ''; |
168 | 169 | |
169 | 170 | $out .= wfOpenElement( 'form', array( |
— | — | @@ -171,47 +172,47 @@ |
172 | 173 | 'method' => 'post') ); |
173 | 174 | |
174 | 175 | $out .= '<table>'; |
175 | | - $out .= $this->makeInput( false, false, 'realname', wfMsg('sign-realname'), |
| 176 | + $out .= $this->makeInput( false, false, 'realname', wfMsg('sign-realname'), |
176 | 177 | $this->mCurrentSig->getRealname(), 'anonymous' ); |
177 | | - |
178 | | - $out .= $this->makeInput( $this->mForm->mAddressHidden, |
| 178 | + |
| 179 | + $out .= $this->makeInput( $this->mForm->mAddressHidden, |
179 | 180 | $this->mForm->mAddressOptional, |
180 | | - 'address', wfMsg('sign-address'), |
| 181 | + 'address', wfMsg('sign-address'), |
181 | 182 | $this->mCurrentSig->getAddress(), 'hideaddress' ); |
182 | | - $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
| 183 | + $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
183 | 184 | $this->mForm->mExtAddressOptional, |
184 | | - 'city', wfMsg('sign-city'), |
| 185 | + 'city', wfMsg('sign-city'), |
185 | 186 | $this->mCurrentSig->getCity(), 'hideextaddress' ); |
186 | | - $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
| 187 | + $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
187 | 188 | $this->mForm->mExtAddressOptional, |
188 | | - 'state', wfMsg('sign-state'), |
| 189 | + 'state', wfMsg('sign-state'), |
189 | 190 | $this->mCurrentSig->getState(), false ); |
190 | | - $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
| 191 | + $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
191 | 192 | $this->mForm->mExtAddressOptional, |
192 | | - 'zip', wfMsg('sign-zip'), |
| 193 | + 'zip', wfMsg('sign-zip'), |
193 | 194 | $this->mCurrentSig->getZip(), false ); |
194 | | - $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
| 195 | + $out .= $this->makeInput( $this->mForm->mExtAddressHidden, |
195 | 196 | $this->mForm->mExtAddressOptional, |
196 | | - 'country', wfMsg('sign-country'), |
| 197 | + 'country', wfMsg('sign-country'), |
197 | 198 | $this->mCurrentSig->getCountry(), false ); |
198 | | - $out .= $this->makeInput( $this->mForm->mPhoneHidden, |
| 199 | + $out .= $this->makeInput( $this->mForm->mPhoneHidden, |
199 | 200 | $this->mForm->mPhoneOptional, |
200 | | - 'phone', wfMsg('sign-phone'), |
| 201 | + 'phone', wfMsg('sign-phone'), |
201 | 202 | $this->mCurrentSig->getPhone(), 'hidephone' ); |
202 | | - $out .= $this->makeInput( $this->mForm->mBdayHidden, |
| 203 | + $out .= $this->makeInput( $this->mForm->mBdayHidden, |
203 | 204 | $this->mForm->mBdayOptional, |
204 | | - 'bday', wfMsg('sign-bday'), |
| 205 | + 'bday', wfMsg('sign-bday'), |
205 | 206 | $this->mCurrentSig->getBday(), 'hidebday' ); |
206 | | - $out .= $this->makeInput( $this->mForm->mEmailHidden, |
| 207 | + $out .= $this->makeInput( $this->mForm->mEmailHidden, |
207 | 208 | $this->mForm->mEmailOptional, |
208 | | - 'email', wfMsg('sign-email'), |
| 209 | + 'email', wfMsg('sign-email'), |
209 | 210 | $this->mCurrentSig->getEmail(), 'hideemail' ); |
210 | 211 | |
211 | 212 | $out .= '<tr><td></td><td>' . wfMsg( 'sign-indicates-req' ) . '</td></tr>'; |
212 | 213 | $out .= '<tr><td></td><td>' . wfMsg( 'sign-hide-note' ) . '</td></tr>'; |
213 | 214 | |
214 | 215 | $out .= wfElement( 'input', array( |
215 | | - |
| 216 | + |
216 | 217 | 'type' => 'hidden', |
217 | 218 | 'name' => 'doc', |
218 | 219 | 'value' => $wgRequest->getVal('doc') ) ); |
— | — | @@ -222,7 +223,7 @@ |
223 | 224 | 'value' => wfMsg( 'sign-submit') ) ); |
224 | 225 | |
225 | 226 | $out .= '</td></tr>'; |
226 | | - |
| 227 | + |
227 | 228 | $out .= '</table></form>'; |
228 | 229 | |
229 | 230 | $wgOut->addHTML( $out ); |
— | — | @@ -247,9 +248,9 @@ |
248 | 249 | $markPrivate, |
249 | 250 | false); |
250 | 251 | } |
251 | | - |
| 252 | + |
252 | 253 | $out .= '</td></tr>'; |
253 | | - |
| 254 | + |
254 | 255 | return $out; |
255 | 256 | } |
256 | 257 | |
— | — | @@ -264,9 +265,9 @@ |
265 | 266 | |
266 | 267 | function doSigning() { |
267 | 268 | global $wgRequest, $wgOut, $wgUser; |
268 | | - |
| 269 | + |
269 | 270 | $this->mCurrentSig = SignDocumentSignature::newFromPost(); |
270 | | - |
| 271 | + |
271 | 272 | if ( !$this->mCurrentSig->mForm->mOpen ) { |
272 | 273 | $wgOut->addWikiText( wfMsg( 'sign-error-closed' ) ); |
273 | 274 | return; |
— | — | @@ -274,7 +275,7 @@ |
275 | 276 | |
276 | 277 | $wgOut->addHTML( '<div style="position:absolute; top:5px; right:10px;">' . |
277 | 278 | '[<b>'. $wgUser->getSkin()->makeKnownLinkObj( SpecialPage::getTitleFor('SignDocument'), |
278 | | - wfMsg( 'sign-viewsignatures' ), 'doc=' . $wgRequest->getVal('doc') |
| 279 | + wfMsg( 'sign-viewsignatures' ), 'doc=' . $wgRequest->getVal('doc') |
279 | 280 | . '&viewsigs×tamp&realname') |
280 | 281 | . '</b>]</div>' ); |
281 | 282 | |
— | — | @@ -289,9 +290,9 @@ |
290 | 291 | } |
291 | 292 | |
292 | 293 | $this->mCurrentSig->addToDB(); |
293 | | - |
| 294 | + |
294 | 295 | wfLogSignDocumentSignature($this->mCurrentSig); |
295 | | - |
| 296 | + |
296 | 297 | $wgOut->addWikiText( wfMsg( 'sig-success' ) ); |
297 | 298 | } |
298 | 299 | } |
— | — | @@ -301,19 +302,19 @@ |
302 | 303 | */ |
303 | 304 | class SignatureViewer { |
304 | 305 | private $mForm, $mSigs; |
305 | | - |
| 306 | + |
306 | 307 | private $mFields; |
307 | | - |
| 308 | + |
308 | 309 | function execute() { |
309 | 310 | global $wgRequest, $wgTitle, $wgUser; |
310 | 311 | |
311 | 312 | if ($wgRequest->getVal('detail')) { |
312 | 313 | $this->doDetail(); |
313 | 314 | return; |
314 | | - } else |
315 | | - |
| 315 | + } else |
| 316 | + |
316 | 317 | $this->setUp(); |
317 | | - |
| 318 | + |
318 | 319 | if ($wgRequest->wasPosted() && $wgUser->isAllowed('sigadmin')) { |
319 | 320 | if (!is_null($wgRequest->getVal('opensigning') ) ) |
320 | 321 | $this->openSigning(); |
— | — | @@ -322,20 +323,20 @@ |
323 | 324 | } |
324 | 325 | |
325 | 326 | global $wgOut; |
326 | | - |
| 327 | + |
327 | 328 | //TODO: Add counts, etc. |
328 | 329 | $wgOut->addWikiText( wfMsg( 'sign-viewsigs-intro', $this->mForm->mPagename, $this->mForm->getId() ) ); |
329 | 330 | |
330 | 331 | $wgOut->addHTML( $this->getCloseOpenOptions() ); |
331 | | - |
| 332 | + |
332 | 333 | $wgOut->addHTML( '<br />' . $this->getFieldSelector() ); |
333 | | - |
| 334 | + |
334 | 335 | $wgOut->addHTML( '<fieldset><legend>' . wfMsg('sign-signatures') . '</legend>' ); |
335 | 336 | $wgOut->addHTML( $this->getTableHead() ); |
336 | 337 | |
337 | 338 | foreach ($this->mSigs as $sig) |
338 | 339 | $wgOut->addHTML( $this->getSigRow($sig, $sig->mStricken ) ); |
339 | | - |
| 340 | + |
340 | 341 | $wgOut->addHTML( '</table>' ); |
341 | 342 | $wgOut->addHTML( '</fieldset>' ); |
342 | 343 | |
— | — | @@ -367,14 +368,14 @@ |
368 | 369 | 'agent' => !is_null($wgRequest->getVal('agent')) |
369 | 370 | ); |
370 | 371 | } |
371 | | - |
| 372 | + |
372 | 373 | private function getCloseOpenOptions() { |
373 | 374 | global $wgUser, $wgTitle; |
374 | 375 | if (!$wgUser->isAllowed('sigadmin')) return ''; |
375 | 376 | |
376 | 377 | $url = $wgTitle->escapeLocalUrl() . '?doc=' . $this->mForm->getId() |
377 | 378 | . '&viewsigs'; |
378 | | - |
| 379 | + |
379 | 380 | $out = wfOpenElement( 'form', array( |
380 | 381 | 'id' => 'wm-sign-viewsigs-closeopen-form', |
381 | 382 | 'action' => $url, |
— | — | @@ -386,7 +387,7 @@ |
387 | 388 | 'type' => 'submit', |
388 | 389 | 'name' => 'closesigning-submit', |
389 | 390 | 'value' => wfMsg( 'sign-sigadmin-close' ) ) ); |
390 | | - $out .= wfElement( 'input', array( |
| 391 | + $out .= wfElement( 'input', array( |
391 | 392 | 'type' => 'hidden', |
392 | 393 | 'name' => 'closesigning') ); |
393 | 394 | } else { |
— | — | @@ -395,7 +396,7 @@ |
396 | 397 | 'type' => 'submit', |
397 | 398 | 'name' => 'opensigning-submit', |
398 | 399 | 'value' => wfMsg( 'sign-sigadmin-open' ) ) ); |
399 | | - $out .= wfElement( 'input', array( |
| 400 | + $out .= wfElement( 'input', array( |
400 | 401 | 'type' => 'hidden', |
401 | 402 | 'name' => 'opensigning') ); |
402 | 403 | } |
— | — | @@ -415,7 +416,7 @@ |
416 | 417 | $out .= wfMsg( 'sign-view-selectfields' ); |
417 | 418 | |
418 | 419 | $out .= wfElement( 'input', array( |
419 | | - 'type' => 'hidden', 'name' => 'doc', |
| 420 | + 'type' => 'hidden', 'name' => 'doc', |
420 | 421 | 'value' => $this->mForm->getId())); |
421 | 422 | |
422 | 423 | $out .= wfElement( 'input', array( |
— | — | @@ -423,10 +424,10 @@ |
424 | 425 | |
425 | 426 | foreach (array_keys($this->mFields) as $field) |
426 | 427 | $out .= $this->fieldCheck($field); |
427 | | - |
428 | | - $out .= ' ' . wfElement( 'input', array( |
| 428 | + |
| 429 | + $out .= ' ' . wfElement( 'input', array( |
429 | 430 | 'type' => 'submit', 'value' => wfMsg('go') ) ); |
430 | | - |
| 431 | + |
431 | 432 | $out .= '</form>'; |
432 | 433 | return $out; |
433 | 434 | } |
— | — | @@ -447,14 +448,14 @@ |
448 | 449 | $out = '<table cellpadding="2" class="sortable" '; |
449 | 450 | $out .= 'style="cell-border: 0.25px solid gray; text-align: left;'; |
450 | 451 | $out .= 'border-spacing: 1px; margin-left: 1em;"><tr>'; |
451 | | - |
| 452 | + |
452 | 453 | if ( $wgUser->isAllowed('sigadmin') ) |
453 | 454 | $out .= '<th>' . wfMsg( 'sign-viewfield-options' ) . '</th>'; |
454 | | - |
| 455 | + |
455 | 456 | foreach ($this->mFields as $field => $val) { |
456 | 457 | if ($val) $out .= '<th>' . wfMsg( "sign-viewfield-$field" ) . '</th>'; |
457 | 458 | } |
458 | | - |
| 459 | + |
459 | 460 | return '</tr>' . $out; |
460 | 461 | } |
461 | 462 | |
— | — | @@ -464,7 +465,7 @@ |
465 | 466 | if ( $sig->isPrivileged() ) |
466 | 467 | $out .= '<td>[' . $wgUser->getSkin()->makeKnownLinkObj( |
467 | 468 | SpecialPage::getTitleFor('SignDocument'), |
468 | | - wfMsg('sign-viewfield-options'), 'doc=' . |
| 469 | + wfMsg('sign-viewfield-options'), 'doc=' . |
469 | 470 | $this->mForm->getId() . '&viewsigs&detail=' . $sig->mId ) . ']</td>'; |
470 | 471 | |
471 | 472 | #$out .= $this->getSigCell( 'entryid', $sig->mId, $del ); |
— | — | @@ -501,10 +502,10 @@ |
502 | 503 | $this->mForm->setOpen(true); |
503 | 504 | $wgOut->addWikiText( wfMsg( 'sign-sigadmin-opensuccess', $this->mForm->mPagename ) ); |
504 | 505 | } |
505 | | - |
| 506 | + |
506 | 507 | private function doDetail() { |
507 | 508 | global $wgUser, $wgOut, $wgRequest; |
508 | | - |
| 509 | + |
509 | 510 | if ( !$wgUser->isAllowed('sigadmin') ) { |
510 | 511 | $wgOut->permissionRequired( 'sigadmin' ); |
511 | 512 | return; |
— | — | @@ -518,7 +519,7 @@ |
519 | 520 | } |
520 | 521 | |
521 | 522 | $wgOut->addHTML( $this->getDetailReviewForm( $sig ) ); |
522 | | - |
| 523 | + |
523 | 524 | $wgOut->addHTML( $this->getDetailTable( $sig ) ); |
524 | 525 | |
525 | 526 | $wgOut->addHTML( $this->runDetailUniqueQuery( $sig ) ); |
— | — | @@ -531,15 +532,15 @@ |
532 | 533 | } |
533 | 534 | |
534 | 535 | $out = ''; |
535 | | - |
| 536 | + |
536 | 537 | $url = $wgTitle->escapeLocalUrl() . '?doc=' . $wgRequest->getVal('doc') |
537 | 538 | . '&viewsigs&detail=' . $wgRequest->getVal('detail'); |
538 | 539 | |
539 | | - $out .= wfOpenElement( 'form', array( |
| 540 | + $out .= wfOpenElement( 'form', array( |
540 | 541 | 'id' => 'doreview-form', |
541 | 542 | 'action' => $url, |
542 | 543 | 'method' => 'post' ) ); |
543 | | - |
| 544 | + |
544 | 545 | $out .= '<fieldset><legend>' . wfMsg( 'sign-reviewsig' ) . '</legend>'; |
545 | 546 | |
546 | 547 | $out .= Xml::checkLabel( |
— | — | @@ -562,17 +563,17 @@ |
563 | 564 | |
564 | 565 | $out .= '</fieldset></form>'; |
565 | 566 | return $out; |
566 | | - |
567 | 567 | |
| 568 | + |
568 | 569 | } |
569 | 570 | |
570 | 571 | private function updateReviewFromPost( $sig ) { |
571 | 572 | global $wgRequest; |
572 | | - if (!$wgRequest->wasPosted() || is_null($wgRequest->getVal('doreview')) |
573 | | - || is_null($wgRequest->getVal('reviewcomment' ) ) ) |
| 573 | + if (!$wgRequest->wasPosted() || is_null($wgRequest->getVal('doreview')) |
| 574 | + || is_null($wgRequest->getVal('reviewcomment' ) ) ) |
574 | 575 | return; //What are you doing here then? |
575 | 576 | |
576 | | - $sig->postReview( $wgRequest->getVal( 'reviewcomment' ), |
| 577 | + $sig->postReview( $wgRequest->getVal( 'reviewcomment' ), |
577 | 578 | $wgRequest->getVal('strikesig')); |
578 | 579 | } |
579 | 580 | |
— | — | @@ -582,9 +583,9 @@ |
583 | 584 | |
584 | 585 | $out .= '<table style="width: 100%"><tr><td><table>'; |
585 | 586 | |
586 | | - $out .= $this->getDetailTableRow( 'realname', $sig->getRealName(), |
| 587 | + $out .= $this->getDetailTableRow( 'realname', $sig->getRealName(), |
587 | 588 | $sig->isHidden('realname') ); |
588 | | - $out .= $this->getDetailTableRow( 'address', $sig->getAddress(), |
| 589 | + $out .= $this->getDetailTableRow( 'address', $sig->getAddress(), |
589 | 590 | $sig->isHidden('address') ); |
590 | 591 | $out .= $this->getDetailTableRow( 'city', $sig->getCity(), |
591 | 592 | $sig->isHidden('extaddress') ); |
— | — | @@ -596,29 +597,29 @@ |
597 | 598 | $sig->isHidden('extaddress') ); |
598 | 599 | $out .= $this->getDetailTableRow( 'phone', $sig->getPhone(), |
599 | 600 | $sig->isHidden('phone') ); |
600 | | - $out .= $this->getDetailTableRow( 'email', |
601 | | - wfMsg( 'sign-emailto', $sig->getEmail() ), |
| 601 | + $out .= $this->getDetailTableRow( 'email', |
| 602 | + wfMsg( 'sign-emailto', $sig->getEmail() ), |
602 | 603 | $sig->isHidden('email') ); |
603 | 604 | |
604 | 605 | $out .= '</table></td><td valign="top"><table valign="top">'; |
605 | 606 | |
606 | 607 | $out .= $this->getDetailTableRow( 'timestamp', $sig->mTimestamp ); |
607 | | - $out .= $this->getDetailTableRow( 'ip', wfMsgExt( 'sign-iptools', array( |
| 608 | + $out .= $this->getDetailTableRow( 'ip', wfMsgExt( 'sign-iptools', array( |
608 | 609 | 'parse' ), $sig->getIp() ) ); |
609 | 610 | $out .= $this->getDetailTableRow( 'agent', $sig->getAgent() ); |
610 | | - |
| 611 | + |
611 | 612 | $out .= $this->getDetailTableRow( 'stricken', ($sig->mStricken)?wfMsg( 'yes' ):wfMsg('no') ); |
612 | 613 | $out .= $this->getDetailTableRow( 'reviewedby', $sig->getReviewedBy() ); |
613 | 614 | $out .= $this->getDetailTableRow( 'reviewcomment', $sig->mStrickenComment ); |
614 | | - |
| 615 | + |
615 | 616 | $out .= '</table></td></tr>'; |
616 | | - |
| 617 | + |
617 | 618 | $out .= '</table></fieldset>'; |
618 | 619 | return $out; |
619 | 620 | } |
620 | 621 | |
621 | 622 | private function getDetailTableRow( $fieldid, $val, $priv = false ) { |
622 | | - return '<tr><td><strong>' . wfMsg( "sign-viewfield-$fieldid" ) . ':</strong></td><td>' |
| 623 | + return '<tr><td><strong>' . wfMsg( "sign-viewfield-$fieldid" ) . ':</strong></td><td>' |
623 | 624 | . $val . (($priv)?(' (' . wfMsg( 'sig-private' ) . ')'):'') . '</td></tr>'; |
624 | 625 | } |
625 | 626 | |
— | — | @@ -627,7 +628,7 @@ |
628 | 629 | $out = ''; |
629 | 630 | |
630 | 631 | $out .= '<fieldset><legend>' . wfMsg( 'sign-detail-uniquequery' ) . '</legend>'; |
631 | | - |
| 632 | + |
632 | 633 | if ( !$wgRequest->wasPosted() || !$wgRequest->getVal( 'rununiquequery' ) ) { |
633 | 634 | $url = $wgTitle->escapeLocalUrl() . '?doc=' . $wgRequest->getVal('doc') |
634 | 635 | . '&viewsigs&detail=' . $wgRequest->getVal('detail'); |
— | — | @@ -641,7 +642,7 @@ |
642 | 643 | 'name' => 'rununiquequery', |
643 | 644 | 'value'=> wfMsg( 'sign-detail-uniquequery-run' ) ) ); |
644 | 645 | |
645 | | - return '</form></fieldset>' . $out; |
| 646 | + return '</form></fieldset>' . $out; |
646 | 647 | } |
647 | 648 | |
648 | 649 | $out .= $this->similarTable( wfMsg( 'sign-uniquequery-similarname' ), $sig->similarByName() ); |
— | — | @@ -655,15 +656,15 @@ |
656 | 657 | |
657 | 658 | private function similarTable( $header, $sigs ) { |
658 | 659 | $out = "<h5>$header</h5>"; |
659 | | - |
| 660 | + |
660 | 661 | $out .= '<ul>'; |
661 | 662 | foreach ($sigs as $sig) |
662 | 663 | $out .= '<li>' . wfMsgExt( 'sign-uniquequery-1signed2', array( 'parse'), |
663 | | - $sig->getRealName(), $sig->mForm->mPagename, |
| 664 | + $sig->getRealName(), $sig->mForm->mPagename, |
664 | 665 | $sig->mId, $sig->mForm->getId() ) . '</li>'; |
665 | | - |
| 666 | + |
666 | 667 | $out .= '</ul>'; |
667 | | - |
| 668 | + |
668 | 669 | return $out; |
669 | 670 | } |
670 | 671 | } |
Index: trunk/extensions/SignDocument/SignDocumentHelpers.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Helper classes for the SignDocument extensions. This file provides the classes |
6 | | - * SignDocumentForm, which represents a document signing form generated by a |
| 6 | + * SignDocumentForm, which represents a document signing form generated by a |
7 | 7 | * sigadmin, and SignDocumentSignature, which represents a signature committed by |
8 | 8 | * a user to a document. |
9 | 9 | * |
— | — | @@ -12,10 +12,10 @@ |
13 | 13 | * @copyright Copyright © 2007, Daniel Cannon |
14 | 14 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
15 | 15 | */ |
16 | | - |
| 16 | + |
17 | 17 | /** |
18 | 18 | * A "SignDocumentForm" is essentially the configuration of *how* a user can |
19 | | - * sign a document. This includes what options are visibile to users, what |
| 19 | + * sign a document. This includes what options are visibile to users, what |
20 | 20 | * options are optional, what users may sign a document, whether signing is |
21 | 21 | * enabled for the given document, what the minimum age of a signer must |
22 | 22 | * be, and a brief introductory text displayed to signers. |
— | — | @@ -23,26 +23,26 @@ |
24 | 24 | class SignDocumentForm { |
25 | 25 | /* public fields */ |
26 | 26 | public $mPagename, $mAllowedGroup, $mMinAge, $mIntrotext; |
27 | | - |
| 27 | + |
28 | 28 | public $mEmailHidden, $mAddressHidden, $mExtAddressHidden, |
29 | 29 | $mPhoneHidden, $mBdayHidden; |
30 | | - |
| 30 | + |
31 | 31 | public $mEmailOptional, $mAddressOptional, $mExtAddressOptional, |
32 | 32 | $mPhoneOptional, $mBdayOptional; |
33 | | - |
| 33 | + |
34 | 34 | public $mOpen; |
35 | | - |
| 35 | + |
36 | 36 | /* null until the item exists in the db. */ |
37 | 37 | private $mInDb; |
38 | 38 | private $mId; |
39 | | - |
| 39 | + |
40 | 40 | /* Compressed bitfields representing hidden and optional fields. */ |
41 | 41 | private $mHiddenFlags, $mOptionalFlags; |
42 | | - |
| 42 | + |
43 | 43 | /* Pertaining to the article this form describes. */ |
44 | 44 | private $mOldid, $mPageId; |
45 | 45 | public $mTitle, $mArticle; |
46 | | - |
| 46 | + |
47 | 47 | /* Hackerish indeed .. my little cheat to make this class immutable. */ |
48 | 48 | private static $mCanRunCtor; |
49 | 49 | |
— | — | @@ -73,38 +73,38 @@ |
74 | 74 | $f->mExtAddressHidden = $wgRequest->getVal('mwCreateSignDocHidden-extaddress'); |
75 | 75 | $f->mPhoneHidden = $wgRequest->getVal('mwCreateSignDocHidden-phone'); |
76 | 76 | $f->mBdayHidden = $wgRequest->getVal('mwCreateSignDocHidden-bday'); |
77 | | - |
| 77 | + |
78 | 78 | $f->mEmailOptional = $wgRequest->getVal('mwCreateSignDocOptional-email'); |
79 | 79 | $f->mAddressOptional = $wgRequest->getVal('mwCreateSignDocOptional-address'); |
80 | 80 | $f->mExtAddressOptional = $wgRequest->getVal('mwCreateSignDocOptional-extaddress'); |
81 | 81 | $f->mPhoneOptional = $wgRequest->getVal('mwCreateSignDocOptional-phone'); |
82 | 82 | $f->mBdayOptional = $wgRequest->getVal('mwCreateSignDocOptional-bday'); |
83 | | - |
| 83 | + |
84 | 84 | $f->basicSanityChecking(); |
85 | | - |
| 85 | + |
86 | 86 | return $f; |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Generates mTitle, mArticle and sets mOldid to the latest revision of the |
91 | | - * article specified by mPagename. |
| 91 | + * article specified by mPagename. |
92 | 92 | */ |
93 | 93 | function loadArticleData() { |
94 | 94 | $this->mTitle = Title::newFromText( $this->mPagename ); |
95 | | - |
96 | | - if (is_null($this->mTitle) || !is_object($this->mTitle)) |
| 95 | + |
| 96 | + if (is_null($this->mTitle) || !is_object($this->mTitle)) |
97 | 97 | throw new MWException('Something went horribly wrong. '. |
98 | 98 | 'mTitle is null or not an object.'); |
99 | | - |
| 99 | + |
100 | 100 | if ( !$this->mTitle->exists() ) |
101 | 101 | return false; |
102 | 102 | |
103 | | - $this->mArticle = new Article( $this->mTitle ); |
| 103 | + $this->mArticle = new Article( $this->mTitle ); |
104 | 104 | $this->mArticle->loadPageData(); |
105 | | - |
| 105 | + |
106 | 106 | $this->mOldid = $this->mArticle->mLatest; |
107 | 107 | $this->mPageId = $this->mTitle->getArticleID(); |
108 | | - |
| 108 | + |
109 | 109 | return true; |
110 | 110 | } |
111 | 111 | |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | |
127 | 127 | /* Make sure title includes namespace. */ |
128 | 128 | $this->mPagename = $this->mTitle->getPrefixedText(); |
129 | | - |
| 129 | + |
130 | 130 | /* Make sure it don't already exist ... */ |
131 | 131 | $res = $dbw->selectRow( 'sdoc_form', '*', array( |
132 | 132 | 'form_pageid' => $this->mPageId)); |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | } |
136 | 136 | |
137 | 137 | $this->compressFlags(); |
138 | | - |
| 138 | + |
139 | 139 | $dbw->insert( 'sdoc_form', |
140 | 140 | array( |
141 | 141 | 'form_pageid' => $this->mPageId, |
— | — | @@ -149,13 +149,13 @@ |
150 | 150 | |
151 | 151 | $this->mInDb = true; |
152 | 152 | |
153 | | - $id = $dbw->selectRow( 'sdoc_form', 'form_id', |
| 153 | + $id = $dbw->selectRow( 'sdoc_form', 'form_id', |
154 | 154 | '', 'Database::selectRow', array( |
155 | 155 | 'ORDER BY' => 'form_id DESC', |
156 | 156 | 'LIMIT' => '1' ) ); |
157 | | - |
| 157 | + |
158 | 158 | $this->mId = $id->form_id; |
159 | | - |
| 159 | + |
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | |
— | — | @@ -169,23 +169,23 @@ |
170 | 170 | global $wgUser; |
171 | 171 | $dbw = wfGetDB( DB_MASTER ); |
172 | 172 | |
173 | | - $dbrs = $dbw->select( 'sdoc_form', array('form_pagename', 'form_oldid', |
| 173 | + $dbrs = $dbw->select( 'sdoc_form', array('form_pagename', 'form_oldid', |
174 | 174 | 'form_id', 'form_allowgroup', 'form_open'), |
175 | 175 | array()); |
176 | 176 | |
177 | 177 | $ret = array(); |
178 | 178 | while ( $dbr = $dbw->fetchObject($dbrs)) { |
179 | | - if ( in_array( $dbr->form_allowgroup, |
| 179 | + if ( in_array( $dbr->form_allowgroup, |
180 | 180 | $wgUser->getEffectiveGroups() ) ) |
181 | 181 | $ret[$dbr->form_pagename . ' (r' . $dbr->form_oldid . ( |
182 | | - (!$dbr->form_open)?' - ' . wfMsg('sign-closed'):'') |
| 182 | + (!$dbr->form_open)?' - ' . wfMsg('sign-closed'):'') |
183 | 183 | . ')'] = $dbr->form_id; |
184 | 184 | } |
185 | 185 | |
186 | 186 | return $ret; |
187 | | - |
| 187 | + |
188 | 188 | } |
189 | | - |
| 189 | + |
190 | 190 | /** |
191 | 191 | * Create a new SignDocumentForm from the db, as extracted using the provided |
192 | 192 | * form_id. |
— | — | @@ -194,16 +194,16 @@ |
195 | 195 | self::$mCanRunCtor = true; |
196 | 196 | $f = new SignDocumentForm(); |
197 | 197 | self::$mCanRunCtor = false; |
198 | | - |
| 198 | + |
199 | 199 | $dbw = wfGetDB( DB_MASTER ); |
200 | 200 | |
201 | 201 | $row = $dbw->selectRow( 'sdoc_form', '*', |
202 | 202 | array('form_id' => $id)); |
203 | 203 | |
204 | 204 | if ( empty($row) ) return false; |
205 | | - |
| 205 | + |
206 | 206 | $f->mInDb = true; |
207 | | - |
| 207 | + |
208 | 208 | $f->mId = $row->form_id; |
209 | 209 | $f->mPageId = $row->form_pageid; |
210 | 210 | $f->mPagename = $row->form_pagename; |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | $f->mIntrotext = $row->form_intro; |
217 | 217 | |
218 | 218 | $f->inflateFlags(); |
219 | | - |
| 219 | + |
220 | 220 | $f->mTitle = Title::newFromId( $f->mPageId ); |
221 | 221 | $f->mArticle = new Article($f->mTitle, $f->mOldid); |
222 | 222 | |
— | — | @@ -223,20 +223,20 @@ |
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
227 | | - * Compresses the optional and hidden boolean flags down into two |
| 227 | + * Compresses the optional and hidden boolean flags down into two |
228 | 228 | * bitfields. |
229 | 229 | */ |
230 | 230 | function compressFlags() { |
231 | 231 | $this->mHiddenFlags = 0; |
232 | | - |
| 232 | + |
233 | 233 | if ($this->mEmailHidden) $this->mHiddenFlags |= 1; |
234 | 234 | if ($this->mAddressHidden) $this->mHiddenFlags |= 1 << 1; |
235 | 235 | if ($this->mExtAddressHidden) $this->mHiddenFlags |= 1 << 2; |
236 | 236 | if ($this->mPhoneHidden) $this->mHiddenFlags |= 1 << 3; |
237 | 237 | if ($this->mBdayHidden) $this->mHiddenFlags |= 1 << 4; |
238 | | - |
| 238 | + |
239 | 239 | $this->mOptionalFlags = 0; |
240 | | - |
| 240 | + |
241 | 241 | if ($this->mEmailOptional) $this->mOptionalFlags |= 1; |
242 | 242 | if ($this->mAddressOptional) $this->mOptionalFlags |= 1 << 1; |
243 | 243 | if ($this->mExtAddressOptional) $this->mOptionalFlags |= 1 << 2; |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | $this->mExtAddressHidden = (bool) ($this->mHiddenFlags & (1 << 2)); |
258 | 258 | $this->mPhoneHidden = (bool) ($this->mHiddenFlags & (1 << 3)); |
259 | 259 | $this->mBdayHidden = (bool) ($this->mHiddenFlags & (1 << 4)); |
260 | | - |
| 260 | + |
261 | 261 | $this->mEmailOptional = (bool) ($this->mOptionalFlags & 1); |
262 | 262 | $this->mAddressOptional = (bool) ($this->mOptionalFlags & (1 << 1)); |
263 | 263 | $this->mExtAddressOptional = (bool) ($this->mOptionalFlags & (1 << 2)); |
— | — | @@ -275,7 +275,7 @@ |
276 | 276 | 'form_open' => $this->mOpen ), array( |
277 | 277 | 'form_id' => $this->getId() ) ); |
278 | 278 | } |
279 | | - |
| 279 | + |
280 | 280 | /** |
281 | 281 | * Basic string representation for debugging purposes. |
282 | 282 | */ |
— | — | @@ -308,22 +308,22 @@ |
309 | 309 | public function getId() { return $this->mId; } |
310 | 310 | public function getOldid() { return $this->mOldid; } |
311 | 311 | public function getPageId() { return $this->mPageId; } |
312 | | -} |
| 312 | +} |
313 | 313 | |
314 | 314 | /** |
315 | | - * A SignDocumentSignature is, just as its name suggests, all data attached to a |
| 315 | + * A SignDocumentSignature is, just as its name suggests, all data attached to a |
316 | 316 | * given signature. |
317 | 317 | */ |
318 | 318 | class SignDocumentSignature { |
319 | 319 | /* Public fields, visible to all users regardless of settings. */ |
320 | 320 | public $mId, $mTimestamp; |
321 | 321 | public $mStricken, $mStrickenBy, $mStrickenComment; |
322 | | - |
| 322 | + |
323 | 323 | /* Private fields accessible only if not specified as private or if the user |
324 | 324 | * viewing them has the appropriate priveleges to view private fields. */ |
325 | 325 | private $mRealName, $mAddress, $mCity, $mState, $mCountry, $mZip, $mPhone, |
326 | 326 | $mBday, $mEmail; |
327 | | - |
| 327 | + |
328 | 328 | /* Array containing fields set as private. */ |
329 | 329 | private $mHiddenFields; |
330 | 330 | private $mAllAccessible; |
— | — | @@ -332,13 +332,13 @@ |
333 | 333 | private $mIp, $mAgent; |
334 | 334 | |
335 | 335 | public $mForm; |
336 | | - |
| 336 | + |
337 | 337 | private static $canRunCtor; |
338 | 338 | |
339 | 339 | function __construct() { |
340 | 340 | if (!self::$canRunCtor) throw new MWException('Finger weg!'); |
341 | 341 | } |
342 | | - |
| 342 | + |
343 | 343 | /** |
344 | 344 | * Create a "blank" SignDocumentSignature. |
345 | 345 | */ |
— | — | @@ -348,7 +348,7 @@ |
349 | 349 | self::$canRunCtor = false; |
350 | 350 | return $f; |
351 | 351 | } |
352 | | - |
| 352 | + |
353 | 353 | /** |
354 | 354 | * Create a new SignDocumentSignature using data obtained from a POST. |
355 | 355 | */ |
— | — | @@ -360,7 +360,7 @@ |
361 | 361 | self::$canRunCtor = true; |
362 | 362 | $f = new SignDocumentSignature(); |
363 | 363 | self::$canRunCtor = false; |
364 | | - |
| 364 | + |
365 | 365 | $f->mTimestamp = wfTimestampNow(); |
366 | 366 | |
367 | 367 | $f->mRealName = $wgRequest->getVal( 'realname', '' ); |
— | — | @@ -446,7 +446,7 @@ |
447 | 447 | $dbw = wfGetDB( DB_MASTER ); |
448 | 448 | |
449 | 449 | $dbrs = $dbw->select('sdoc_signature', '*', $cond ); |
450 | | - |
| 450 | + |
451 | 451 | while ( $dbr = $dbw->fetchObject($dbrs)) { |
452 | 452 | $ret[] = self::newFromRow($dbr); |
453 | 453 | } |
— | — | @@ -478,7 +478,7 @@ |
479 | 479 | $f->mStricken = $dbr->sig_stricken; |
480 | 480 | $f->mStrickenBy = $dbr->sig_strickenby; |
481 | 481 | $f->mStrickenComment = $dbr->sig_strickencomment; |
482 | | - |
| 482 | + |
483 | 483 | if ( $dbr->sig_anonymous ) $f->mHiddenFields[] = 'realname'; |
484 | 484 | if ( $dbr->sig_hideaddress ) $f->mHiddenFields[] = 'address'; |
485 | 485 | if ( $dbr->sig_hideextaddress ) $f->mHiddenFields[] = 'extaddress'; |
— | — | @@ -498,7 +498,7 @@ |
499 | 499 | |
500 | 500 | $row1 = $dbw->selectRow( 'sdoc_signature', 'sig_id', array( |
501 | 501 | 'sig_form' => $this->mForm->getId(), |
502 | | - 'sig_ip' => $this->mIp ), 'LIMIT 1' ); |
| 502 | + 'sig_ip' => $this->mIp ), 'LIMIT 1' ); |
503 | 503 | |
504 | 504 | if ( !empty($row1) ) throw new MWException( wfMsg( 'sig-error-already-signed' ) ); |
505 | 505 | |
— | — | @@ -508,7 +508,7 @@ |
509 | 509 | |
510 | 510 | if ($this->mEmail && !empty($row2)) throw new MWException( wfMsg( 'sig-error-already-signed' ) ); |
511 | 511 | } |
512 | | - |
| 512 | + |
513 | 513 | /** |
514 | 514 | * Add it to the database. |
515 | 515 | */ |
— | — | @@ -539,7 +539,7 @@ |
540 | 540 | ) ); |
541 | 541 | |
542 | 542 | /* Get back our id. */ |
543 | | - $id = $dbw->selectRow( 'sdoc_signature', 'sig_id', |
| 543 | + $id = $dbw->selectRow( 'sdoc_signature', 'sig_id', |
544 | 544 | '', 'Database::selectRow', array( |
545 | 545 | 'ORDER BY' => 'sig_id DESC', |
546 | 546 | 'LIMIT' => '1' ) ); |
— | — | @@ -608,7 +608,7 @@ |
609 | 609 | public function setAllAccessible( $b ) { |
610 | 610 | $this->mAllAccessible = $b; |
611 | 611 | } |
612 | | - |
| 612 | + |
613 | 613 | public function isPrivileged() { |
614 | 614 | global $wgUser; |
615 | 615 | return $wgUser->isAllowed( 'sigadmin' ); |
— | — | @@ -621,7 +621,7 @@ |
622 | 622 | public function canView( $val ) { |
623 | 623 | return $this->mAllAccessible || (!$this->isHidden( $val ) || $this->isPrivileged() ); |
624 | 624 | } |
625 | | - |
| 625 | + |
626 | 626 | public function getRealName(){ |
627 | 627 | return ($this->canView('realname'))?$this->mRealName:wfMsg( 'sig-anonymous' ); |
628 | 628 | } |
— | — | @@ -629,31 +629,31 @@ |
630 | 630 | public function getAddress(){ |
631 | 631 | return ($this->canView('address'))?$this->mAddress:wfMsg( 'sig-private' ); |
632 | 632 | } |
633 | | - |
| 633 | + |
634 | 634 | public function getCity(){ |
635 | 635 | return ($this->canView('extaddress'))?$this->mCity:wfMsg( 'sig-private' ); |
636 | 636 | } |
637 | | - |
| 637 | + |
638 | 638 | public function getState(){ |
639 | 639 | return ($this->canView('extaddress'))?$this->mState:wfMsg( 'sig-private' ); |
640 | 640 | } |
641 | | - |
| 641 | + |
642 | 642 | public function getCountry(){ |
643 | 643 | return ($this->canView('extaddress'))?$this->mCountry:wfMsg( 'sig-private' ); |
644 | 644 | } |
645 | | - |
| 645 | + |
646 | 646 | public function getZip(){ |
647 | 647 | return ($this->canView('extaddress'))?$this->mZip:wfMsg( 'sig-private' ); |
648 | 648 | } |
649 | | - |
| 649 | + |
650 | 650 | public function getPhone(){ |
651 | 651 | return ($this->canView('phone'))?$this->mPhone:wfMsg( 'sig-private' ); |
652 | 652 | } |
653 | | - |
| 653 | + |
654 | 654 | public function getEmail(){ |
655 | 655 | return ($this->canView('email'))?$this->mEmail:wfMsg( 'sig-private' ); |
656 | 656 | } |
657 | | - |
| 657 | + |
658 | 658 | public function getBday(){ |
659 | 659 | return ($this->canView('bday'))?$this->mBday:wfMsg( 'sig-private' ); |
660 | 660 | } |
— | — | @@ -661,15 +661,13 @@ |
662 | 662 | public function getIp() { |
663 | 663 | return ($this->isPrivileged())?$this->mIp:wfMsg( 'sig-private' ); |
664 | 664 | } |
665 | | - |
| 665 | + |
666 | 666 | public function getAgent() { |
667 | 667 | return ($this->isPrivileged())?$this->mAgent:wfMsg( 'sig-private' ); |
668 | 668 | } |
669 | 669 | |
670 | 670 | public function getReviewedBy() { |
671 | 671 | return User::whois( $this->mStrickenBy ); |
672 | | - |
| 672 | + |
673 | 673 | } |
674 | 674 | } |
675 | | - |
676 | | -?> |
Index: trunk/extensions/SignDocument/SpecialCreateSignDocument.php |
— | — | @@ -1,23 +1,25 @@ |
2 | | -<?PHP |
| 2 | +<?PHP |
3 | 3 | if (!defined('MEDIAWIKI')) die(); |
4 | 4 | |
5 | 5 | require_once( 'SignDocumentHelpers.php' ); |
6 | 6 | |
7 | 7 | //TODO: Doc |
8 | | -class CreateSignDocument extends SpecialPage { |
| 8 | +class SpecialCreateSignDocument extends SpecialPage { |
9 | 9 | /** |
10 | | - * Constructor |
11 | | - */ |
12 | | - function CreateSignDocument() { |
| 10 | + * Constructor |
| 11 | + */ |
| 12 | + function __construct() { |
13 | 13 | SpecialPage::SpecialPage( 'CreateSignDocument', 'createsigndocument' ); |
14 | | - wfLoadExtensionMessages('CreateSignDocument'); |
15 | 14 | } |
16 | 15 | |
17 | 16 | function execute($par) { |
18 | 17 | global $wgOut, $wgRequest, $wgUser; |
| 18 | + |
| 19 | + wfLoadExtensionMessages('CreateSignDocument'); |
| 20 | + |
19 | 21 | $this->setHeaders(); |
20 | 22 | if ($wgUser->isAllowed( 'createsigndocument' )) { |
21 | | - |
| 23 | + |
22 | 24 | if ( $wgRequest->wasPosted() ) |
23 | 25 | $this->dealWithPost(); |
24 | 26 | else |
— | — | @@ -44,12 +46,12 @@ |
45 | 47 | </td></tr><tr><td> |
46 | 48 | <strong>' . wfMsg( 'createsigndoc-allowedgroup' ) . ' </strong> |
47 | 49 | </td><td> |
48 | | - <select id="allowedgroup" name="group" style="width: 400px;">' |
| 50 | + <select id="allowedgroup" name="group" style="width: 400px;">' |
49 | 51 | . $this->makeComboItems( array_keys($wgGroupPermissions) ) . ' </select> |
50 | | - ' . $this->checkMarks( 'email' ) . |
51 | | - $this->checkMarks( 'address' ) . |
52 | | - $this->checkMarks( 'extaddress' ) . |
53 | | - $this->checkMarks( 'phone' ) . |
| 52 | + ' . $this->checkMarks( 'email' ) . |
| 53 | + $this->checkMarks( 'address' ) . |
| 54 | + $this->checkMarks( 'extaddress' ) . |
| 55 | + $this->checkMarks( 'phone' ) . |
54 | 56 | $this->checkMarks( 'bday' ) . ' |
55 | 57 | </td></tr><tr><td> |
56 | 58 | <strong>' . wfMsg( 'createsigndoc-minage' ) . ' </strong> |
— | — | @@ -59,7 +61,7 @@ |
60 | 62 | </td><td><textarea id="introtext" name="introtext" wrap="soft" style="height: 300px; width: 400px;">' . |
61 | 63 | '</textarea> |
62 | 64 | </td></tr><tr><td></td><td> |
63 | | - <input type="submit" id="create" name="create" value="' . |
| 65 | + <input type="submit" id="create" name="create" value="' . |
64 | 66 | wfMsg( 'createsigndoc-create' ) . '" /> |
65 | 67 | </td></tr> |
66 | 68 | </table> |
— | — | @@ -77,7 +79,7 @@ |
78 | 80 | "mwCreateSignDocHidden-$id", |
79 | 81 | "mwCreateSignDocHidden-$id", |
80 | 82 | false); |
81 | | - |
| 83 | + |
82 | 84 | $out .= Xml::checkLabel( |
83 | 85 | wfMsg( 'createsigndoc-optional' ), |
84 | 86 | "mwCreateSignDocOptional-$id", |
— | — | @@ -109,7 +111,7 @@ |
110 | 112 | |
111 | 113 | if (!$bob->loadArticleData()) |
112 | 114 | return $this->showError( 'pagenoexist', $bob->mPagename ); |
113 | | - |
| 115 | + |
114 | 116 | if (!$bob->addToDb()) |
115 | 117 | return $this->showError( 'alreadycreated', $bob->mPagename ); |
116 | 118 | |
Index: trunk/extensions/SignDocument/README.txt |
— | — | @@ -21,24 +21,24 @@ |
22 | 22 | [4] File manifest |
23 | 23 | |
24 | 24 | [1] Installation |
25 | | - [1.1] SignDocument has the following installation prerequisites: |
| 25 | + [1.1] SignDocument has the following installation prerequisites: |
26 | 26 | [1.1.1] MediaWiki 1.10+ and its requirements (such as PHP5 and MySQL) |
27 | 27 | [1.1.2] It should run on all operating systems that MW supports; |
28 | 28 | however, it has only been tested on SuSE Linux 10.1 and Red Hat Fedora |
29 | 29 | Core 4. |
30 | 30 | [1.1.3] ExtensionFunctions.php must be installed in your extensions |
31 | 31 | directory. This can be downloaded from subversion. |
32 | | - |
| 32 | + |
33 | 33 | [1.2] Verify that you have all the needed files (see |4| below) in the |
34 | 34 | directoy "<wikiroot>/extensions/SignDocument". If you need the extension |
35 | 35 | to be stored elsewhere, then amend these instructions accordingly. |
36 | | - |
| 36 | + |
37 | 37 | [1.3] First, you must set up the database to support the extension. To do |
38 | 38 | this, execute "mysql -u root -p |yourwikidb| < signdocument.sql", or |
39 | 39 | otherwise execute the signdocument.sql script (using phpMyAdmin or similar |
40 | 40 | applications). |
41 | 41 | |
42 | | - [1.4] Then, add to your LocalSettings.php: |
| 42 | + [1.4] Then, add to your LocalSettings.php: |
43 | 43 | 'require_once( "$IP/extensions/SignDocument/SignDocument.php" )'. |
44 | 44 | |
45 | 45 | [1.5] You can then add a user on your wiki to the group "sigadmin" via |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | [3] Using Special:SignDocument |
78 | 78 | [3.1] The heart of the extension is Special:SignDocument, which provides |
79 | 79 | both the interface allowing users to sign documents and the moderation |
80 | | - interface, accessible to users in the group "sigadmin". |
| 80 | + interface, accessible to users in the group "sigadmin". |
81 | 81 | |
82 | 82 | [3.2] Accessing the special page directly will give you a list of pages |
83 | 83 | that you can sign or for which you can view signatures; however, in most |
— | — | @@ -122,6 +122,3 @@ |
123 | 123 | -> Localization for Special:CreateSignDocument. |
124 | 124 | [4.9] SignDocumentHelpers.php |
125 | 125 | -> Helper classes for the extension. |
126 | | - |
127 | | - |
128 | | - |
Index: trunk/extensions/SignDocument/SignDocument.alias.php |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for special pages |
| 5 | + * |
| 6 | + */ |
| 7 | + |
| 8 | +$aliases = array(); |
| 9 | + |
| 10 | +$aliases['en'] = array( |
| 11 | + 'SignDocument' => array( 'SignDocument' ), |
| 12 | + 'CreateSignDocument' => array( 'CreateSignDocument' ), |
| 13 | +); |
Property changes on: trunk/extensions/SignDocument/SignDocument.alias.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 14 | + native |
Name: svn:keywords |
2 | 15 | + Id |
Index: trunk/extensions/SignDocument/signdocument.sql |
— | — | @@ -5,11 +5,11 @@ |
6 | 6 | |
7 | 7 | -- -------------------------------------------------------- |
8 | 8 | |
| 9 | +-- |
9 | 10 | -- Table structure for table sdoc_form |
10 | 11 | -- This table contains the configuration of which documents |
11 | 12 | -- may be signed and how they should be signed. |
| 13 | +-- |
12 | 14 | |
13 | 15 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/sdoc_form ( |
14 | 16 | form_id int(11) NOT NULL auto_increment, |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | form_pageid int(11) NOT NULL default '0', |
20 | 20 | form_pagename varchar(255) character set latin1 collate latin1_bin NOT NULL default '', |
21 | 21 | |
| 22 | +-- Users signing the document will only see this old |
22 | 23 | -- revision of the page. |
23 | 24 | form_oldid int(11) NOT NULL default '0', |
24 | 25 | |
— | — | @@ -43,10 +43,10 @@ |
44 | 44 | |
45 | 45 | -- -------------------------------------------------------- |
46 | 46 | |
| 47 | +-- |
47 | 48 | -- Table structure for table sdoc_signature |
48 | 49 | -- This table contains the actual signatures. |
| 50 | +-- |
49 | 51 | |
50 | 52 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/sdoc_signature ( |
51 | 53 | sig_id int(11) NOT NULL auto_increment, |
Index: trunk/extensions/Translate/aliases.txt |
— | — | @@ -130,6 +130,9 @@ |
131 | 131 | Show processlist |
132 | 132 | file = ShowProcesslist/ShowProcesslist.alias.php |
133 | 133 | |
| 134 | +Sign document |
| 135 | +file = SignDocument/SignDocument.alias.php |
| 136 | + |
134 | 137 | Site matrix |
135 | 138 | file = SiteMatrix/SiteMatrix.alias.php |
136 | 139 | |