Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -706,6 +706,7 @@ |
707 | 707 | } |
708 | 708 | $dbr = wfGetDB( DB_SLAVE ); |
709 | 709 | |
| 710 | + // Get campaign info from database |
710 | 711 | $row = $dbr->selectRow( 'cn_notices', |
711 | 712 | array( |
712 | 713 | 'not_id', |
— | — | @@ -720,17 +721,11 @@ |
721 | 722 | array( 'not_name' => $notice ), |
722 | 723 | __METHOD__ |
723 | 724 | ); |
724 | | - $res = $dbr->select( 'cn_notice_languages', |
725 | | - 'nl_language', |
726 | | - array( 'nl_notice_id' => $row->not_id ), |
727 | | - __METHOD__ |
728 | | - ); |
729 | | - $project_languages = array(); |
730 | | - foreach ( $res as $langRow ) { |
731 | | - $project_languages[] = $langRow->nl_language; |
732 | | - } |
733 | 725 | |
734 | 726 | if ( $row ) { |
| 727 | + // Get all languages associated with the campaign |
| 728 | + $noticeLanguages = $this->getNoticeLanguages( $notice ); |
| 729 | + |
735 | 730 | // Build Html |
736 | 731 | $htmlOut = ''; |
737 | 732 | $htmlOut .= Xml::tags( 'h2', null, wfMsg( 'centralnotice-notice-heading', $notice ) ); |
— | — | @@ -760,7 +755,7 @@ |
761 | 756 | // Languages |
762 | 757 | $htmlOut .= Xml::openElement( 'tr' ); |
763 | 758 | $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) ); |
764 | | - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $project_languages ) ); |
| 759 | + $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) ); |
765 | 760 | $htmlOut .= Xml::closeElement( 'tr' ); |
766 | 761 | // Enabled |
767 | 762 | $htmlOut .= Xml::openElement( 'tr' ); |
— | — | @@ -1091,7 +1086,7 @@ |
1092 | 1087 | $eNoticeName = htmlspecialchars( $noticeName ); |
1093 | 1088 | $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1094 | 1089 | $languages = array(); |
1095 | | - if ( $dbr->numRows( $row ) > 0 ) { |
| 1090 | + if ( $row ) { |
1096 | 1091 | $res = $dbr->select( 'cn_notice_languages', 'nl_language', array( 'nl_notice_id' => $row->not_id ) ); |
1097 | 1092 | foreach ( $res as $langRow ) { |
1098 | 1093 | $languages[] = $langRow->nl_language; |
— | — | @@ -1297,11 +1292,12 @@ |
1298 | 1293 | |
1299 | 1294 | // Remove disassociated languages |
1300 | 1295 | $removeLanguages = array_diff( $oldLanguages, $newLanguages ); |
1301 | | - if ( !empty( $removeLanguages ) ) { |
| 1296 | + if ( $removeLanguages ) { |
1302 | 1297 | $res = $dbw->delete( 'cn_notice_languages', |
1303 | 1298 | array( 'nl_notice_id' => $row->not_id, 'nl_language' => $removeLanguages ) |
1304 | 1299 | ); |
1305 | 1300 | } |
| 1301 | + |
1306 | 1302 | $dbw->commit(); |
1307 | 1303 | } |
1308 | 1304 | |