r72950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72949‎ | r72950 | r72951 >
Date:01:19, 14 September 2010
Author:kaldari
Status:ok
Tags:
Comment:
schema changes from r72932 (futureproofing), adding basic support for saving geo info
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/patches/patch-notice_countries.sql (added) (history)
  • /trunk/extensions/CentralNotice/patches/patch-notice_geo.sql (deleted) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -120,7 +120,7 @@
121121 $wgExtNewFields[] = array( 'cn_notices', 'not_preferred', $base . '/patches/patch-notice_preferred.sql' );
122122 $wgExtNewTables[] = array( 'cn_notice_languages', $base . '/patches/patch-notice_languages.sql' );
123123 $wgExtNewFields[] = array( 'cn_templates', 'tmp_display_anon', $base . '/patches/patch-template_settings.sql' );
124 - $wgExtNewTables[] = array( 'cn_notice_geo', $base . '/patches/patch-notice_geo.sql' );
 124+ $wgExtNewTables[] = array( 'cn_notice_countries', $base . '/patches/patch-notice_countries.sql' );
125125 }
126126 return true;
127127 }
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -147,10 +147,12 @@
148148 $start = $wgRequest->getArray( 'start' );
149149 $project_name = $wgRequest->getVal( 'project_name' );
150150 $project_languages = $wgRequest->getArray( 'project_languages' );
 151+ $geotargeted = $wgRequest->getCheck( 'geotargeted' );
 152+ $geo_countries = $wgRequest->getArray( 'geo_countries' );
151153 if ( $noticeName == '' ) {
152154 $this->showError( 'centralnotice-null-string' );
153155 } else {
154 - $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages );
 156+ $this->addNotice( $noticeName, '0', $start, $project_name, $project_languages, $geotargeted, $geo_countries );
155157 }
156158 }
157159
@@ -1026,7 +1028,7 @@
10271029 return $templates;
10281030 }
10291031
1030 - function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages ) {
 1032+ function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages, $geotargeted, $geo_countries ) {
10311033 global $wgOut;
10321034
10331035 if ( $this->noticeExists( $noticeName ) ) {
@@ -1059,7 +1061,8 @@
10601062 'not_enabled' => $enabled,
10611063 'not_start' => $dbw->timestamp( $startTs ),
10621064 'not_end' => $dbw->timestamp( $endTs ),
1063 - 'not_project' => $project_name
 1065+ 'not_project' => $project_name,
 1066+ 'not_geo' => $geotargeted
10641067 )
10651068 );
10661069 $not_id = $dbw->insertId();
@@ -1070,6 +1073,15 @@
10711074 $insertArray[] = array( 'nl_notice_id' => $not_id, 'nl_language' => $code );
10721075 }
10731076 $res = $dbw->insert( 'cn_notice_languages', $insertArray, __METHOD__, array( 'IGNORE' ) );
 1077+
 1078+ if ( $geotargeted ) {
 1079+ // Do multi-row insert for campaign countries
 1080+ $insertArray = array();
 1081+ foreach( $geo_countries as $code ) {
 1082+ $insertArray[] = array( 'nc_notice_id' => $not_id, 'nc_country' => $code );
 1083+ }
 1084+ $res = $dbw->insert( 'cn_notice_countries', $insertArray, __METHOD__, array( 'IGNORE' ) );
 1085+ }
10741086
10751087 $dbw->commit();
10761088 return;
Index: trunk/extensions/CentralNotice/patches/patch-notice_geo.sql
@@ -1,8 +0,0 @@
2 -
3 -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_geo (
4 - ng_notice_id int unsigned NOT NULL,
5 - ng_country varchar(2) NOT NULL
6 -) /*$wgDBTableOptions*/;
7 -CREATE UNIQUE INDEX /*i*/ng_notice_id_geo ON /*$wgDBprefix*/cn_notice_geo (ng_notice_id, ng_country);
8 -ALTER TABLE /*$wgDBprefix*/cn_notices ADD not_geo BOOLEAN NOT NULL DEFAULT '0' AFTER not_locked;
Index: trunk/extensions/CentralNotice/patches/patch-notice_countries.sql
@@ -0,0 +1,8 @@
 2+-- Update to allow for any number of geotargetted countries per notice.
 3+
 4+CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_countries (
 5+ nc_notice_id int unsigned NOT NULL,
 6+ nc_country varchar(2) NOT NULL
 7+) /*$wgDBTableOptions*/;
 8+CREATE UNIQUE INDEX /*i*/nc_notice_id_country ON /*$wgDBprefix*/cn_notice_countries (nc_notice_id, nc_country);
 9+ALTER TABLE /*$wgDBprefix*/cn_notices ADD not_geo BOOLEAN NOT NULL DEFAULT '0' AFTER not_locked;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r72932adding schema changes for geotargetting, adding BannerController classkaldari21:05, 13 September 2010

Status & tagging log