Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | } |
20 | 20 | |
21 | 21 | /* |
22 | | - * Given a project/language and date range return all active notices. |
| 22 | + * Return notices in the system within given constraints |
23 | 23 | * Optional: return both enabled and disabled notices |
24 | 24 | */ |
25 | 25 | public function getNotices( $project = false, $language = false , $date = false , $enabled = true, $preferred = false ) { |
— | — | @@ -32,10 +32,12 @@ |
33 | 33 | $conds[] = "not_language =" . $dbr->addQuotes( $language ); |
34 | 34 | if ( $preferred ) |
35 | 35 | $conds[] = "not_preferred = 1"; |
| 36 | + if ( !date ) |
| 37 | + $date = wfTimestamp( TS_MW ); |
| 38 | + |
| 39 | + $conds[] = ( $date ) ? "not_start <= ". $dbr->addQuotes( $date ) : "not_start <= " . $dbr->addQuotes( $dbr->timestamp( $date ) ); |
| 40 | + $conds[] = ( $date ) ? "not_end >= " . $dbr->addQuotes( $date ) : "not_end >= " . $dbr->addQuotes( $dbr->timestamp( $date ) ); |
36 | 41 | $conds[] = ( $enabled ) ? "not_enabled = " . $dbr->addQuotes( $enabled ) : "not_enabled = " . $dbr->addQuotes( 1 ); |
37 | | - $conds[] = ( $date ) ? "not_start <= ". $dbr->addQuotes( $date ) : "not_start <= " . $dbr->addQuotes( $dbr->timestamp() ); |
38 | | - $conds[] = ( $date ) ? "not_end >= " . $dbr->addQuotes( $date ) : "not_end >= " . $dbr->addQuotes( $dbr->timestamp() ); |
39 | | - |
40 | 42 | |
41 | 43 | // Pull db data |
42 | 44 | $res = $dbr->select( |