Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/55612
Change subject: Countries column in campaigns table
......................................................................
Countries column in campaigns table
Change-Id: I253a651c9486142961ab747efd475b01368f636c
---
M includes/Campaign.php
M special/SpecialCentralNotice.php
2 files changed, 21 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/12/55612/1
diff --git a/includes/Campaign.php b/includes/Campaign.php
index b0755bd..5a90414 100644
--- a/includes/Campaign.php
+++ b/includes/Campaign.php
@@ -464,13 +464,23 @@
global $wgCentralDBname;
$dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname );
$eNoticeName = htmlspecialchars( $noticeName );
- $row = $dbr->selectRow( 'cn_notices', 'not_id', array(
'not_name' => $eNoticeName ) );
+ $row = $dbr->selectRow( 'cn_notices',
+ array(
+ 'not_id',
+ 'not_geo',
+ ),
+ array( 'not_name' => $eNoticeName )
+ );
$countries = array();
if ( $row ) {
- $res = $dbr->select( 'cn_notice_countries',
'nc_country',
- array( 'nc_notice_id' => $row->not_id ) );
- foreach ( $res as $countryRow ) {
- $countries[ ] = $countryRow->nc_country;
+ if ( $row->not_geo === '1' ) {
+ $res = $dbr->select( 'cn_notice_countries',
'nc_country',
+ array( 'nc_notice_id' => $row->not_id )
);
+ foreach ( $res as $countryRow ) {
+ $countries[ ] = $countryRow->nc_country;
+ }
+ } else {
+ return array_keys( GeoTarget::getCountriesList(
'en' ) );
}
}
return $countries;
diff --git a/special/SpecialCentralNotice.php b/special/SpecialCentralNotice.php
index 241ca92..2fc7aa3 100644
--- a/special/SpecialCentralNotice.php
+++ b/special/SpecialCentralNotice.php
@@ -398,6 +398,7 @@
$this->msg( 'centralnotice-notice-name'
)->escaped(),
$this->msg( 'centralnotice-projects'
)->escaped(),
$this->msg( 'centralnotice-languages'
)->escaped(),
+ $this->msg( 'centralnotice-countries'
)->escaped(),
$this->msg( 'centralnotice-start-date'
)->escaped(),
$this->msg( 'centralnotice-end-date'
)->escaped(),
$this->msg( 'centralnotice-enabled'
)->escaped(),
@@ -436,6 +437,11 @@
$languageList = $this->listLanguages(
$project_langs );
$rowCells .= Html::rawElement( 'td', array(),
$languageList );
+ // Countries
+ $project_countries =
Campaign::getNoticeCountries( $row->not_name );
+ $countryList = $this->listCountries(
$project_countries );
+ $rowCells .= Html::rawElement( 'td', array(),
$countryList );
+
// Date and time calculations
$start_timestamp = wfTimestamp( TS_MW,
$row->not_start );
$start_year = substr( $start_timestamp, 0, 4 );
--
To view, visit https://gerrit.wikimedia.org/r/55612
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I253a651c9486142961ab747efd475b01368f636c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits