View Issue Details

IDProjectCategoryView StatusLast Update
0004768mantisbtfeaturepublic2014-11-20 16:54
Reportermasc Assigned Toatrol  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionduplicate 
PlatformX86OSWindowsOS VersionWin2K
Summary0004768: States transitions diagram
Description

I designed a script to graph the whole transitions automa based on the same graphviz_api we use to graph the relationships.
The script creates a graph for each access level (from viewer to manager) in order to give evidence of what transition an user can perform or not based on his access level. The grey arrows mean transitions not allowed for that access level but foreseen (i.e. allowed for a greater access level). The black arrows mean transitions allowed. The blu arrows are just to highlight the "reopen" transitions.

It's just a draft and I would like to have some feedback from you in order to improve it. Just copy the files and call the adm_status_automa.php

TagsNo tags attached.
Attached Files
adm_status_automa.php_ (2,055 bytes)   
<?php
	# Mantis - a php based bugtracking system
	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
	# This program is distributed under the terms and conditions of the GPL
	# See the README and LICENSE files for details

	# --------------------------------------------------------
	# $Id: $
	# --------------------------------------------------------

	# ======================================================================
	# Author: Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
	# ======================================================================

	require_once( 'core.php' );

	$t_core_path = config_get( 'core_path' );

	auth_ensure_user_authenticated();

	compress_enable();

	html_page_top1();
	html_page_top2();

	$t_access_levels = explode_enum_string( config_get( 'access_levels_enum_string' ) );

	echo '<br><br><div align="center">' . "\n";
	echo '<table class="hide" border="0" cellspacing="3" cellpadding="0">' . "\n";

	$t_flag = false;
	foreach( $t_access_levels as $t_access_level ) {
		list( $t_access_level_id, $t_access_level_label ) = explode_enum_arr( $t_access_level );
		if( $t_access_level_id >= ADMINISTRATOR )
			continue;
		$t_access_level_label = get_enum_element( 'access_levels', $t_access_level_id );

		if( !$t_flag) echo '<tr>';
		echo '<td valign="top" width="50%">' . "\n";
		echo '<table class="width100" cellspacing="1"><tr><td class="form-title" style="text-align:center">' . strtoupper( $t_access_level_label );
		if( $t_access_level_id == current_user_get_access_level() ) echo ' (' . lang_get( 'myself' ) . ')';
		echo '</td></tr>';
		echo '<td style="text-align:center"><img src="adm_status_automa_img.php?access=' . $t_access_level_id . '" vspace=20></td></tr>';
		echo '</table>' . "\n";
		echo '</td>' . "\n";
		if( $t_flag) echo '</tr>' . "\n";
		$t_flag = !$t_flag;
	}
	echo '</table></div>' . "\n";

	html_page_bottom1( __FILE__ );
