r92516 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92515‎ | r92516 | r92517 >
Date:00:55, 19 July 2011
Author:kaldari
Status:ok
Tags:
Comment:
moving noticeExists method to DB class and renaming to campaignExists
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -596,7 +596,7 @@
597597 global $wgOut, $wgRequest, $wgUser;
598598
599599 // Make sure notice exists
600 - if ( !$this->noticeExists( $notice ) ) {
 600+ if ( !CentralNoticeDB::campaignExists( $notice ) ) {
601601 $this->showError( 'centralnotice-notice-doesnt-exist' );
602602 } else {
603603
@@ -1096,7 +1096,7 @@
10971097 function addCampaign( $noticeName, $enabled, $start, $projects,
10981098 $project_languages, $geotargeted, $geo_countries )
10991099 {
1100 - if ( $this->noticeExists( $noticeName ) ) {
 1100+ if ( CentralNoticeDB::campaignExists( $noticeName ) ) {
11011101 $this->showError( 'centralnotice-notice-exists' );
11021102 return null;
11031103 } elseif ( empty( $projects ) ) {
@@ -1359,7 +1359,7 @@
13601360 }
13611361
13621362 // Invalid campaign name
1363 - if ( !$this->noticeExists( $noticeName ) ) {
 1363+ if ( !CentralNoticeDB::campaignExists( $noticeName ) ) {
13641364 $this->showError( 'centralnotice-notice-doesnt-exist' );
13651365 return;
13661366 }
@@ -1385,7 +1385,7 @@
13861386 * @param $settingValue int: Value to use for the setting, 0 or 1
13871387 */
13881388 private function setBooleanCampaignSetting( $noticeName, $settingName, $settingValue ) {
1389 - if ( !$this->noticeExists( $noticeName ) ) {
 1389+ if ( !CentralNoticeDB::campaignExists( $noticeName ) ) {
13901390 // Exit quietly since campaign may have been deleted at the same time.
13911391 return;
13921392 } else {
@@ -1624,17 +1624,6 @@
16251625 }
16261626 }
16271627
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 -
16391628 public static function dropDownList( $text, $values ) {
16401629 $dropDown = "*{$text}\n";
16411630 foreach ( $values as $value ) {
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -318,6 +318,22 @@
319319 }
320320
321321 /*
 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+ /*
322338 * See if a given banner exists in the database
323339 */
324340 public static function bannerExists( $bannerName ) {

Status & tagging log