Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -72,48 +72,16 @@ |
73 | 73 | // Handle adding banner |
74 | 74 | // FIXME: getText()? weak comparison |
75 | 75 | if ( $wgRequest->getVal( 'wpMethod' ) == 'addTemplate' ) { |
76 | | - |
77 | | - // Handle "Display to anonymous users" checkbox |
78 | | - $displayAnon = 0; |
79 | | - if ( $wgRequest->getVal( 'displayAnon' ) ) { |
80 | | - $displayAnon = $wgRequest->getVal( 'displayAnon' ); |
81 | | - } |
82 | | - |
83 | | - // Handle "Display to logged in users" checkbox |
84 | | - $displayAccount = 0; |
85 | | - if ( $wgRequest->getVal( 'displayAccount' ) ) { |
86 | | - $displayAccount = $wgRequest->getVal( 'displayAccount' ); |
87 | | - } |
88 | | - |
89 | 76 | $this->addTemplate( |
90 | 77 | $wgRequest->getVal( 'templateName' ), |
91 | | - $wgRequest->getVal( 'templateBody' ), |
92 | | - $displayAnon, |
93 | | - $displayAccount |
| 78 | + $wgRequest->getVal( 'templateBody' ) |
94 | 79 | ); |
95 | 80 | $sub = 'view'; |
96 | 81 | } |
97 | | - |
98 | | - // Handle editing banner |
99 | 82 | if ( $wgRequest->getVal( 'wpMethod' ) == 'editTemplate' ) { |
100 | | - |
101 | | - // Handle "Display to anonymous users" checkbox |
102 | | - $displayAnon = 0; |
103 | | - if ( $wgRequest->getVal( 'displayAnon' ) ) { |
104 | | - $displayAnon = $wgRequest->getVal( 'displayAnon' ); |
105 | | - } |
106 | | - |
107 | | - // Handle "Display to logged in users" checkbox |
108 | | - $displayAccount = 0; |
109 | | - if ( $wgRequest->getVal( 'displayAccount' ) ) { |
110 | | - $displayAccount = $wgRequest->getVal( 'displayAccount' ); |
111 | | - } |
112 | | - |
113 | 83 | $this->editTemplate( |
114 | 84 | $wgRequest->getVal( 'template' ), |
115 | | - $wgRequest->getVal( 'templateBody' ), |
116 | | - $displayAnon, |
117 | | - $displayAccount |
| 85 | + $wgRequest->getVal( 'templateBody' ) |
118 | 86 | ); |
119 | 87 | $sub = 'view'; |
120 | 88 | } |
— | — | @@ -226,15 +194,6 @@ |
227 | 195 | $htmlOut .= Xml::tags( 'p', null, |
228 | 196 | Xml::inputLabel( wfMsg( 'centralnotice-banner-name' ) . ":", 'templateName', 'templateName', 25 ) |
229 | 197 | ); |
230 | | - |
231 | | - $htmlOut .= Xml::openElement( 'p', null ); |
232 | | - $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
233 | | - $htmlOut .= Xml::check( 'displayAnon', true, array( 'id' => 'displayAnon' ) ); |
234 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
235 | | - $htmlOut .= Xml::check( 'displayAccount', true, array( 'id' => 'displayAccount' ) ); |
236 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
237 | | - $htmlOut .= Xml::closeElement( 'p' ); |
238 | | - |
239 | 198 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) ); |
240 | 199 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
241 | 200 | $buttons = array(); |
— | — | @@ -272,10 +231,8 @@ |
273 | 232 | |
274 | 233 | if ( $this->editable ) { |
275 | 234 | $readonly = array(); |
276 | | - $disabled = array(); |
277 | 235 | } else { |
278 | 236 | $readonly = array( 'readonly' => 'readonly' ); |
279 | | - $disabled = array( 'disabled' => 'disabled' ); |
280 | 237 | } |
281 | 238 | |
282 | 239 | // Get user's language |
— | — | @@ -284,17 +241,6 @@ |
285 | 242 | // Get current banner |
286 | 243 | $currentTemplate = $wgRequest->getText( 'template' ); |
287 | 244 | |
288 | | - // Pull template settings from database |
289 | | - $dbr = wfGetDB( DB_SLAVE ); |
290 | | - $row = $dbr->selectRow( 'cn_templates', |
291 | | - array( |
292 | | - 'tmp_display_anon', |
293 | | - 'tmp_display_account' |
294 | | - ), |
295 | | - array( 'tmp_name' => $currentTemplate ), |
296 | | - __METHOD__ |
297 | | - ); |
298 | | - |
299 | 245 | // Begin building HTML |
300 | 246 | $htmlOut = ''; |
301 | 247 | |
— | — | @@ -451,18 +397,6 @@ |
452 | 398 | $htmlOut .= Xml::openElement( 'form', array( 'method' => 'post' ) ); |
453 | 399 | $htmlOut .= Xml::hidden( 'wpMethod', 'editTemplate' ); |
454 | 400 | } |
455 | | - |
456 | | - // FIXME |
457 | | - $htmlOut .= Xml::fieldset( 'Settings' ); |
458 | | - $htmlOut .= Xml::openElement( 'p', null ); |
459 | | - $htmlOut .= wfMsg( 'centralnotice-banner-display' ); |
460 | | - $htmlOut .= Xml::check( 'displayAnon', ( $row->tmp_display_anon == 1 ), wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) ); |
461 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' ); |
462 | | - $htmlOut .= Xml::check( 'displayAccount', ( $row->tmp_display_account == 1 ), wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) ); |
463 | | - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' ); |
464 | | - $htmlOut .= Xml::closeElement( 'p' ); |
465 | | - $htmlOut .= Xml::closeElement( 'fieldset' ); |
466 | | - |
467 | 401 | $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-edit-template' ) ); |
468 | 402 | $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' ); |
469 | 403 | $buttons = array(); |
— | — | @@ -620,7 +554,7 @@ |
621 | 555 | /** |
622 | 556 | * Create a new banner |
623 | 557 | */ |
624 | | - private function addTemplate( $name, $body, $displayAnon, $displayAccount ) { |
| 558 | + private function addTemplate ( $name, $body ) { |
625 | 559 | global $wgOut; |
626 | 560 | |
627 | 561 | if ( $body == '' || $name == '' ) { |
— | — | @@ -645,12 +579,9 @@ |
646 | 580 | } else { |
647 | 581 | $dbw = wfGetDB( DB_MASTER ); |
648 | 582 | $dbw->begin(); |
649 | | - $res = $dbw->insert( 'cn_templates', |
650 | | - array( |
651 | | - 'tmp_name' => $name, |
652 | | - 'tmp_display_anon' => $displayAnon, |
653 | | - 'tmp_display_account' => $displayAccount |
654 | | - ), |
| 583 | + $res = $dbw->insert( |
| 584 | + 'cn_templates', |
| 585 | + array( 'tmp_name' => $name ), |
655 | 586 | __METHOD__ |
656 | 587 | ); |
657 | 588 | $dbw->commit(); |
— | — | @@ -667,7 +598,7 @@ |
668 | 599 | /** |
669 | 600 | * Update a banner |
670 | 601 | */ |
671 | | - private function editTemplate( $name, $body, $displayAnon, $displayAccount ) { |
| 602 | + private function editTemplate ( $name, $body ) { |
672 | 603 | global $wgOut; |
673 | 604 | |
674 | 605 | if ( $body == '' || $name == '' ) { |
— | — | @@ -681,18 +612,7 @@ |
682 | 613 | __METHOD__ |
683 | 614 | ); |
684 | 615 | |
685 | | - if ( $dbr->numRows( $res ) == 1 ) { |
686 | | - $dbw = wfGetDB( DB_MASTER ); |
687 | | - $dbw->begin(); |
688 | | - $res = $dbw->update( 'cn_templates', |
689 | | - array( |
690 | | - 'tmp_display_anon' => $displayAnon, |
691 | | - 'tmp_display_account' => $displayAccount |
692 | | - ), |
693 | | - array( 'tmp_name' => $name ) |
694 | | - ); |
695 | | - $dbw->commit(); |
696 | | - |
| 616 | + if ( $dbr->numRows( $res ) > 0 ) { |
697 | 617 | // Perhaps these should move into the db as blob |
698 | 618 | $article = new Article( |
699 | 619 | Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI ) |