?>
adm_status_automa.php_ (2,055 bytes)   
adm_status_automa_img.php_ (4,325 bytes)   
<?php
	# Mantis - a php based bugtracking system
	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
	# This program is distributed under the terms and conditions of the GPL
	# See the README and LICENSE files for details

	# --------------------------------------------------------
	# $Id: $
	# --------------------------------------------------------

	# ======================================================================
	# Author: Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
	# ======================================================================

	require_once( 'core.php' );

	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path . 'graphviz_api.php' );

	compress_enable();

	$f_access_level = gpc_get_int( 'access', VIEWER );

	$t_enum_status = config_get( 'status_enum_string' );
	$t_enum_workflow = config_get( 'status_enum_workflow' );
	$t_reopen = config_get( 'bug_reopen_status' );
	$t_thresh_array = config_get( 'set_status_threshold' );
	$t_bug_submit_status = config_get( 'bug_submit_status' );
	$t_bug_readonly_status_threshold = config_get( 'bug_readonly_status_threshold' );
	$t_reopen_bug_threshold = config_get( 'reopen_bug_threshold' );
	$t_bug_reopen_status = config_get( 'bug_reopen_status' );

	$t_graph_fontname	= config_get( 'relationship_graph_fontname' );
	$t_graph_fontsize	= config_get( 'relationship_graph_fontsize' );
	$t_graph_fontpath	= config_get( 'relationship_graph_fontpath' );
	$t_dot_tool			= config_get( 'dot_tool' );

	$t_graph_attributes	= array ( );

	if ( !empty( $t_graph_fontpath ) )
		$t_graph_attributes['fontpath'] = $t_graph_fontpath;

	$t_graph = new Digraph( 'STATES', $t_graph_attributes, $t_dot_tool );

	$t_graph->set_default_node_attr( array (
		'fontname'	=> $t_graph_fontname,
		'fontsize'	=> $t_graph_fontsize,
		'shape'		=> 'record',
		'style'		=> 'filled',
		'height'	=> '0.2',
		'width'		=> '0.4'
	) );

	$t_graph->set_default_edge_attr( array (
		'fontname'	=> $t_graph_fontname,
		'fontsize'	=> $t_graph_fontsize,
		'style'		=> 'solid',
		'color'		=> '#000000',
		'dir'		=> 'forward'
	) );

	$t_status_arr  = explode_enum_string( $t_enum_status );

	foreach ( $t_status_arr as $t_status ) {
		list( $t_status_id, $t_status_label ) = explode_enum_arr( $t_status );
		$t_status_label = get_enum_element( 'status', $t_status_id );

		$t_node_attributes = array ( );
		$t_node_attributes['label'] = $t_status_label;
		if( $t_bug_submit_status == $t_status_id || $t_bug_readonly_status_threshold <= $t_status_id ) {
			# submit status with bold border
			$t_node_attributes['style'] = 'bold, filled';
		}
		else {
			$t_node_attributes['style'] = 'filled';
		}
		$t_node_attributes['color'] = 'black';
		$t_node_attributes['fillcolor']	= get_status_color( $t_status_id );
		$t_node_attributes['URL']	= '';
		$t_node_attributes['tooltip']	= '';
		$t_graph->add_node( $t_status_id, $t_node_attributes );

		if( isset( $t_enum_workflow[$t_status_id] ) ) {
			$t_next_arr = explode_enum_string( $t_enum_workflow[$t_status_id] );
			foreach ( $t_next_arr as $t_next ) {
				if ( !is_blank( $t_next ) ) {
					list( $t_next_id, $t_next_label ) = explode_enum_arr( $t_next );

					# link  to itself
					if( $t_status_id == $t_next_id )
						continue;

					if( access_get_status_threshold( $t_next_id ) <= $f_access_level ) {
						$t_color = '#000000';
					}
					else {
						$t_color = '#C0C0C0';
					}

					$t_graph->add_edge( $t_status_id, $t_next_id, array ( 'style' => 'solid', 'color' => $t_color, 'dir' => 'forward' ) );
				}
			}
		}
	}

	# add user defined arcs and implicit reopen arcs
	foreach ( $t_status_arr as $t_status ) {
		list( $t_status_id, $t_status_label ) = explode_enum_arr( $t_status );
		if ( $t_status_id >= $t_bug_readonly_status_threshold ) {
			if( access_get_status_threshold( $t_bug_reopen_status ) <= $f_access_level ) {
				$t_color = '#0000ff';
			}
			else {
				$t_color = '#C0C0C0';
			}

			$t_graph->add_edge( $t_status_id, $t_bug_reopen_status, array ( 'style' => 'solid', 'color' => $t_color, 'dir' => 'forward' ) );
		}
	}

	$t_graph->output( 'png', true );
?>
adm_status_automa_img.php_ (4,325 bytes)   

Relationships

duplicate of 0012253 closed Graphviz Graph to display workflow - PATCH 
has duplicate 0004767 closedgrangeway States transition diagram 

Activities

sgrund

sgrund

2004-10-26 09:11

reporter   ~0008175

Nice thing. I've seen some flows in my config which aren't intended.
One question: Why have some states a thick border?

masc

masc

2004-10-26 09:50

reporter   ~0008176

The thick border is to highlight the read-only states on one side and the NEW state on the other side while the blu arrows are to highlight the reopen linkes. I know I have to add some explaination on the page.

thraxisp

thraxisp

2004-10-27 19:59

reporter   ~0008188

This looks good. It does show the duplicate transitions that can be introduced by reopen.

vboctor

vboctor

2004-12-01 06:01

manager   ~0008469

Looks good, following are my comments:

  1. There is no graph for administrators.
  2. Configuration option 'update_readonly_bug_threshold' is not taken into account when deciding if a state is readonly or not for the current access level.
  3. For reporter (as an example) what about own issues? For example, reporters may be able to close their own issues but not other issues.
  4. A legend is needed to explain what everthing means. Colors, thick borders, ...etc.
  5. Is there a way to add a check to admin/check.php to see if graphviz is installed properly? Or in case of Windows check for WinGraphViz?
  6. I think we should consider moving adm_status_automa_img.php into the code. In my opinion the main page should only contains pages that the user can visit via Mantis. I know that there are a lot of other stuff (like all the action pages) that are not implemented this way.
  7. The generated page is too wide for my notebook screen. I use 1024x768. Consider having a page for each graph and a menu to navigate between them. The only disadvantage of this approach is that it is not as easy to compare. Maybe just making the page 1 column or small boxes would be better. Other opinions are welcome.
  8. Is there ideas out there about where this should be added? Should it be only accessible to the administrators? I think it is useful for everyone to see this, and hence, it should be adm_*.php.
grangeway

grangeway

2014-10-05 05:42

reporter   ~0041350

Will look at this patch to see if this is same functionality to workflow_graph_img.php that exists now, or different.

atrol

atrol

2014-11-07 17:45

developer   ~0041793

Similar Graphviz based implementation like 0012253