r44357 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44356‎ | r44357 | r44358 >
Date:20:19, 9 December 2008
Author:tomasz
Status:ok
Tags:
Comment:
changing to single call for date
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -18,7 +18,7 @@
1919 }
2020
2121 /*
22 - * Given a project/language and date range return all active notices.
 22+ * Return notices in the system within given constraints
2323 * Optional: return both enabled and disabled notices
2424 */
2525 public function getNotices( $project = false, $language = false , $date = false , $enabled = true, $preferred = false ) {
@@ -32,10 +32,12 @@
3333 $conds[] = "not_language =" . $dbr->addQuotes( $language );
3434 if ( $preferred )
3535 $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 ) );
3641 $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 -
4042
4143 // Pull db data
4244 $res = $dbr->select(

Status & tagging log