Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -1081,9 +1081,12 @@ |
1082 | 1082 | public static function getNoticeId( $noticeName ) { |
1083 | 1083 | $dbr = wfGetDB( DB_SLAVE ); |
1084 | 1084 | $eNoticeName = htmlspecialchars( $noticeName ); |
1085 | | - $res = $dbr->select( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
1086 | | - $row = $dbr->fetchObject( $res ); |
1087 | | - return $row->not_id; |
| 1085 | + $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) ); |
| 1086 | + if ( $row ) { |
| 1087 | + return $row->not_id; |
| 1088 | + } else { |
| 1089 | + return; |
| 1090 | + } |
1088 | 1091 | } |
1089 | 1092 | |
1090 | 1093 | function getNoticeLanguages( $noticeName ) { |
— | — | @@ -1282,7 +1285,7 @@ |
1283 | 1286 | $oldLanguages = $this->getNoticeLanguages( $notice ); |
1284 | 1287 | |
1285 | 1288 | // Get the notice id |
1286 | | - $row = $dbw->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $notice ) ); |
| 1289 | + $row = $this->getNoticeId( $notice ); |
1287 | 1290 | |
1288 | 1291 | // Add newly assigned languages |
1289 | 1292 | $addLanguages = array_diff( $newLanguages, $oldLanguages ); |
— | — | @@ -1303,7 +1306,7 @@ |
1304 | 1307 | $dbw->commit(); |
1305 | 1308 | } |
1306 | 1309 | |
1307 | | - function dropDownList( $text, $values ) { |
| 1310 | + public static function dropDownList( $text, $values ) { |
1308 | 1311 | $dropDown = "* {$text}\n"; |
1309 | 1312 | foreach ( $values as $value ) { |
1310 | 1313 | $dropDown .= "**{$value}\n"; |
— | — | @@ -1335,18 +1338,26 @@ |
1336 | 1339 | function getQueryInfo() { |
1337 | 1340 | $notice = $this->mRequest->getVal( 'notice' ); |
1338 | 1341 | $noticeId = CentralNotice::getNoticeId( $notice ); |
1339 | | - // Return all the banners not already assigned to the current campaign |
1340 | | - return array( |
1341 | | - 'tables' => array( 'cn_assignments', 'cn_templates' ), |
1342 | | - 'fields' => array( 'cn_templates.tmp_name', 'cn_templates.tmp_id' ), |
1343 | | - 'conds' => array( 'cn_assignments.tmp_id IS NULL' ), |
1344 | | - 'join_conds' => array( |
1345 | | - 'cn_assignments' => array( |
1346 | | - 'LEFT JOIN', |
1347 | | - "cn_assignments.tmp_id = cn_templates.tmp_id AND cn_assignments.not_id = $noticeId" |
| 1342 | + if ( $noticeId ) { |
| 1343 | + // Return all the banners not already assigned to the current campaign |
| 1344 | + return array( |
| 1345 | + 'tables' => array( 'cn_assignments', 'cn_templates' ), |
| 1346 | + 'fields' => array( 'cn_templates.tmp_name', 'cn_templates.tmp_id' ), |
| 1347 | + 'conds' => array( 'cn_assignments.tmp_id IS NULL' ), |
| 1348 | + 'join_conds' => array( |
| 1349 | + 'cn_assignments' => array( |
| 1350 | + 'LEFT JOIN', |
| 1351 | + "cn_assignments.tmp_id = cn_templates.tmp_id AND cn_assignments.not_id = $noticeId" |
| 1352 | + ) |
1348 | 1353 | ) |
1349 | | - ) |
1350 | | - ); |
| 1354 | + ); |
| 1355 | + } else { |
| 1356 | + // Return all the banners in the database |
| 1357 | + return array( |
| 1358 | + 'tables' => 'cn_templates', |
| 1359 | + 'fields' => array( 'tmp_name', 'tmp_id' ), |
| 1360 | + ); |
| 1361 | + } |
1351 | 1362 | } |
1352 | 1363 | |
1353 | 1364 | /** |