Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -31,11 +31,10 @@ |
32 | 32 | if ( $language ) |
33 | 33 | $conds[] = "not_language =" . $dbr->addQuotes( $language ); |
34 | 34 | if ( $preferred ) |
35 | | - $conds[] = "not_preferred =" . $dbr->addQuotes( $preferred ); |
36 | | - |
| 35 | + $conds[] = "not_preferred = 1"; |
37 | 36 | $conds[] = ( $enabled ) ? "not_enabled = " . $dbr->addQuotes( $enabled ) : "not_enabled = " . $dbr->addQuotes( 1 ); |
38 | 37 | $conds[] = ( $date ) ? "not_start <= ". $dbr->addQuotes( $date ) : "not_start <= " . $dbr->addQuotes( $dbr->timestamp() ); |
39 | | - $conds[] = ( $date ) ? "not_end >= ". $dbr->addQuotes( $date ) : "not_end >= " . $dbr->addQuotes( $dbr->timestamp() ); |
| 38 | + $conds[] = ( $date ) ? "not_end >= " . $dbr->addQuotes( $date ) : "not_end >= " . $dbr->addQuotes( $dbr->timestamp() ); |
40 | 39 | |
41 | 40 | |
42 | 41 | // Pull db data |
— | — | @@ -45,6 +44,8 @@ |
46 | 45 | ), |
47 | 46 | array( |
48 | 47 | 'not_name', |
| 48 | + 'not_project', |
| 49 | + 'not_language', |
49 | 50 | 'not_locked', |
50 | 51 | 'not_enabled', |
51 | 52 | 'not_preferred', |
— | — | @@ -61,6 +62,8 @@ |
62 | 63 | // Loop through result set and return attributes |
63 | 64 | while ( $row = $dbr->fetchObject( $res ) ) { |
64 | 65 | $notice = $row->not_name; |
| 66 | + $notices[$notice]['project'] = $row->not_project; |
| 67 | + $notices[$notice]['language'] = $row->not_language; |
65 | 68 | $notices[$notice]['preferred'] = $row->not_preferred; |
66 | 69 | $notices[$notice]['locked'] = $row->not_locked; |
67 | 70 | $notices[$notice]['enabled'] = $row->not_enabled; |
Index: trunk/extensions/CentralNotice/SpecialNoticeText.php |
— | — | @@ -23,25 +23,25 @@ |
24 | 24 | |
25 | 25 | // Quick short circuit to be able to show preferred notices |
26 | 26 | $templates = array(); |
27 | | - if ( $this->language == 'en' ) { |
28 | | - // See if we have any preferred notices |
| 27 | + |
| 28 | + if ( $this->language == 'en' && $this->project != null ) { |
| 29 | + // See if we have any preferred notices for all of en |
29 | 30 | $notices = CentralNoticeDB::getNotices( '', 'en', '', '', 1 ); |
30 | | - if ( !$notices ) { |
31 | | - // If there were no preferred notices do a normal lookup for enabled |
32 | | - $notices = CentralNoticeDB::getNotices( '', 'en' ); |
33 | | - // Last ditch effort. Try to find an all match |
34 | | - if ( !$notices ) { |
35 | | - $notices = CentralNoticeDB::getNotices(); |
| 31 | + |
| 32 | + if ( $notices ) { |
| 33 | + // Pull out values |
| 34 | + foreach( $notices as $notice => $val ) { |
| 35 | + // Either match against ALL project or a specific project |
| 36 | + if ( $val['project'] == '' || $val['project'] == $this->project ) { |
| 37 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $notice ); |
| 38 | + break; |
| 39 | + } |
36 | 40 | } |
37 | 41 | } |
38 | | - // Pull the notice name |
39 | | - $notice = array_keys( $notices ); |
40 | | - // Pull the actual templates from only the first match |
41 | | - $templates = CentralNoticeDB::selectTemplatesAssigned( $notice[0] ); |
42 | | - } else { |
43 | | - // Continue as normal with non en notices |
44 | | - $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language ); |
45 | | - } |
| 42 | + } |
| 43 | + // Didn't find any preferred matches so do an old style lookup |
| 44 | + if ( !$templates ) |
| 45 | + $templates = CentralNotice::selectNoticeTemplates( $this->project, $this->language ); |
46 | 46 | |
47 | 47 | $templateNames = array_keys( $templates ); |
48 | 48 | |