CVSROOT: /sources/phpgroupware Module name: ged Changes by: Pascal Vilarem <maat> 07/10/22 15:29:25
Modified files: inc : class.flows.inc.php class.flow_client.inc.php class.soflows.inc.php Log message: added : triggers management for workflow CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flows.inc.php?cvsroot=phpgroupware&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flow_client.inc.php?cvsroot=phpgroupware&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.soflows.inc.php?cvsroot=phpgroupware&r1=1.1&r2=1.2 Patches: Index: class.flows.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.flows.inc.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- class.flows.inc.php 20 Oct 2007 22:09:39 -0000 1.1 +++ class.flows.inc.php 22 Oct 2007 15:29:25 -0000 1.2 @@ -196,10 +196,7 @@ $trigger_object=CreateObject($trigger['app'].'.flow_client', True); } - // TODO : récupérer les paramètres dont a besoin le trigger - $trigger_context=Array(); - - $trigger_result=call_user_func(array(&$trigger_object, $trigger['method']),$context['object'],$trigger_context); + $trigger_result=call_user_func(array(&$trigger_object, $trigger['method']),$context['object'],$trigger['context']); //TODO : contrôler le résultat des triggers } Index: class.flow_client.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.flow_client.inc.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- class.flow_client.inc.php 20 Oct 2007 22:09:39 -0000 1.1 +++ class.flow_client.inc.php 22 Oct 2007 15:29:25 -0000 1.2 @@ -202,8 +202,8 @@ function apply_transition_to_previous_versions_matching_status($version_id,$trigger_context=null) { - //TODO : set as parameter - $transition=11; + // DONE : set as parameter + $transition=$trigger_context['transition']; $sub_flow=CreateObject('ged.flows'); $status_from=$sub_flow->get_transition_status_from($transition); @@ -219,10 +219,11 @@ } // Mettre en alerte les dépendances quand on passe obsolète - function apply_transition_to_linked_versions_with_link_type($version_id,$trigger_context=null) + function apply_transition_to_linking_versions_with_link_type($version_id,$trigger_context=null) { - $transition=13; - $link_type='dependancy'; + // DONE : set as parameter + $transition=$trigger_context['transition'];; + $link_type=$trigger_context['link_type']; $sub_flow=CreateObject('ged.flows'); $status_from=$sub_flow->get_transition_status_from($transition); @@ -238,6 +239,27 @@ } + // Mettre en alerte les dépendances quand on passe obsolète + function apply_transition_to_linked_versions_with_link_type($version_id,$trigger_context=null) + { + // DONE : set as parameter + $transition=$trigger_context['transition'];; + $link_type=$trigger_context['link_type']; + + $sub_flow=CreateObject('ged.flows'); + $status_from=$sub_flow->get_transition_status_from($transition); + + $versions=$this->ged_dm->get_versions_linked_and_matching_criteria($version_id,$status_from, $link_type); + + // CARE : triggered transition should always be 'automatic' ones + foreach ($versions as $version) + { + $context['object']=$version['version_id']; + $do_transition_result=$sub_flow->do_transition($transition, $context); + } + + } + } ?> \ No newline at end of file Index: class.soflows.inc.php =================================================================== RCS file: /sources/phpgroupware/ged/inc/class.soflows.inc.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- class.soflows.inc.php 20 Oct 2007 22:09:39 -0000 1.1 +++ class.soflows.inc.php 22 Oct 2007 15:29:25 -0000 1.2 @@ -288,13 +288,55 @@ function get_transition_triggers($transition) { + $sql="SELECT trigger_id, app, class, method, context FROM phpgw_flows_triggers WHERE transition='".$transition."'"; + + $this->db->query($sql, __LINE__, __FILE__); + + + while ($this->db->next_record()) + { + $triggers[$this->db->f('trigger_id')]['app']=$this->db->f('app'); + $triggers[$this->db->f('trigger_id')]['class']=$this->db->f('class'); + $triggers[$this->db->f('trigger_id')]['method']=$this->db->f('method'); + $triggers[$this->db->f('trigger_id')]['context']=unserialize($this->db->f('context')); + } + + /* if ($transition==5 ) - $triggers=Array(Array('app'=>'ged','class'=>'flow_client','method'=> 'apply_transition_to_previous_versions_matching_status', 'params' => Array('status_from', 'status_to'))); + { + $triggers=Array( + Array( + 'app'=>'ged', + 'class'=>'flow_client', + 'method'=> 'apply_transition_to_previous_versions_matching_status', + 'context' => unserialize('a:1:{s:10:"transition";i:11;}')) + ); + } elseif($transition==11) - $triggers=Array(Array('app'=>'ged','class'=>'flow_client','method'=> 'apply_transition_to_linked_versions_with_link_type', 'params' => Array('status_from', 'status_to'))); + { + $triggers=Array( + Array( + 'app'=>'ged', + 'class'=>'flow_client', + 'method'=> 'apply_transition_to_linked_versions_with_link_type', + 'context' => unserialize('a:2:{s:10:"transition";i:13;s:9:"link_type";s:10:"dependancy";}')) + ); + } + elseif($transition==4) + { + $triggers=Array( + Array( + 'app'=>'ged', + 'class'=>'flow_client', + 'method'=> 'apply_transition_to_linked_versions_with_link_type', + 'context' => unserialize('a:2:{s:10:"transition";i:4;s:9:"link_type";s:8:"delivery";}')) + ); + } else + { $triggers=Array(); - + } + */ return($triggers); } _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs