http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73003

Revision: 73003
Author:   kaldari
Date:     2010-09-14 18:37:38 +0000 (Tue, 14 Sep 2010)

Log Message:
-----------
adding geotargeting support to preferred campaign overrides

Modified Paths:
--------------
    trunk/extensions/CentralNotice/CentralNotice.db.php
    trunk/extensions/CentralNotice/SpecialBannerListLoader.php

Modified: trunk/extensions/CentralNotice/CentralNotice.db.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.db.php 2010-09-14 18:30:19 UTC 
(rev 73002)
+++ trunk/extensions/CentralNotice/CentralNotice.db.php 2010-09-14 18:37:38 UTC 
(rev 73003)
@@ -18,7 +18,7 @@
         * Return notices in the system within given constraints
         * Optional: return both enabled and disabled notices
         */
-       public function getNotices( $project = false, $language = false, $date 
= false, $enabled = true, $preferred = false ) {
+       public function getNotices( $project = false, $language = false, $date 
= false, $enabled = true, $preferred = false, $location = false ) {
                // Database setup
                $dbr = wfGetDB( DB_SLAVE );
                
@@ -26,6 +26,9 @@
                if ( $language ) {
                        $tables[] = "cn_notice_languages";
                }
+               if ( $location ) {
+                       $tables[] = "cn_notice_countries";
+               }
 
                // Use whatever conditional arguments got passed in
                if ( $project ) {
@@ -38,6 +41,10 @@
                if ( $preferred ) {
                        $conds[] = "not_preferred = 1";
                }
+               if ( $location ) {
+                       $conds[] = 'nc_notice_id = cn_notices.not_id',
+                       $conds[] = "(not_geo = 0) OR ((not_geo = 1) AND 
(nc_country = '$location'))",
+               }
                if ( !$date ) {
                        $date = $dbr->timestamp();
                }

Modified: trunk/extensions/CentralNotice/SpecialBannerListLoader.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerListLoader.php  2010-09-14 
18:30:19 UTC (rev 73002)
+++ trunk/extensions/CentralNotice/SpecialBannerListLoader.php  2010-09-14 
18:37:38 UTC (rev 73003)
@@ -64,7 +64,7 @@
 
                if ( $this->language == 'en' && $this->project != null ) {
                        // See if we have any preferred notices for all of en
-                       $notices = $this->centralNoticeDB->getNotices( '', 
'en', '', '', 1 );
+                       $notices = $this->centralNoticeDB->getNotices( '', 
'en', '', '', 1, $this->location );
 
                        if ( $notices ) {
                                // Pull out values
@@ -79,7 +79,7 @@
                }
 
                if ( !$templates && $this->project == 'wikipedia' ) {
-                       $notices = $this->centralNoticeDB->getNotices( 
'wikipedia', $this->language, '', '', 1 );
+                       $notices = $this->centralNoticeDB->getNotices( 
'wikipedia', $this->language, '', '', 1, $this->location );
                        if ( $notices ) ) {
                                foreach ( $notices as $notice => $val ) {
                                        $templates = 
$this->centralNoticeDB->selectTemplatesAssigned( $notice );



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to