[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] ged/inc class.flows.inc.php class.flow_client.i...
From: |
Pascal Vilarem |
Subject: |
[Phpgroupware-cvs] ged/inc class.flows.inc.php class.flow_client.i... |
Date: |
Wed, 24 Oct 2007 23:06:26 +0000 |
CVSROOT: /sources/phpgroupware
Module name: ged
Changes by: Pascal Vilarem <maat> 07/10/24 23:06:26
Modified files:
inc : class.flows.inc.php class.flow_client.inc.php
class.soflows.inc.php
Log message:
cleanup : make flow "objects" more generic
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flows.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flow_client.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.soflows.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
Patches:
Index: class.flows.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.flows.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- class.flows.inc.php 24 Oct 2007 16:24:58 -0000 1.3
+++ class.flows.inc.php 24 Oct 2007 23:06:26 -0000 1.4
@@ -44,14 +44,22 @@
* @param string $status status from which we are
starting
* @return array list of possible transitions
*/
- function
get_available_transitions($flow,$status,$context=null,$account_id=null)
+ function
get_available_transitions($flow_object,$account_id=null)
{
+ $app=$flow_object['app'];
+
$this->app_flow_client=CreateObject($app.'.flow_client', True);
+
+ //récupérer le flow
+ $flow=$this->app_flow_client->get_flow($flow_object);
+
+
$status=$this->app_flow_client->get_status($flow_object);
+
$available_transitions=$this->soflows->get_available_transitions($flow,$status);
$result_transition=array();
foreach ($available_transitions as $transition_label =>
$available_transition)
{
- if (
$this->soflows->check_if_user_has_required_role($available_transition['transition'],$context,$account_id))
+ if (
$this->soflows->check_if_user_has_required_role($available_transition['transition'],$flow_object,$account_id))
{
$result_transition[$transition_label]=$available_transition;
}
@@ -106,7 +114,7 @@
* @param array $context set of vars depending on
needs
* @return TOTO error message ?
*/
- function do_transition($transition,$context=null)
+ function
do_transition($transition,$object=null,$account_id=null)
{
/**
* Needs to checks conditions,
@@ -126,7 +134,7 @@
$this->app_flow_client=CreateObject($app.'.flow_client', True);
//récupérer le flow
-
$flow=$this->app_flow_client->get_flow($context['object']);
+ $flow=$this->app_flow_client->get_flow($object);
//contrôler que la transition appratient bien
au flow en question
$transition_is_in_flow=$this->soflows->check_if_transition_is_in_flow($transition,
$flow);
@@ -134,7 +142,7 @@
if ( $transition_is_in_flow )
{
//récupérer le statut de départ de
l'objet
-
$object_status_from=$this->app_flow_client->get_status($context['object']);
+
$object_status_from=$this->app_flow_client->get_status($object);
$transition_status_from=$this->soflows->get_transition_status_from($transition);
@@ -145,14 +153,13 @@
//print ( "<br>\nok available");
//contrôler les rôles
-
$object_context=$this->app_flow_client->get_object_context($context['object']);
-
$user_has_required_role=$this->soflows->check_if_user_has_required_role($transition,$object_context);
+
$user_has_required_role=$this->soflows->check_if_user_has_required_role($transition,$object,$account_id);
if ($user_has_required_role ==
true)
{
//contrôler les
conditions
-
$conditions_of_transition_are_filled=$this->soflows->check_if_conditions_of_transition_are_filled($transition,$context['object']);
+
$conditions_of_transition_are_filled=$this->soflows->check_if_conditions_of_transition_are_filled($transition,$object);
if (
$conditions_of_transition_are_filled )
{
@@ -175,7 +182,7 @@
$transition_context=Array('action' => $action, 'custom_fields'
=>$custom_fields);
if (
is_callable(array(&$this->app_flow_client, $client_set_next_method)))
{
-
$method_result=call_user_func(array(&$this->app_flow_client,
$client_set_next_method),$context['object'], $next_status,$transition_context);
+
$method_result=call_user_func(array(&$this->app_flow_client,
$client_set_next_method),$object, $next_status,$transition_context);
if ( $method_result['status'] == 'ok')
{
@@ -190,7 +197,7 @@
}
$comment_context=Array('comment' => $comment);
-
$this->app_flow_client->set_history($context['object'],
$action."[".$transition."]", $comment_context);
+
$this->app_flow_client->set_history($object,
$action."[".$transition."]", $comment_context);
//récupérer les triggers
$triggers=$this->soflows->get_transition_triggers($transition);
@@ -207,7 +214,7 @@
$trigger_object=CreateObject($trigger['app'].'.flow_client', True);
}
-
$trigger_result=call_user_func(array(&$trigger_object,
$trigger['method']),$context['object'],$trigger['context']);
+
$trigger_result=call_user_func(array(&$trigger_object,
$trigger['method']),$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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- class.flow_client.inc.php 24 Oct 2007 16:24:59 -0000 1.3
+++ class.flow_client.inc.php 24 Oct 2007 23:06:26 -0000 1.4
@@ -60,24 +60,16 @@
*/
function get_status($object)
{
- $last_version=$this->ged_dm->get_version_info($object);
+
$last_version=$this->ged_dm->get_version_info($object['version_id']);
return($last_version['status']);
}
- function get_object_context($object)
- {
- //project
- //project+type
- //project+type+element
- //project+type+element+version
- }
-
function set_status($object,$status,$context=null)
{
//DEBUG
//print ( "<br/>\n".$status );
- $this->ged_dm->set_version_status($object,$status);
+
$this->ged_dm->set_version_status($object['version_id'],$status);
$function_result=Array('status' => 'ok');
return($function_result);
@@ -87,7 +79,7 @@
{
$function_result=Array('status' => 'processing');
- $last_version=$this->ged_dm->get_version_info($object);
+
$last_version=$this->ged_dm->get_version_info($object['version_id']);
$element=$this->ged_dm->get_element_info($last_version['element_id']);
$review_file=get_var('review_file',array('POST'));
@@ -149,7 +141,7 @@
}
-
$this->ged_dm->set_version_status($object,$status);
+
$this->ged_dm->set_version_status($object['version_id'],$status);
$function_result['comment']=$comment;
$function_result['status']='ok';
}
@@ -183,7 +175,7 @@
return ($function_result);
}
- function set_history($version_id, $action, $context=null)
+ function set_history($object, $action, $context=null)
{
if ( isset($context))
{
@@ -201,14 +193,14 @@
$comment='';
}
- $this->ged_dm->store_history ($action, $comment,
$version_id);
+ $this->ged_dm->store_history ($action, $comment,
$object['version_id']);
}
/*
* TRIGGERS
*/
- function
apply_transition_to_previous_versions_matching_status($version_id,$trigger_context=null)
+ function
apply_transition_to_previous_versions_matching_status($object,$trigger_context=null)
{
// DONE : set as parameter
$transition=$trigger_context['transition'];
@@ -216,18 +208,21 @@
$sub_flow=CreateObject('ged.flows');
$status_from=$sub_flow->get_transition_status_from($transition);
-
$versions=$this->ged_dm->get_previous_versions_matching_status($version_id,$status_from);
+
$versions=$this->ged_dm->get_previous_versions_matching_status($object['version_id'],$status_from);
// 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);
+ $loop_object=null;
+ $loop_object=$object;
+
$loop_object['version_id']=$version['version_id'];
+
+
$do_transition_result=$sub_flow->do_transition($transition, $loop_object);
}
}
// Mettre en alerte les dépendances quand on passe obsolète
- function
apply_transition_to_linking_versions_with_link_type($version_id,$trigger_context=null)
+ function
apply_transition_to_linking_versions_with_link_type($object,$trigger_context=null)
{
// DONE : set as parameter
$transition=$trigger_context['transition'];;
@@ -236,19 +231,22 @@
$sub_flow=CreateObject('ged.flows');
$status_from=$sub_flow->get_transition_status_from($transition);
-
$versions=$this->ged_dm->get_versions_linking_and_matching_criteria($version_id,$status_from,
$link_type);
+
$versions=$this->ged_dm->get_versions_linking_and_matching_criteria($object['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);
+ $loop_element=null;
+
$loop_element=$this->ged_dm->get_element_info($version['element_id']);
+ $loop_object=array('app' =>
$object['app'],'project_root' => $loop_element['project_root'], 'doc_type' =>
$loop_element['doc_type'], 'element_id' => $version['element_id'], 'version_id'
=> $version['version_id'] );
+
+
$do_transition_result=$sub_flow->do_transition($transition, $loop_object);
}
}
// 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_linked_versions_with_link_type($object,$trigger_context=null)
{
// DONE : set as parameter
$transition=$trigger_context['transition'];;
@@ -257,13 +255,16 @@
$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);
+
$versions=$this->ged_dm->get_versions_linked_and_matching_criteria($object['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);
+ $loop_element=null;
+
$loop_element=$this->ged_dm->get_element_info($version['element_id']);
+ $loop_object=array('app' =>
$object['app'],'project_root' => $loop_element['project_root'], 'doc_type' =>
$loop_element['doc_type'], 'element_id' => $version['element_id'], 'version_id'
=> $version['version_id'] );
+
+
$do_transition_result=$sub_flow->do_transition($transition, $loop_object);
}
}
Index: class.soflows.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.soflows.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- class.soflows.inc.php 24 Oct 2007 16:24:59 -0000 1.3
+++ class.soflows.inc.php 24 Oct 2007 23:06:26 -0000 1.4
@@ -81,7 +81,7 @@
* @param integer $account account_id (current uid by
default)
* @return bool result
*/
- function
check_if_user_has_required_role($transition,$context=null,$account_id=null)
+ function
check_if_user_has_required_role($transition,$object,$account_id=null)
{
if (is_null($account_id))
{
@@ -104,6 +104,10 @@
$sql_role_base.=$or."phpgw_flows_roles.account_id=".$the_account_id." ";
$sql_role_base.=" ) ";
+ //balayage des champs de l'objet pour faire n
objets progressivement renseignés
+ // 1 champ, 2 champs etc
+ // puis sérialisation pour enrichir la requête SQL
+
$sql="SELECT * FROM phpgw_flows_roles WHERE
phpgw_flows_roles.transition=".$transition." ";
$sql.="AND ".$sql_role_base;
@@ -132,7 +136,7 @@
* @param TODO $context TODO
* @return bool result
*/
- function
check_if_conditions_of_transition_are_filled($transition,$context=null)
+ function
check_if_conditions_of_transition_are_filled($transition,$object=null)
{
return (true);
}
@@ -261,7 +265,7 @@
* @param TODO $context TODO
* @return array list of phpgw accounts
*/
- function get_transition_roles($transition,$context=null)
+ function get_transition_roles($transition,$object)
{
}