From: <reg...@us...> - 2005-05-29 11:10:03
|
Update of /cvsroot/egroupware/workflow/inc/engine/src/API In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5727 Modified Files: Instance.php Log Message: bugs found by C. riccomini : fix space in SQL query. Unique user was set in sendTo even with groups belonging to roles. We don't check anymore this unique user if there are groups in one of the roles. And a little getter fix on name Index: Instance.php =================================================================== RCS file: /cvsroot/egroupware/workflow/inc/engine/src/API/Instance.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Instance.php 23 May 2005 11:04:29 -0000 1.4 --- Instance.php 29 May 2005 11:09:54 -0000 1.5 *************** *** 105,113 **** $this->started=$now; $this->owner = $user; $props=serialize($this->properties); $query = "insert into `".GALAXIA_TABLE_PREFIX."instances` (`wf_started`,`wf_ended`,`wf_status`,`wf_p_id`,`wf_owner`,`wf_properties`,`wf_name`) values(?,?,?,?,?,?,?)"; ! $this->query($query,array($now,0,'active',$pid,$user,$props,$this->name)); $this->instanceId = $this->getOne("select max(`wf_instance_id`) from `".GALAXIA_TABLE_PREFIX."instances` where `wf_started`=? and `wf_owner`=?",array((int)$now,$user)); $iid=$this->instanceId; --- 105,114 ---- $this->started=$now; $this->owner = $user; + $name = $this->getName(); $props=serialize($this->properties); $query = "insert into `".GALAXIA_TABLE_PREFIX."instances` (`wf_started`,`wf_ended`,`wf_status`,`wf_p_id`,`wf_owner`,`wf_properties`,`wf_name`) values(?,?,?,?,?,?,?)"; ! $this->query($query,array($now,0,'active',$pid,$user,$props,$name)); $this->instanceId = $this->getOne("select max(`wf_instance_id`) from `".GALAXIA_TABLE_PREFIX."instances` where `wf_started`=? and `wf_owner`=?",array((int)$now,$user)); $iid=$this->instanceId; *************** *** 243,247 **** $bindvars = array($theuser,(int)$activityId,(int)$this->instanceId); if(!($theuser=='*')) { ! $query.= "and (`wf_user`=? or `wf_user`=?)"; $bindvars[]= $theuser; $bindvars[]= '*'; --- 244,248 ---- $bindvars = array($theuser,(int)$activityId,(int)$this->instanceId); if(!($theuser=='*')) { ! $query.= " and (`wf_user`=? or `wf_user`=?)"; $bindvars[]= $theuser; $bindvars[]= '*'; *************** *** 581,585 **** $query = "select `wf_role_id` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `wf_activity_id`=?"; $result = $this->query($query,array((int)$activityId)); ! while ($res = $result->fetchRow()) { $roleId = $res['wf_role_id']; //regis: group role mapping as an impact here, we need to count real user corresponding to this role --- 582,587 ---- $query = "select `wf_role_id` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `wf_activity_id`=?"; $result = $this->query($query,array((int)$activityId)); ! while ($res = $result->fetchRow()) ! { $roleId = $res['wf_role_id']; //regis: group role mapping as an impact here, we need to count real user corresponding to this role *************** *** 588,607 **** // to look in members of the group to find is there is a unique real user candidate for this role // you could try it if you want but it's quite complex for something not really usefull ! //$user_groups = galaxia_retrieve_user_groups($GLOBALS['phpgw_info']['user']['account_id'] ); ! $query2 = "select distinct wf_user, wf_account_type from ".GALAXIA_TABLE_PREFIX."user_roles ! where wf_role_id=? and wf_account_type='u'"; ! $result2 = $this->query($query2,array((int)$roleId)); ! while ($res2 = $result2->fetchRow()) ! { ! $candidates[] = $res2['wf_user']; ! //optimisation, we do not need the complete list ! if (count($candidates) > 1) break; } } ! // here if we have only 1 REAL egw USER (not group) coming for next activity the user is setted ! if(count($candidates) == 1) { $putuser = $candidates[0]; ! } else { ! // If there is more than one user for this activity // then check to see if there is a default user $activity_manager =& CreateObject('workflow.workflow_activitymanager'); --- 590,621 ---- // to look in members of the group to find is there is a unique real user candidate for this role // you could try it if you want but it's quite complex for something not really usefull ! // if there's at least one group in the roles we then won't even try to get this unique user ! $query_group = "select count(*) from ".GALAXIA_TABLE_PREFIX."user_roles ! where wf_role_id=? and wf_account_type='g'"; ! if (!$this->getOne($query_group,array((int)$roleId))) ! {//if count<>0 then !getOne==true, we have at least one group ! //we can break the while, we wont search the candidate ! unset($candidates); ! break; ! } ! else ! {// if count==0 then !getOne==false, we have no groups ! $query2 = "select distinct wf_user, wf_account_type from ".GALAXIA_TABLE_PREFIX."user_roles ! where wf_role_id=?"; ! $result2 = $this->query($query2,array((int)$roleId)); ! while ($res2 = $result2->fetchRow()) ! { ! $candidates[] = $res2['wf_user']; ! } } } ! // here if we have only 1 REAL egw USER (no groups) coming for next activity the user is setted ! if(isset($candidates) && (count($candidates) == 1)) ! { $putuser = $candidates[0]; ! } ! else ! { ! // If there is more than one user or groups for this activity // then check to see if there is a default user $activity_manager =& CreateObject('workflow.workflow_activitymanager'); |