Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -596,7 +596,7 @@ |
597 | 597 | global $wgOut, $wgRequest, $wgUser; |
598 | 598 | |
599 | 599 | // Make sure notice exists |
600 | | - if ( !$this->noticeExists( $notice ) ) { |
| 600 | + if ( !CentralNoticeDB::campaignExists( $notice ) ) { |
601 | 601 | $this->showError( 'centralnotice-notice-doesnt-exist' ); |
602 | 602 | } else { |
603 | 603 | |
— | — | @@ -1096,7 +1096,7 @@ |
1097 | 1097 | function addCampaign( $noticeName, $enabled, $start, $projects, |
1098 | 1098 | $project_languages, $geotargeted, $geo_countries ) |
1099 | 1099 | { |
1100 | | - if ( $this->noticeExists( $noticeName ) ) { |
| 1100 | + if ( CentralNoticeDB::campaignExists( $noticeName ) ) { |
1101 | 1101 | $this->showError( 'centralnotice-notice-exists' ); |
1102 | 1102 | return null; |
1103 | 1103 | } elseif ( empty( $projects ) ) { |
— | — | @@ -1359,7 +1359,7 @@ |
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | // Invalid campaign name |
1363 | | - if ( !$this->noticeExists( $noticeName ) ) { |
| 1363 | + if ( !CentralNoticeDB::campaignExists( $noticeName ) ) { |
1364 | 1364 | $this->showError( 'centralnotice-notice-doesnt-exist' ); |
1365 | 1365 | return; |
1366 | 1366 | } |
— | — | @@ -1385,7 +1385,7 @@ |
1386 | 1386 | * @param $settingValue int: Value to use for the setting, 0 or 1 |
1387 | 1387 | */ |
1388 | 1388 | private function setBooleanCampaignSetting( $noticeName, $settingName, $settingValue ) { |
1389 | | - if ( !$this->noticeExists( $noticeName ) ) { |
| 1389 | + if ( !CentralNoticeDB::campaignExists( $noticeName ) ) { |
1390 | 1390 | // Exit quietly since campaign may have been deleted at the same time. |
1391 | 1391 | return; |
1392 | 1392 | } else { |
— | — | @@ -1624,17 +1624,6 @@ |
1625 | 1625 | } |
1626 | 1626 | } |
1627 | 1627 | |
1628 | | - public static function noticeExists( $noticeName ) { |
1629 | | - $dbr = wfGetDB( DB_SLAVE ); |
1630 | | - $eNoticeName = htmlspecialchars( $noticeName ); |
1631 | | - $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 'not_name' => $eNoticeName ) ); |
1632 | | - if ( $row ) { |
1633 | | - return true; |
1634 | | - } else { |
1635 | | - return false; |
1636 | | - } |
1637 | | - } |
1638 | | - |
1639 | 1628 | public static function dropDownList( $text, $values ) { |
1640 | 1629 | $dropDown = "*{$text}\n"; |
1641 | 1630 | foreach ( $values as $value ) { |
Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -318,6 +318,22 @@ |
319 | 319 | } |
320 | 320 | |
321 | 321 | /* |
| 322 | + * See if a given campaign exists in the database |
| 323 | + */ |
| 324 | + public static function campaignExists( $campaignName ) { |
| 325 | + global $wgCentralDBname; |
| 326 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
| 327 | + |
| 328 | + $eCampaignName = htmlspecialchars( $campaignName ); |
| 329 | + $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 'not_name' => $eCampaignName ) ); |
| 330 | + if ( $row ) { |
| 331 | + return true; |
| 332 | + } else { |
| 333 | + return false; |
| 334 | + } |
| 335 | + } |
| 336 | + |
| 337 | + /* |
322 | 338 | * See if a given banner exists in the database |
323 | 339 | */ |
324 | 340 | public static function bannerExists( $bannerName ) { |