phpgroupware-cvs
[Top][All Lists]
Advanced

[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 16:24:59 +0000

CVSROOT:        /sources/phpgroupware
Module name:    ged
Changes by:     Pascal Vilarem <maat>   07/10/24 16:24:59

Modified files:
        inc            : class.flows.inc.php class.flow_client.inc.php 
                         class.soflows.inc.php 

Log message:
        added : role management for workflow

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flows.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.flow_client.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/ged/inc/class.soflows.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3

Patches:
Index: class.flows.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.flows.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- class.flows.inc.php 22 Oct 2007 15:29:25 -0000      1.2
+++ class.flows.inc.php 24 Oct 2007 16:24:58 -0000      1.3
@@ -44,10 +44,20 @@
                * @param   string   $status        status from which we are 
starting
                * @return  array                   list of possible transitions
                */
-               function get_available_transitions($flow,$status)
+               function 
get_available_transitions($flow,$status,$context=null,$account_id=null)
                {
                        
$available_transitions=$this->soflows->get_available_transitions($flow,$status);
-                       return ($available_transitions);
+                       $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))
+                               {
+                                       
$result_transition[$transition_label]=$available_transition;
+                               }
+                       }
+                       
+                       return ($result_transition);
                }
                
                /**
@@ -135,9 +145,10 @@
                                                //print ( "<br>\nok available");
                                                
                                                //contrôler les rôles
-                                               
$user_has_required_role=$this->soflows->check_if_user_has_required_role($transition);
+                                               
$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);
                                                
-                                               if ($user_has_required_role)
+                                               if ($user_has_required_role == 
true)
                                                {
                                                
                                                        //contrôler les 
conditions

Index: class.flow_client.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.flow_client.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- class.flow_client.inc.php   22 Oct 2007 15:29:25 -0000      1.2
+++ class.flow_client.inc.php   24 Oct 2007 16:24:59 -0000      1.3
@@ -65,6 +65,14 @@
                        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

Index: class.soflows.inc.php
===================================================================
RCS file: /sources/phpgroupware/ged/inc/class.soflows.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- class.soflows.inc.php       22 Oct 2007 15:29:25 -0000      1.2
+++ class.soflows.inc.php       24 Oct 2007 16:24:59 -0000      1.3
@@ -81,16 +81,47 @@
                * @param   integer  $account       account_id (current uid by 
default)
                * @return  bool                    result
                */
-               function 
check_if_user_has_required_role($transition,$accound_id=null)
+               function 
check_if_user_has_required_role($transition,$context=null,$account_id=null)
                {
-                       if (is_null($accound_id))
+                       if (is_null($account_id))
                        {
-                               
$accound_id=$GLOBALS['phpgw_info']['user']['account_id'];
+                               
$the_account_id=$GLOBALS['phpgw_info']['user']['account_id'];
+                       }
+                       else
+                       {
+                               $the_account_id=$account_id;
                        }
                        
-                       //if account_id is a user_id get the groups he belongs 
to
+                       
$the_groups=$GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, 
$the_account_id);
                         
-                       return (true);
+                       $or="";
+                       $sql_role_base="( ";
+                       foreach ( $the_groups as $group )
+                       {
+                               
$sql_role_base.=$or."phpgw_flows_roles.account_id=".intval($group)." ";
+                               $or="OR ";
+                       }
+                       
$sql_role_base.=$or."phpgw_flows_roles.account_id=".$the_account_id." ";
+                       $sql_role_base.=" ) ";                  
+                       
+                       $sql="SELECT * FROM phpgw_flows_roles WHERE 
phpgw_flows_roles.transition=".$transition." ";
+                       $sql.="AND ".$sql_role_base;
+                       
+                       // DEBUG
+                       //print ($sql);
+                       
+                       $this->db->query($sql, __LINE__, __FILE__);
+       
+                       if ($this->db->next_record())
+                       {
+                               $check=true;
+                       }
+                       else
+                       {
+                               $check=false;
+                       }
+                       
+                       return($check);
                }
 
                /**
@@ -127,7 +158,6 @@
                        
                        while ($this->db->next_record())
                        {
-       
                                
$transitions[$ii]['transition']=$this->db->f('transition');
                                
$transitions[$ii]['action']=$this->db->f('action');
                                $ii ++;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]