From: <gi...@ma...> - 2011-07-12 10:08:56
|
The branch, master has been updated via 332233868199e4a5b3db7bf6e7c7ce1eebbca8c8 (commit) via 344e4409490bce1dd3e50ab6bcb7fb3929a699df (commit) from 21c242c6b2b2b1ea1866258d665ba57820fc8f44 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 332233868199e4a5b3db7bf6e7c7ce1eebbca8c8 Author: Damien Regad <dam...@me...> Date: Thu Jun 23 18:25:06 2011 +0200 Fix #12259: select user's default project when it's a subproject Function helper_get_current_project_trace did not properly build the project hierarchy when initializing the array from the user's preferences Signed-off-by: David Hicks <d...@hx...> commit 344e4409490bce1dd3e50ab6bcb7fb3929a699df Author: Damien Regad <dam...@me...> Date: Thu Jun 23 18:18:25 2011 +0200 Added new API function project_hierarchy_get_parent Returns the id of the project's parent, or 0 (ALL_PROJECTS) if project is top-level or not found Also fix wrong type in comment for function project_hierarchy_is_toplevel, parameter $p_project_id Signed-off-by: David Hicks <d...@hx...> ----------------------------------------------------------------------- Summary of changes: core/helper_api.php | 10 ++++++++++ core/project_hierarchy_api.php | 26 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-) ----------------------------------------------------------------------- commit 332233868199e4a5b3db7bf6e7c7ce1eebbca8c8 Author: Damien Regad <dam...@me...> Date: Thu Jun 23 18:25:06 2011 +0200 Fix #12259: select user's default project when it's a subproject Function helper_get_current_project_trace did not properly build the project hierarchy when initializing the array from the user's preferences Signed-off-by: David Hicks <d...@hx...> diff --git a/core/helper_api.php b/core/helper_api.php index b3404ce..56c1803 100644 --- a/core/helper_api.php +++ b/core/helper_api.php @@ -340,9 +340,19 @@ function helper_get_current_project_trace() { if( null === $t_project_id ) { $t_bottom = current_user_get_pref( 'default_project' ); + $t_parent = $t_bottom; $t_project_id = Array( $t_bottom, ); + + while( true ) { + $t_parent = project_hierarchy_get_parent( $t_parent ); + if( 0 == $t_parent ) { + break; + } + array_unshift($t_project_id, $t_parent); + } + } else { $t_project_id = explode( ';', $t_project_id ); $t_bottom = $t_project_id[count( $t_project_id ) - 1]; commit 344e4409490bce1dd3e50ab6bcb7fb3929a699df Author: Damien Regad <dam...@me...> Date: Thu Jun 23 18:18:25 2011 +0200 Added new API function project_hierarchy_get_parent Returns the id of the project's parent, or 0 (ALL_PROJECTS) if project is top-level or not found Also fix wrong type in comment for function project_hierarchy_is_toplevel, parameter $p_project_id Signed-off-by: David Hicks <d...@hx...> diff --git a/core/project_hierarchy_api.php b/core/project_hierarchy_api.php index 8334791..fcf0001 100644 --- a/core/project_hierarchy_api.php +++ b/core/project_hierarchy_api.php @@ -120,7 +120,7 @@ function project_hierarchy_remove_all( $p_project_id ) { /** * Returns true if project is at top of hierarchy - * @param bool $p_project_id Project ID + * @param int $p_project_id Project ID * @param bool $p_show_disabled Whether or not to consider projects which are disabled * @return bool */ @@ -137,6 +137,30 @@ function project_hierarchy_is_toplevel( $p_project_id, $p_show_disabled = false } /** + * Returns the id of the project's parent (0 if top-level or not found) + * @param int $p_project_id Project ID + * @param bool $p_show_disabled Whether or not to consider projects which are disabled + * @return int + */ +function project_hierarchy_get_parent( $p_project_id, $p_show_disabled = false ) { + global $g_cache_project_hierarchy; + + project_hierarchy_cache( $p_show_disabled ); + + if( ALL_PROJECTS == $p_project_id ) { + return 0; + } + + foreach( $g_cache_project_hierarchy as $key => $value ) { + if( in_array( $p_project_id, $g_cache_project_hierarchy[$key] ) ) { + return $key; + } + } + + return 0; +} + +/** * Cache project hierarchy * @param bool $p_show_disabled Whether or not to cache projects which are disabled * @return bool ----------------------------------------------------------------------- -- Mantis Bug Tracker |