View Issue Details

IDProjectCategoryView StatusLast Update
0005888mantisbtbugtrackerpublic2005-07-23 02:08
Reporterhgaland Assigned Tothraxisp  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.0a3 
Fixed in Version1.0.0rc1 
Summary0005888: error in user_get_accessible_projects
Description
When you have a project hierarchy like
0 (ALL_PROJECTS)
+--P1
+-SP11 +-SP12
+--P2 +-SP21 +-SP22

+--P3
| +-SP31
| +-SP32

and call user_get_accessible_projects for a user that have access_has_global_level private_project_threshold

you get the wrong list of projects (P1, P2, P3 instead of all)

Additional Information

correction seems to be in user_api.php

function user_get_accessible_projects( $p_user_id, $p_show_disabled = false ) {
global $g_user_accessible_projects_cache;

if ( null != $g_user_accessible_projects_cache
     && auth_get_current_user_id() == $p_user_id 
     && false == $p_show_disabled ) {
    return $g_user_accessible_projects_cache;
}

if ( access_has_global_level( config_get( 'private_project_threshold' ), $p_user_id ) ) {

/
[replace]
$t_projects = project_hierarchy_get_subprojects( ALL_PROJECTS, $p_show_disabled );
[by]
/
$t_projects = project_hierarchy_get_all_subprojects( ALL_PROJECTS );
} else {

TagsNo tags attached.
Attached Files
Modifications_graph_api.php.delta (4,405 bytes)   
********
  		$t_user_id = auth_get_current_user_id();
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
342a343
> 			/* Bug in project list
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
343a345,351
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' AND (project_id='. implode( ' OR project_id=', $t_acc
  		} else {
  			$specific_where = " AND project_id='$t_project_id'";
********
  
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
376a385
> 			/* Bug in project list
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
377a387,393
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' AND (project_id='. implode( ' OR project_id=', $t_acc
  		} else {
  			$specific_where = " AND project_id='$t_project_id'";
********
  
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
427a444
> 			/* Bug in project list
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
428a446,452
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' AND (project_id='. implode( ' OR project_id=', $t_acc
  		} else {
  			$specific_where = " AND project_id='$t_project_id'";
********
  
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
496a521
> 			/* Bug in project list
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
497a523,529
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' AND (project_id='. implode( ' OR project_id=', $t_acc
  		} else {
  			$specific_where = " AND project_id='$t_project_id'";
********
  
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
551a584
> 			/* Bug in project list 
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
552a586,592
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' (project_id='. implode( ' OR project_id=', $t_accessi
  		} else {
  			$specific_where = " project_id='$t_project_id'";
********
  
  		if ( ALL_PROJECTS == $t_project_id ) {
  			# Only projects to which the user have access
614a655
> 			/* Bug in project list
  			$t_accessible_projects_array = user_get_accessible_projects( $t_user_id )
615a657,663
> 			*/
> 			$t_topprojects = $t_accessible_projects_array = user_get_accessible_proje
> 			foreach ( $t_topprojects as $t_project ) {
> 				$t_accessible_projects_array = array_merge( $t_accessible_projects_array
> 			}
> 			$t_accessible_projects_array = array_unique( $t_accessible_projects_array
> 			# Bug in project list
  			$specific_where = ' (project_id='. implode( ' OR project_id=', $t_accessi
  		} else {
  			$specific_where = " project_id='$t_project_id'";

Relationships

related to 0005914 closedthraxisp My View doesnt list assigned bugs of child projects 

Activities

hgaland

hgaland

2005-07-11 05:27

reporter   ~0010708

I detected this problem while testing graphes. When on all_projects, the graph shows only data from the projects directly under the root project (ALL_PROJECTS) and not sub-projects.

The proposed correction in additional notes does not work because it indeeds a side effect in the drop down box for project selection (sub projects are duplicated)

Do you have another solution ?????

hgaland

hgaland

2005-07-11 06:18

reporter   ~0010709

The problem was in fact in the Graph_api which does not include all subprojects.

Can you include the attached correction in standard release ???

Best regards

thraxisp

thraxisp

2005-07-22 12:20

reporter   ~0010924

This was fixed as part of the related issue.

core/graph_api.php -> 1.31