Index: trunk/extensions/CentralNotice/SpecialBannerListLoader.php |
— | — | @@ -56,32 +56,18 @@ |
57 | 57 | * Generate JSON for the specified site |
58 | 58 | */ |
59 | 59 | function getJsonList() { |
60 | | - |
61 | | - // Quick short circuit to be able to show preferred notices |
62 | 60 | $templates = array(); |
63 | | - |
64 | | - if ( $this->language == 'en' && $this->project != null ) { |
65 | | - // See if we have any preferred notices for all of en |
66 | | - $notices = CentralNoticeDB::getNotices( null, 'en', null, 1, 1, $this->location ); |
67 | | - |
68 | | - if ( $notices ) { |
69 | | - // Pull banners |
70 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notices ); |
71 | | - } |
| 61 | + |
| 62 | + // See if we have any preferred campaigns for this language and project |
| 63 | + $notices = CentralNoticeDB::getNotices( $this->project, $this->language, null, 1, 1, $this->location ); |
| 64 | + |
| 65 | + // Quick short circuit to show preferred campaigns |
| 66 | + if ( $notices ) { |
| 67 | + // Pull banners |
| 68 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $notices ); |
72 | 69 | } |
73 | 70 | |
74 | | - if ( !$templates && $this->project == 'wikipedia' ) { |
75 | | - // See if we have any preferred notices for this language wikipedia |
76 | | - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, |
77 | | - false, 1, 1, $this->location ); |
78 | | - |
79 | | - if ( $notices ) { |
80 | | - // Pull banners |
81 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notices ); |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - // Didn't find any preferred matches so do an old style lookup |
| 71 | + // Didn't find any preferred banners so do an old style lookup |
86 | 72 | if ( !$templates ) { |
87 | 73 | $templates = CentralNotice::selectNoticeTemplates( |
88 | 74 | $this->project, $this->language, $this->location ); |
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -1070,6 +1070,7 @@ |
1071 | 1071 | $campaignResults1 = $dbr->select( |
1072 | 1072 | array( |
1073 | 1073 | 'cn_notices', |
| 1074 | + 'cn_notice_projects', |
1074 | 1075 | 'cn_notice_languages' |
1075 | 1076 | ), |
1076 | 1077 | array( |
— | — | @@ -1080,9 +1081,10 @@ |
1081 | 1082 | "not_end >= $encTimestamp", |
1082 | 1083 | 'not_enabled = 1', // enabled |
1083 | 1084 | 'not_geo = 0', // not geotargeted |
| 1085 | + 'np_notice_id = cn_notices.not_id', |
| 1086 | + 'np_project' => $project, |
1084 | 1087 | 'nl_notice_id = cn_notices.not_id', |
1085 | | - 'nl_language' => $language, |
1086 | | - 'not_project' => array( '', $project ) |
| 1088 | + 'nl_language' => $language |
1087 | 1089 | ), |
1088 | 1090 | __METHOD__ |
1089 | 1091 | ); |
— | — | @@ -1100,6 +1102,7 @@ |
1101 | 1103 | $campaignResults2 = $dbr->select( |
1102 | 1104 | array( |
1103 | 1105 | 'cn_notices', |
| 1106 | + 'cn_notice_projects', |
1104 | 1107 | 'cn_notice_languages', |
1105 | 1108 | 'cn_notice_countries' |
1106 | 1109 | ), |
— | — | @@ -1113,9 +1116,10 @@ |
1114 | 1117 | 'not_geo = 1', // geotargeted |
1115 | 1118 | 'nc_notice_id = cn_notices.not_id', |
1116 | 1119 | 'nc_country' => $location, |
| 1120 | + 'np_notice_id = cn_notices.not_id', |
| 1121 | + 'np_project' => $project, |
1117 | 1122 | 'nl_notice_id = cn_notices.not_id', |
1118 | | - 'nl_language' => $language, |
1119 | | - 'not_project' => array( '', $project ) |
| 1123 | + 'nl_language' => $language |
1120 | 1124 | ), |
1121 | 1125 | __METHOD__ |
1122 | 1126 | ); |
Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -27,17 +27,23 @@ |
28 | 28 | } |
29 | 29 | |
30 | 30 | $tables = array( 'cn_notices' ); |
| 31 | + if ( $project ) { |
| 32 | + $tables[] = 'cn_notice_projects'; |
| 33 | + } |
31 | 34 | if ( $language ) { |
32 | 35 | $tables[] = 'cn_notice_languages'; |
33 | 36 | } |
34 | 37 | |
35 | 38 | $conds = array( |
36 | | - 'not_project' => array( '', $project ), |
37 | 39 | 'not_geo' => 0, |
38 | 40 | "not_start <= $encTimestamp", |
39 | 41 | "not_end >= $encTimestamp", |
40 | 42 | ); |
41 | 43 | // Use whatever conditional arguments got passed in |
| 44 | + if ( $project ) { |
| 45 | + $conds[] = 'np_notice_id = cn_notices.not_id'; |
| 46 | + $conds['np_project'] = $project; |
| 47 | + } |
42 | 48 | if ( $language ) { |
43 | 49 | $conds[] = 'nl_notice_id = cn_notices.not_id'; |
44 | 50 | $conds['nl_language'] = $language; |
— | — | @@ -65,19 +71,25 @@ |
66 | 72 | // If a location is passed, also pull geotargeted campaigns that match the location |
67 | 73 | if ( $location ) { |
68 | 74 | $tables = array( 'cn_notices', 'cn_notice_countries' ); |
| 75 | + if ( $project ) { |
| 76 | + $tables[] = 'cn_notice_projects'; |
| 77 | + } |
69 | 78 | if ( $language ) { |
70 | 79 | $tables[] = 'cn_notice_languages'; |
71 | 80 | } |
72 | 81 | |
73 | 82 | // Use whatever conditional arguments got passed in |
74 | 83 | $conds = array( |
75 | | - 'not_project' => array( '', $project ), |
76 | 84 | 'not_geo' => 1, |
77 | 85 | 'nc_notice_id = cn_notices.not_id', |
78 | 86 | 'nc_country' => $location, |
79 | 87 | "not_start <= $encTimestamp", |
80 | 88 | "not_end >= $encTimestamp", |
81 | 89 | ); |
| 90 | + if ( $project ) { |
| 91 | + $conds[] = 'np_notice_id = cn_notices.not_id'; |
| 92 | + $conds['np_project'] = $project; |
| 93 | + } |
82 | 94 | if ( $language ) { |
83 | 95 | $conds[] = "nl_notice_id = cn_notices.not_id"; |
84 | 96 | $conds['nl_language'] = $language; |