Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -132,37 +132,36 @@ |
133 | 133 | $templates = array(); |
134 | 134 | |
135 | 135 | if ( $campaigns ) { |
136 | | - // Pull templates based on join with assignments |
137 | | - $res = $dbr->select( |
138 | | - array( |
139 | | - 'cn_notices', |
140 | | - 'cn_assignments', |
141 | | - 'cn_templates' |
142 | | - ), |
143 | | - array( |
144 | | - 'tmp_name', |
145 | | - 'SUM(tmp_weight) AS total_weight', |
146 | | - 'tmp_display_anon', |
147 | | - 'tmp_display_account' |
148 | | - ), |
149 | | - array( |
150 | | - 'cn_notices.not_id' => $campaigns, |
151 | | - 'cn_notices.not_id = cn_assignments.not_id', |
152 | | - 'cn_assignments.tmp_id = cn_templates.tmp_id' |
153 | | - ), |
154 | | - __METHOD__, |
155 | | - array( |
156 | | - 'GROUP BY' => 'tmp_name' |
157 | | - ) |
158 | | - ); |
159 | | - |
160 | | - foreach ( $res as $row ) { |
161 | | - $templates[] = array( |
162 | | - 'name' => $row->tmp_name, |
163 | | - 'weight' => intval( $row->total_weight ), |
164 | | - 'display_anon' => intval( $row->tmp_display_anon ), |
165 | | - 'display_account' => intval( $row->tmp_display_account ), |
| 136 | + foreach ( $campaigns as $campaignId ) { |
| 137 | + $res = $dbr->select( |
| 138 | + array( |
| 139 | + 'cn_notices', |
| 140 | + 'cn_assignments', |
| 141 | + 'cn_templates' |
| 142 | + ), |
| 143 | + array( |
| 144 | + 'tmp_name', |
| 145 | + 'tmp_weight', |
| 146 | + 'tmp_display_anon', |
| 147 | + 'tmp_display_account' |
| 148 | + ), |
| 149 | + array( |
| 150 | + 'cn_notices.not_id' => $campaignId, |
| 151 | + 'cn_notices.not_id = cn_assignments.not_id', |
| 152 | + 'cn_assignments.tmp_id = cn_templates.tmp_id' |
| 153 | + ), |
| 154 | + __METHOD__ |
166 | 155 | ); |
| 156 | + |
| 157 | + foreach ( $res as $row ) { |
| 158 | + $templates[] = array( |
| 159 | + 'name' => $row->tmp_name, |
| 160 | + 'weight' => intval( $row->tmp_weight ), |
| 161 | + 'display_anon' => intval( $row->tmp_display_anon ), |
| 162 | + 'display_account' => intval( $row->tmp_display_account ), |
| 163 | + 'campaign' => CentralNotice::getNoticeName( $campaignId ), |
| 164 | + ); |
| 165 | + } |
167 | 166 | } |
168 | 167 | } |
169 | 168 | return $templates; |