View Issue Details

IDProjectCategoryView StatusLast Update
0002077mantisbtnewspublic2014-01-23 04:43
Reportervboctor Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionwon't fix 
Summary0002077: Project news not visible site wide
Description

Currently a manager can post news for the managed projects but not to site-wide (all projects). Admins are the only ones who can post to site-wide. It would be good if there is a configurable option that makes "All Products" also show the news for all the products to which the logged in user is a viewer or for public projects. Of course this will be limited by the configured news limits.

Additional Information

The current behaviour is that site wide news are viewable when any project or all projects is selected, but project specific news is only visible when the corresponding project is selected.

TagsNo tags attached.
Attached Files
bug2077.patch (12,041 bytes)   
? 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';
bug2077.patch (12,041 bytes)   

Relationships

related to 0005505 closedvboctor All Projects issue... 
related to 0002699 closedgrangeway News related to a project should have a different colored title 

Activities

giallu

giallu

2007-07-03 18:22

reporter   ~0014860

The attached patch should solve this issue. Basically, what I've done
is:

  1. defined 3 new constants specific for the news view states (public,
    private, and a new one, global) along with the corresponding enum
    strings

  2. replaced all references to the old constants, where used in the
    context of news, with new ones

  3. reworked the queries for reading the news set so that:
    a. with a project selected, show all news from the project + global news
    b. with "All projects" selected, show all news from all projects

giallu

giallu

2007-07-04 02:58

reporter   ~0014862

Transcript of a chat with Victor (vboctor), small typos fixed:

Victor: I am not sure I agree with your proposed solution for the news.
Did you consider using a different project id instead of a different view state?
12:28 AM me: yes.
but the problem is you really want to have a project issue that escalate to a global status
12:29 AM not vice-versa
Victor: How about a flag that is similar to announcement.
me: also considered, and was more attractive than using a project id
12:30 AM Victor: any reason why you didn't go with a flag?
bool global
me: no schema changes
Victor: I am ok with a schema change if it makes sense.
me: easier to code, easier upgrade
Victor: otherwise the view state will have to be private-global, private, public-global, public.
12:31 AM me: I thought about that but the question is:
does private-global make sense?
12:32 AM and global implies public
all in all, if you foresee we will be asked to support private-global news
I agree for the schema change
12:33 AM otherwise, I'd prefer the current solution
which is also toward solving 0006919 :)

vboctor

vboctor

2007-07-05 19:04

manager   ~0014879

As per our discussion earlier, I do no think it is wise to allow a manager of a project to post news on other projects. What we can do is to have a threshold that once a user has can post site-wide news. Not sure if we currently support that or we only allow it for Admin.

ccruzmoncada

ccruzmoncada

2008-08-26 17:52

reporter   ~0019248

There is an enumeration for project_view_status but the project pages seem to be using the view_status instead. I modified the project_view_status enum in Config_inc.php (removing the public option to enforce all projects to be created as private) and patched manage_proj_Create_page.php and manage_proj_edit_page.php to use the correct enumeration. I did thatbefore actually checking this issue. Is there a better way to do this? The patch in the attachment seemed a bit complicated and over my head (I am not a php programmer).

atrol

atrol

2013-08-16 12:43

developer   ~0037886

Removed assignment. giallu will not contribute to this issue in near future.

vboctor

vboctor

2014-01-13 02:36

manager   ~0039033

The news feature has been deprecated.