? bug2077.patch
? core/.custom_function_api.php.swp
Index: config_defaults_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v
retrieving revision 1.341
diff -u -r1.341 config_defaults_inc.php
--- config_defaults_inc.php	28 Jun 2007 23:13:39 -0000	1.341
+++ config_defaults_inc.php	3 Jul 2007 22:12:40 -0000
@@ -1342,6 +1342,7 @@
 	$g_project_status_enum_string		= '10:development,30:release,50:stable,70:obsolete';
 	$g_project_view_state_enum_string	= '10:public,50:private';
 	$g_view_state_enum_string			= '10:public,50:private';
+	$g_news_view_state_enum_string		= '10:public,50:private,100:global';
 
 	$g_priority_enum_string				= '10:none,20:low,30:normal,40:high,50:urgent,60:immediate';
 	$g_severity_enum_string				= '10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block';
Index: main_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/main_page.php,v
retrieving revision 1.59
diff -u -r1.59 main_page.php
--- main_page.php	25 Apr 2006 13:18:27 -0000	1.59
+++ main_page.php	3 Jul 2007 22:12:40 -0000
@@ -66,8 +66,8 @@
 	for ( $i = 0; $i < $t_news_count; $i++ ) {
 		$t_row = $t_news_rows[$i];
 
-		# only show VS_PRIVATE posts to configured threshold and above
-		if ( ( VS_PRIVATE == $t_row[ 'view_state' ] ) &&
+		# only show NVS_PRIVATE posts to configured threshold and above
+		if ( ( NVS_PRIVATE == $t_row[ 'view_state' ] ) &&
 			 !access_has_project_level( config_get( 'private_news_threshold' ) ) ) {
 			continue;
 		}
@@ -98,4 +98,4 @@
 	echo '</div>';
 
 	html_page_bottom1( __FILE__ );
-?>
\ No newline at end of file
+?>
Index: news_edit_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/news_edit_page.php,v
retrieving revision 1.40
diff -u -r1.40 news_edit_page.php
--- news_edit_page.php	12 Feb 2005 20:01:06 -0000	1.40
+++ news_edit_page.php	3 Jul 2007 22:12:40 -0000
@@ -101,7 +101,7 @@
 	</td>
 	<td width="75%">
 		<select name="view_state">
-			<?php print_enum_string_option_list( 'view_state', $v_view_state ) ?>
+			<?php print_enum_string_option_list( 'news_view_state', $v_view_state ) ?>
 		</select>
 	</td>
 </tr>
Index: news_list_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/news_list_page.php,v
retrieving revision 1.31
diff -u -r1.31 news_list_page.php
--- news_list_page.php	12 Feb 2005 20:01:06 -0000	1.31
+++ news_list_page.php	3 Jul 2007 22:12:40 -0000
@@ -31,7 +31,7 @@
     # Loop through results
 	for ( $i=0 ; $i < sizeof( $rows ) ; $i++ ) {
 		extract( $rows[$i], EXTR_PREFIX_ALL, 'v' );
-		if ( VS_PRIVATE == $v_view_state &&
+		if ( NVS_PRIVATE == $v_view_state &&
 			 ! access_has_project_level( config_get( 'private_news_threshold' ), $v_project_id ) ) 		{
 			continue;
 		}
@@ -44,8 +44,8 @@
 		if ( 1 == $v_announcement ) {
 			array_push( $t_notes, lang_get( 'announcement' ) );
 		}
-		if ( VS_PRIVATE == $v_view_state ) {
-			array_push( $t_notes, lang_get( 'private' ) );
+		if ( NVS_PRIVATE == $v_view_state || NVS_GLOBAL == $v_view_state ) {
+			array_push( $t_notes, get_enum_element( 'news_view_state', $v_view_state ) );
 		}
 		if ( sizeof( $t_notes ) > 0 ) {
 			$t_note_string = '['.implode( ' ', $t_notes ).']';
Index: news_menu_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/news_menu_page.php,v
retrieving revision 1.33
diff -u -r1.33 news_menu_page.php
--- news_menu_page.php	20 Jul 2004 15:51:50 -0000	1.33
+++ news_menu_page.php	3 Jul 2007 22:12:41 -0000
@@ -57,7 +57,7 @@
 	</td>
 	<td width="75%">
 		<select name="view_state">
-			<?php print_enum_string_option_list( 'view_state' ) ?>
+			<?php print_enum_string_option_list( 'news_view_state' ) ?>
 		</select>
 	</td>
 </tr>
Index: news_rss.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/news_rss.php,v
retrieving revision 1.11
diff -u -r1.11 news_rss.php
--- news_rss.php	25 Apr 2006 13:18:27 -0000	1.11
+++ news_rss.php	3 Jul 2007 22:12:41 -0000
@@ -113,7 +113,7 @@
 
 		# skip news item if private, or
 		# belongs to a private project (will only happen
-		if ( VS_PRIVATE == $v_view_state ) {
+		if ( NVS_PRIVATE == $v_view_state ) {
 			continue;
 		}
 
Index: core/constant_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/constant_inc.php,v
retrieving revision 1.64
diff -u -r1.64 constant_inc.php
--- core/constant_inc.php	16 Jun 2007 23:04:33 -0000	1.64
+++ core/constant_inc.php	3 Jul 2007 22:12:41 -0000
@@ -87,6 +87,11 @@
 	define( 'VS_PUBLIC',	10 );
 	define( 'VS_PRIVATE',	50 );
 
+	# news view state
+	define( 'NVS_PUBLIC',	10 );
+	define( 'NVS_PRIVATE',	50 );
+	define( 'NVS_GLOBAL',  100 );
+
 	# direction
 	define( 'ASC',	101 );
 	define( 'DESC',	102 );
Index: core/news_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/news_api.php,v
retrieving revision 1.23
diff -u -r1.23 news_api.php
--- core/news_api.php	22 Jul 2005 15:34:03 -0000	1.23
+++ core/news_api.php	3 Jul 2007 22:12:41 -0000
@@ -85,6 +85,10 @@
 	function news_update( $p_news_id, $p_project_id, $p_view_state, $p_announcement, $p_headline, $p_body ) {
 		$c_news_id		= db_prepare_int( $p_news_id );
 		$c_project_id	= db_prepare_int( $p_project_id );
+		if ( ALL_PROJECTS == $p_project_id ) {
+			# Force global state when selectd project is "All projects" 
+			$p_view_state = NVS_GLOBAL;
+		}
 		$c_view_state	= db_prepare_int( $p_view_state );
 		$c_announcement	= db_prepare_bool( $p_announcement );
 		$c_headline		= db_prepare_string( $p_headline );
@@ -165,20 +169,16 @@
 		$t_projects = current_user_get_all_accessible_subprojects( $p_project_id );
 		$t_projects[] = $p_project_id;
 
-		if ( $p_sitewide && ALL_PROJECTS != $p_project_id ) {
-			$t_projects[] = ALL_PROJECTS;
-		}
-
 		$t_projects = array_map( 'db_prepare_int', $t_projects );
 
 		$query = "SELECT *
 				  FROM $t_news_table";
 
-		if ( 1 == count( $t_projects ) ) {
-			$c_project_id = $t_projects[0];
-			$query .= " WHERE project_id='$c_project_id'";
+		if ( 1 == count( $t_projects ) && ALL_PROJECTS == $t_projects[0] ) {
+			# when "All projects" is selected, leave the query as is
 		} else {
-			$query .= ' WHERE project_id IN (' . join( $t_projects, ',' ) . ')';
+			$query .= ' WHERE project_id IN (' . join( $t_projects, ',' ) . ')' .
+				' OR view_state=' . NVS_GLOBAL;
 		}
 
 		$query .= " ORDER BY date_posted DESC";
@@ -205,7 +205,7 @@
 	# --------------------
 	# Check if the specified news item is private
 	function news_is_private( $p_news_id ) {
-		return ( news_get_field( $p_news_id, 'view_state' ) == VS_PRIVATE );
+		return ( news_get_field( $p_news_id, 'view_state' ) == NVS_PRIVATE );
 	}
 	# --------------------
 	# Gets a limited set of news rows to be viewed on one page based on the criteria
@@ -217,11 +217,9 @@
 
 		$c_offset		= db_prepare_int( $p_offset );
 
+		#@@@ what happens here when $p_project_id is ALL_PROJECTS ( == 0) ?
 		$t_projects = current_user_get_all_accessible_subprojects( $p_project_id );
 		$t_projects[] = $p_project_id;
-		if ( ALL_PROJECTS != $p_project_id ) {
-			$t_projects[] = ALL_PROJECTS;
-		}
 
 		$t_projects = array_map( 'db_prepare_int', $t_projects );
 
@@ -229,40 +227,24 @@
 		$t_news_view_limit		= config_get( 'news_view_limit' );
 		$t_news_view_limit_days = config_get( 'news_view_limit_days' );
 
-		switch ( config_get( 'news_limit_method' ) ) {
-			case 0 :
-				# BY_LIMIT - Select the news posts
-				$query = "SELECT *
-						FROM $t_news_table";
-
-				if ( 1 == count( $t_projects ) ) {
-					$c_project_id = $t_projects[0];
-					$query .= " WHERE project_id='$c_project_id'";
-				} else {
-					$query .= ' WHERE project_id IN (' . join( $t_projects, ',' ) . ')';
-				}
-
-				$query .= ' ORDER BY announcement DESC, id DESC';
-				$result = db_query( $query , $t_news_view_limit , $c_offset);
-				break;
-			case 1 :
-				# BY_DATE - Select the news posts
-				$query = "SELECT *
-						FROM $t_news_table";
-
-				if ( 1 == count( $t_projects ) ) {
-					$c_project_id = $t_projects[0];
-					$query .= " WHERE project_id='$c_project_id'";
-				} else {
-					$query .= ' WHERE project_id IN (' . join( $t_projects, ',' ) . ')';
-				}
-
-				$query .= " AND " . db_helper_compare_days( db_now(), 'date_posted', "< $t_news_view_limit_days") .
-						  " OR  announcement = 1
-						ORDER BY announcement DESC, id DESC";
-				$result = db_query( $query, $t_news_view_limit, $c_offset );
-				break;
-		} # end switch
+		$query = "SELECT * " .
+			 "FROM $t_news_table ";
+
+		if ( 1 == count( $t_projects ) && ALL_PROJECTS == $t_projects[0] ) {
+			# when "All projects" is selected, leave the query as is
+		} else {
+			$query .= 'WHERE project_id IN (' . join( $t_projects, ',' ) . ')' .
+				' OR view_state=' . NVS_GLOBAL;
+		}
+
+		if ( BY_DATE == config_get( 'news_limit_method' ) ) {
+			$query .= " AND " . db_helper_compare_days( db_now(), 'date_posted', "< $t_news_view_limit_days") .
+			" OR  announcement = 1"; 
+		}
+	
+		$query .= ' ORDER BY announcement DESC, id DESC';
+
+		$result = db_query( $query, $t_news_view_limit, $c_offset );
 
 		$t_row_count = db_num_rows( $result );
 
Index: core/print_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v
retrieving revision 1.166
diff -u -r1.166 print_api.php
--- core/print_api.php	9 Jun 2007 16:39:32 -0000	1.166
+++ core/print_api.php	3 Jul 2007 22:12:42 -0000
@@ -267,7 +267,7 @@
 			if ( 1 == $v_announcement ) {
 				array_push( $t_notes, lang_get( 'announcement' ) );
 			}
-			if ( VS_PRIVATE == $v_view_state ) {
+			if ( NVS_PRIVATE == $v_view_state ) {
 				array_push( $t_notes, lang_get( 'private' ) );
 			}
 			if ( sizeof( $t_notes ) > 0 ) {
@@ -283,7 +283,7 @@
 		$t_body = string_display_links( $p_body );
 		$t_date_posted = date( config_get( 'normal_date_format' ), $p_date_posted );
 
-		if ( VS_PRIVATE == $p_view_state ) {
+		if ( NVS_PRIVATE == $p_view_state ) {
 			$t_news_css = 'news-heading-private';
 		} else {
 			$t_news_css = 'news-heading-public';
@@ -306,8 +306,8 @@
 		if ( 1 == $p_announcement ) {
 			$output .= '[' . lang_get( 'announcement' ) . ']';
 		}
-		if ( VS_PRIVATE == $p_view_state ) {
-			$output .= '[' . lang_get( 'private' ) . ']';
+		if ( NVS_PRIVATE == $p_view_state || NVS_GLOBAL == $p_view_state ) {
+			$output .= '[' . get_enum_element( 'news_view_state', $p_view_state ) . ']';
 		}
 
 		$output .= '</span>';
@@ -334,8 +334,8 @@
 	function print_news_string_by_news_id( $p_news_id ) {
 		$row = news_get_row( $p_news_id );
 
-		# only show VS_PRIVATE posts to configured threshold and above
-		if ( ( VS_PRIVATE == $row['view_state'] ) &&
+		# only show NVS_PRIVATE posts to configured threshold and above
+		if ( ( NVS_PRIVATE == $row['view_state'] ) &&
 			 !access_has_project_level( config_get( 'private_news_threshold' ) ) ) {
 			continue;
 		}
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.298
diff -u -r1.298 strings_english.txt
--- lang/strings_english.txt	23 Jun 2007 03:21:45 -0000	1.298
+++ lang/strings_english.txt	3 Jul 2007 22:12:44 -0000
@@ -295,6 +295,7 @@
 $s_project_status_enum_string = '10:development,30:release,50:stable,70:obsolete';
 $s_project_view_state_enum_string = '10:public,50:private';
 $s_view_state_enum_string = '10:public,50:private';
+$s_news_view_state_enum_string = '10:public,50:private,100:global';
 
 $s_priority_enum_string = '10:none,20:low,30:normal,40:high,50:urgent,60:immediate';
 $s_severity_enum_string = '10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block';
