diff --git a/phpgwapi/inc/galaxia_workflow/src/API/BaseActivity.php b/phpgwapi/inc/galaxia_workflow/src/API/BaseActivity.php index a145e00072..cfbdb43511 100644 --- a/phpgwapi/inc/galaxia_workflow/src/API/BaseActivity.php +++ b/phpgwapi/inc/galaxia_workflow/src/API/BaseActivity.php @@ -39,11 +39,11 @@ class BaseActivity extends Base { */ function getActivity($activityId) { - $query = "select * from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?"; $result = $this->query($query,array($activityId)); if(!$result->numRows()) return false; $res = $result->fetchRow(); - switch($res['type']) { + switch($res['wf_type']) { case 'start': $act = new Start($this->db); break; @@ -66,27 +66,27 @@ class BaseActivity extends Base { $act = new Activity($this->db); break; default: - trigger_error('Unknown activity type:'.$res['type'],E_USER_WARNING); + trigger_error('Unknown activity type:'.$res['wf_type'],E_USER_WARNING); } - $act->setName($res['name']); - $act->setProcessId($res['pId']); - $act->setNormalizedName($res['normalized_name']); + $act->setName($res['wf_name']); + $act->setProcessId($res['wf_p_id']); + $act->setNormalizedName($res['wf_normalized_name']); $act->setDescription($res['description']); - $act->setIsInteractive($res['isInteractive']); - $act->setIsAutoRouted($res['isAutoRouted']); - $act->setActivityId($res['activityId']); - $act->setType($res['type']); + $act->setIsInteractive($res['wf_is_interactive']); + $act->setIsAutoRouted($res['is_autorouted']); + $act->setActivityId($res['activity_id']); + $act->setType($res['wf_type']); //Now get forward transitions //Now get backward transitions //Now get roles - $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `activityId`=?"; - $result=$this->query($query,array($res['activityId'])); + $query = "select `wf_role_id` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `wf_activity_id`=?"; + $result=$this->query($query,array($res['wf_activity_id'])); while($res = $result->fetchRow()) { - $this->roles[] = $res['roleId']; + $this->roles[] = $res['wf_role_id']; } $act->setRoles($this->roles); return $act; @@ -94,11 +94,11 @@ class BaseActivity extends Base { /*! Returns an Array of roleIds for the given user */ function getUserRoles($user) { - $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."user_roles` where `user`=?"; + $query = "select `wf_role_id` from `".GALAXIA_TABLE_PREFIX."user_roles` where `wf_user`=?"; $result=$this->query($query,array($user)); $ret = Array(); while($res = $result->fetchRow()) { - $ret[] = $res['roleId']; + $ret[] = $res['wf_role_id']; } return $ret; } @@ -107,7 +107,7 @@ class BaseActivity extends Base { for the given user */ function getActivityRoleNames() { $aid = $this->activityId; - $query = "select gr.`roleId`, `name` from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`roleId`=gr.`roleId` and gar.`activityId`=?"; + $query = "select gr.`wf_role_id`, `wf_name` from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`wf_role_id`=gr.`wf_role_id` and gar.`wf_activity_id`=?"; $result=$this->query($query,array($aid)); $ret = Array(); while($res = $result->fetchRow()) { @@ -211,7 +211,7 @@ class BaseActivity extends Base { e.g. $isadmin = $activity->checkUserRole($user,'admin'); */ function checkUserRole($user,$rolename) { $aid = $this->activityId; - return $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."user_roles` gur, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`roleId`=gr.`roleId` and gur.`roleId`=gr.`roleId` and gar.`activityId`=? and gur.`user`=? and gr.`name`=?",array($aid, $user, $rolename)); + return $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."activity_roles` gar, `".GALAXIA_TABLE_PREFIX."user_roles` gur, `".GALAXIA_TABLE_PREFIX."roles` gr where gar.`wf_role_id`=gr.`roleId` and gur.`wf_role_id`=gr.`roleId` and gar.`wf_activity_id`=? and gur.`wf_user`=? and gr.`wf_name`=?",array($aid, $user, $rolename)); } } diff --git a/phpgwapi/inc/galaxia_workflow/src/API/Instance.php b/phpgwapi/inc/galaxia_workflow/src/API/Instance.php index e693f666dd..81b3f3de0c 100644 --- a/phpgwapi/inc/galaxia_workflow/src/API/Instance.php +++ b/phpgwapi/inc/galaxia_workflow/src/API/Instance.php @@ -32,23 +32,23 @@ class Instance extends Base { */ function getInstance($instanceId) { // Get the instance data - $query = "select * from `".GALAXIA_TABLE_PREFIX."instances` where `instanceId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."instances` where `wf_instance_id`=?"; $result = $this->query($query,array((int)$instanceId)); if(!$result->numRows()) return false; $res = $result->fetchRow(); //Populate - $this->properties = unserialize($res['properties']); - $this->status = $res['status']; - $this->pId = $res['pId']; - $this->instanceId = $res['instanceId']; - $this->owner = $res['owner']; - $this->started = $res['started']; - $this->ended = $res['ended']; - $this->nextActivity = $res['nextActivity']; - $this->nextUser = $res['nextUser']; + $this->properties = unserialize($res['wf_properties']); + $this->status = $res['wf_status']; + $this->pId = $res['wf_p_id']; + $this->instanceId = $res['wf_instance_id']; + $this->owner = $res['wf_owner']; + $this->started = $res['wf_started']; + $this->ended = $res['wf_ended']; + $this->nextActivity = $res['wf_next_activity']; + $this->nextUser = $res['wf_next_user']; // Get the activities where the instance is (ids only is ok) - $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=?"; $result = $this->query($query,array((int)$instanceId)); while($res = $result->fetchRow()) { $this->activities[]=$res; @@ -64,12 +64,12 @@ class Instance extends Base { function setNextActivity($actname) { $pId = $this->pId; $actname=trim($actname); - $aid = $this->getOne("select `activityId` from `".GALAXIA_TABLE_PREFIX."activities` where `pId`=? and `name`=?",array($pId,$actname)); - if(!$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=? and `pId`=?",array($aid,$pId))) { + $aid = $this->getOne("select `wf_activity_id` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_p_id`=? and `wf_name`=?",array($pId,$actname)); + if(!$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=? and `wf_p_id`=?",array($aid,$pId))) { trigger_error(tra('Fatal error: setting next activity to an unexisting activity'),E_USER_WARNING); } $this->nextActivity=$aid; - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `nextActivity`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_next_activity`=? where `wf_instance_id`=?"; $this->query($query,array((int)$aid,(int)$this->instanceId)); } @@ -81,7 +81,7 @@ class Instance extends Base { function setNextUser($user) { $pId = $this->pId; $this->nextUser = $user; - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `nextUser`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_next_user`=? where `wf_instance_id`=?"; $this->query($query,array($user,(int)$this->instanceId)); } @@ -94,7 +94,7 @@ class Instance extends Base { function _createNewInstance($activityId,$user) { // Creates a new instance setting up started,ended,user // and status - $pid = $this->getOne("select `pId` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array((int)$activityId)); + $pid = $this->getOne("select `wf_p_id` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array((int)$activityId)); $this->status = 'active'; $this->nextActivity = 0; $this->setNextUser(''); @@ -103,19 +103,19 @@ class Instance extends Base { $this->started=$now; $this->owner = $user; $props=serialize($this->properties); - $query = "insert into `".GALAXIA_TABLE_PREFIX."instances`(`started`,`ended`,`status`,`pId`,`owner`,`properties`) values(?,?,?,?,?,?)"; + $query = "insert into `".GALAXIA_TABLE_PREFIX."instances`(`wf_started`,`wf_ended`,`wf_status`,`wf_p_id`,`wf_owner`,`wf_properties`) values(?,?,?,?,?,?)"; $this->query($query,array($now,0,'active',$pid,$user,$props)); - $this->instanceId = $this->getOne("select max(`instanceId`) from `".GALAXIA_TABLE_PREFIX."instances` where `started`=? and `owner`=?",array((int)$now,$user)); + $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; // Now update the properties! $props = serialize($this->properties); - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `properties`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_properties`=? where `wf_instance_id`=?"; $this->query($query,array($props,(int)$iid)); // Then add in ".GALAXIA_TABLE_PREFIX."instance_activities an entry for the // activity the user and status running and started now - $query = "insert into `".GALAXIA_TABLE_PREFIX."instance_activities`(`instanceId`,`activityId`,`user`,`started`,`status`) values(?,?,?,?,?)"; + $query = "insert into `".GALAXIA_TABLE_PREFIX."instance_activities`(`wf_instance_id`,`wf_activity_id`,`wf_user`,`wf_started`,`wf_status`) values(?,?,?,?,?)"; $this->query($query,array((int)$iid,(int)$activityId,$user,(int)$now,'running')); } @@ -126,7 +126,7 @@ class Instance extends Base { function set($name,$value) { $this->properties[$name] = $value; $props = serialize($this->properties); - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `properties`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_properties`=? where `wf_instance_id`=?"; $this->query($query,array($props,$this->instanceId)); } @@ -164,7 +164,7 @@ class Instance extends Base { function setStatus($status) { $this->status = $status; // and update the database - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `status`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_status`=? where `wf_instance_id`=?"; $this->query($query,array($status,(int)$this->instanceId)); } @@ -195,7 +195,7 @@ class Instance extends Base { function setOwner($user) { $this->owner = $user; // save database - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `owner`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_owner`=? where `wf_instance_id`=?"; $this->query($query,array($owner,(int)$this->instanceId)); } @@ -207,9 +207,9 @@ class Instance extends Base { function setActivityUser($activityId,$theuser) { if(empty($theuser)) $theuser='*'; for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - $this->activities[$i]['user']=$theuser; - $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `user`=? where `activityId`=? and `instanceId`=?"; + if($this->activities[$i]['wf_activity_id']==$activityId) { + $this->activities[$i]['wf_user']=$theuser; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_user`=? where `wf_activity_id`=? and `wf_instance_id`=?"; $this->query($query,array($theuser,(int)$activityId,(int)$this->instanceId)); } @@ -222,8 +222,8 @@ class Instance extends Base { */ function getActivityUser($activityId) { for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - return $this->activities[$i]['user']; + if($this->activities[$i]['wf_activity_id']==$activityId) { + return $this->activities[$i]['wf_user']; } } return false; @@ -235,9 +235,9 @@ class Instance extends Base { */ function setActivityStatus($activityId,$status) { for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - $this->activities[$i]['status']=$status; - $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `status`=? where `activityId`=? and `instanceId`=?"; + if($this->activities[$i]['wf_activity_id']==$activityId) { + $this->activities[$i]['wf_status']=$status; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_status`=? where `wf_activity_id`=? and `wf_instance_id`=?"; $this->query($query,array($status,(int)$activityId,(int)$this->instanceId)); } } @@ -250,8 +250,8 @@ class Instance extends Base { */ function getActivityStatus($activityId) { for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - return $this->activities[$i]['status']; + if($this->activities[$i]['wf_activity_id']==$activityId) { + return $this->activities[$i]['wf_status']; } } return false; @@ -263,9 +263,9 @@ class Instance extends Base { function setActivityStarted($activityId) { $now = date("U"); for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - $this->activities[$i]['started']=$now; - $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `started`=? where `activityId`=? and `instanceId`=?"; + if($this->activities[$i]['wf_activity_id']==$activityId) { + $this->activities[$i]['wf_started']=$now; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_started`=? where `wf_activity_id`=? and `wf_instance_id`=?"; $this->query($query,array($now,(int)$activityId,(int)$this->instanceId)); } } @@ -276,8 +276,8 @@ class Instance extends Base { */ function getActivityStarted($activityId) { for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { - return $this->activities[$i]['started']; + if($this->activities[$i]['wf_activity_id']==$activityId) { + return $this->activities[$i]['wf_started']; } } return false; @@ -289,7 +289,7 @@ class Instance extends Base { */ function _get_instance_activity($activityId) { for($i=0;$iactivities);$i++) { - if($this->activities[$i]['activityId']==$activityId) { + if($this->activities[$i]['wf_activity_id']==$activityId) { return $this->activities[$i]; } } @@ -301,7 +301,7 @@ class Instance extends Base { */ function setStarted($time) { $this->started=$time; - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `started`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_started`=? where `wf_instance_id`=?"; $this->query($query,array((int)$time,(int)$this->instanceId)); } @@ -317,7 +317,7 @@ class Instance extends Base { */ function setEnded($time) { $this->ended=$time; - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `ended`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_ended`=? where `wf_instance_id`=?"; $this->query($query,array((int)$time,(int)$this->instanceId)); } @@ -353,25 +353,25 @@ class Instance extends Base { if(empty($user)) {$theuser='*';} else {$theuser=$user;} if($activityId==0) { - $activityId=$_REQUEST['activityId']; + $activityId=$_REQUEST['activity_id']; } // If we are completing a start activity then the instance must // be created first! - $type = $this->getOne("select `type` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array((int)$activityId)); + $type = $this->getOne("select `wf_type` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array((int)$activityId)); if($type=='start') { $this->_createNewInstance((int)$activityId,$theuser); } // Now set ended $now = date("U"); - $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `ended`=? where `activityId`=? and `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_ended`=? where `wf_activity_id`=? and `wf_instance_id`=?"; $this->query($query,array((int)$now,(int)$activityId,(int)$this->instanceId)); //Add a workitem to the instance $iid = $this->instanceId; if($addworkitem) { - $max = $this->getOne("select max(`orderId`) from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?",array((int)$iid)); + $max = $this->getOne("select max(`wf_order_id`) from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?",array((int)$iid)); if(!$max) { $max=1; } else { @@ -383,12 +383,12 @@ class Instance extends Base { $started = $this->getStarted(); $putuser = $this->getOwner(); } else { - $started=$act['started']; - $putuser = $act['user']; + $started=$act['wf_started']; + $putuser = $act['wf_user']; } $ended = date("U"); $properties = serialize($this->properties); - $query="insert into `".GALAXIA_TABLE_PREFIX."workitems`(`instanceId`,`orderId`,`activityId`,`started`,`ended`,`properties`,`user`) values(?,?,?,?,?,?,?)"; + $query="insert into `".GALAXIA_TABLE_PREFIX."workitems`(`wf_instance_id`,`wf_order_id`,`wf_activity_id`,`wf_started`,`wf_ended`,`wf_properties`,`wf_user`) values(?,?,?,?,?,?,?)"; $this->query($query,array((int)$iid,(int)$max,(int)$activityId,(int)$started,(int)$ended,$properties,$putuser)); } @@ -404,13 +404,13 @@ class Instance extends Base { //If the activity ending is autorouted then send to the //activity if ($type != 'end') { - if (($force) || ($this->getOne("select `isAutoRouted` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array($activityId)) == 'y')) { + if (($force) || ($this->getOne("select `wf_is_autorouted` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array($activityId)) == 'y')) { // Now determine where to send the instance - $query = "select `actToId` from `".GALAXIA_TABLE_PREFIX."transitions` where `actFromId`=?"; + $query = "select `wf_act_to_id` from `".GALAXIA_TABLE_PREFIX."transitions` where `wf_act_from_id`=?"; $result = $this->query($query,array((int)$activityId)); $candidates = Array(); while ($res = $result->fetchRow()) { - $candidates[] = $res['actToId']; + $candidates[] = $res['wf_act_to_id']; } if($type == 'split') { $first = true; @@ -446,25 +446,25 @@ class Instance extends Base { } if($activityId==0) { - $activityId=$_REQUEST['activityId']; + $activityId=$_REQUEST['wf_activity_id']; } // If we are completing a start activity then the instance must // be created first! - $type = $this->getOne("select `type` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array((int)$activityId)); + $type = $this->getOne("select `wf_type` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array((int)$activityId)); if($type=='start') { $this->_createNewInstance((int)$activityId,$theuser); } // Now set ended $now = date("U"); - $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `ended`=? where `activityId`=? and `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_ended`=? where `wf_activity_id`=? and `wf_instance_id`=?"; $this->query($query,array((int)$now,(int)$activityId,(int)$this->instanceId)); //Add a workitem to the instance $iid = $this->instanceId; if($addworkitem) { - $max = $this->getOne("select max(`orderId`) from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?",array((int)$iid)); + $max = $this->getOne("select max(`wf_order_id`) from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?",array((int)$iid)); if(!$max) { $max=1; } else { @@ -476,12 +476,12 @@ class Instance extends Base { $started = $this->getStarted(); $putuser = $this->getOwner(); } else { - $started=$act['started']; - $putuser = $act['user']; + $started=$act['wf_started']; + $putuser = $act['wf_user']; } $ended = date("U"); $properties = serialize($this->properties); - $query="insert into `".GALAXIA_TABLE_PREFIX."workitems`(`instanceId`,`orderId`,`activityId`,`started`,`ended`,`properties`,`user`) values(?,?,?,?,?,?,?)"; + $query="insert into `".GALAXIA_TABLE_PREFIX."workitems`(`wf_instance_id`,`wf_order_id`,`wf_activity_id`,`wf_started`,`wf_ended`,`wf_properties`,`wf_user`) values(?,?,?,?,?,?,?)"; $this->query($query,array((int)$iid,(int)$max,(int)$activityId,(int)$started,(int)$ended,$properties,$putuser)); } @@ -502,9 +502,9 @@ class Instance extends Base { function terminate($status = 'completed') { //Set the status of the instance to completed $now = date("U"); - $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `status`=?, `ended`=? where `instanceId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_status`=?, `wf_ended`=? where `wf_instance_id`=?"; $this->query($query,array($status,(int)$now,(int)$this->instanceId)); - $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?"; + $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=?"; $this->query($query,array((int)$this->instanceId)); $this->status = $status; $this->activities = Array(); @@ -521,10 +521,10 @@ class Instance extends Base { //if this instance is also in //other activity if so do //nothing - $type = $this->getOne("select `type` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array((int)$activityId)); + $type = $this->getOne("select `wf_type` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array((int)$activityId)); // Verify the existance of a transition - if(!$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."transitions` where `actFromId`=? and `actToId`=?",array($from,(int)$activityId))) { + if(!$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."transitions` where `wf_act_from_id`=? and `wf_act_to_id`=?",array($from,(int)$activityId))) { trigger_error(tra('Fatal error: trying to send an instance to an activity but no transition found'),E_USER_WARNING); } @@ -534,14 +534,14 @@ class Instance extends Base { $putuser = $this->nextUser; } else { $candidates = Array(); - $query = "select `roleId` from `".GALAXIA_TABLE_PREFIX."activity_roles` where `activityId`=?"; + $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['roleId']; - $query2 = "select `user` from `".GALAXIA_TABLE_PREFIX."user_roles` where `roleId`=?"; + $roleId = $res['wf_role_id']; + $query2 = "select `wf_user` from `".GALAXIA_TABLE_PREFIX."user_roles` where `wf_role_id`=?"; $result2 = $this->query($query2,array((int)$roleId)); while ($res2 = $result2->fetchRow()) { - $candidates[] = $res2['user']; + $candidates[] = $res2['wf_user']; } } if(count($candidates) == 1) { @@ -554,19 +554,19 @@ class Instance extends Base { //if not splitting delete first //please update started,status,user if(!$split) { - $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=? and `activityId`=?"; + $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=? and `wf_activity_id`=?"; $this->query($query,array((int)$this->instanceId,$from)); } $now = date("U"); $iid = $this->instanceId; - $query="delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=? and `activityId`=?"; + $query="delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=? and `wf_activity_id`=?"; $this->query($query,array((int)$iid,(int)$activityId)); - $query="insert into `".GALAXIA_TABLE_PREFIX."instance_activities`(`instanceId`,`activityId`,`user`,`status`,`started`) values(?,?,?,?,?)"; + $query="insert into `".GALAXIA_TABLE_PREFIX."instance_activities`(`wf_instance_id`,`wf_activity_id`,`wf_user`,`wf_status`,`wf_started`) values(?,?,?,?,?)"; $this->query($query,array((int)$iid,(int)$activityId,$putuser,'running',(int)$now)); //we are now in a new activity $this->activities=Array(); - $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=?"; $result = $this->query($query,array((int)$iid)); while ($res = $result->fetchRow()) { $this->activities[]=$res; @@ -583,7 +583,7 @@ class Instance extends Base { //if the activity is not interactive then //execute the code for the activity and //complete the activity - $isInteractive = $this->getOne("select `isInteractive` from `".GALAXIA_TABLE_PREFIX."activities` where `activityId`=?",array((int)$activityId)); + $isInteractive = $this->getOne("select `wf_is_interactive` from `".GALAXIA_TABLE_PREFIX."activities` where `wf_activity_id`=?",array((int)$activityId)); if ($isInteractive=='n') { // Now execute the code for the activity (function defined in lib/Galaxia/config.php) @@ -600,7 +600,7 @@ class Instance extends Base { */ function get_instance_comment($cId) { $iid = $this->instanceId; - $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_comments` where `instanceId`=? and `cId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_comments` where `wf_instance_id`=? and `wf_c_id`=?"; $result = $this->query($query,array((int)$iid,(int)$cId)); $res = $result->fetchRow(); return $res; @@ -615,15 +615,15 @@ class Instance extends Base { } $iid = $this->instanceId; if ($cId) { - $query = "update `".GALAXIA_TABLE_PREFIX."instance_comments` set `title`=?,`comment`=? where `instanceId`=? and `cId`=?"; + $query = "update `".GALAXIA_TABLE_PREFIX."instance_comments` set `wf_title`=?,`wf_comment`=? where `wf_instance_id`=? and `wf_c_id`=?"; $this->query($query,array($title,$comment,(int)$iid,(int)$cId)); } else { $hash = md5($title.$comment); - if ($this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."instance_comments` where `instanceId`=? and `hash`=?",array($iid,$hash))) { + if ($this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."instance_comments` where `wf_instance_id`=? and `wf_hash`=?",array($iid,$hash))) { return false; } $now = date("U"); - $query ="insert into `".GALAXIA_TABLE_PREFIX."instance_comments`(`instanceId`,`user`,`activityId`,`activity`,`title`,`comment`,`timestamp`,`hash`) values(?,?,?,?,?,?,?,?)"; + $query ="insert into `".GALAXIA_TABLE_PREFIX."instance_comments`(`wf_instance_id`,`wf_user`,`wf_activity_id`,`wf_activity`,`wf_title`,`wf_comment`,`wf_timestamp`,`wf_hash`) values(?,?,?,?,?,?,?,?)"; $this->query($query,array((int)$iid,$user,(int)$activityId,$activity,$title,$comment,(int)$now,$hash)); } } @@ -633,7 +633,7 @@ class Instance extends Base { */ function remove_instance_comment($cId) { $iid = $this->instanceId; - $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_comments` where `cId`=? and `instanceId`=?"; + $query = "delete from `".GALAXIA_TABLE_PREFIX."instance_comments` where `wf_c_id`=? and `wf_instance_id`=?"; $this->query($query,array((int)$cId,(int)$iid)); } @@ -642,7 +642,7 @@ class Instance extends Base { */ function get_instance_comments() { $iid = $this->instanceId; - $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_comments` where `instanceId`=? order by ".$this->convert_sortmode("timestamp_desc"); + $query = "select * from `".GALAXIA_TABLE_PREFIX."instance_comments` where `wf_instance_id`=? order by ".$this->convert_sortmode("timestamp_desc"); $result = $this->query($query,array((int)$iid)); $ret = Array(); while($res = $result->fetchRow()) { diff --git a/phpgwapi/inc/galaxia_workflow/src/API/Process.php b/phpgwapi/inc/galaxia_workflow/src/API/Process.php index a0ef8e88fd..a8e84812f1 100644 --- a/phpgwapi/inc/galaxia_workflow/src/API/Process.php +++ b/phpgwapi/inc/galaxia_workflow/src/API/Process.php @@ -22,15 +22,15 @@ class Process extends Base { Loads a process form the database */ function getProcess($pId) { - $query = "select * from `".GALAXIA_TABLE_PREFIX."processes` where `pId`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."processes` where `wf_p_id`=?"; $result = $this->query($query,array($pId)); if(!$result->numRows()) return false; $res = $result->fetchRow(); - $this->name = $res['name']; - $this->description = $res['description']; - $this->normalizedName = $res['normalized_name']; - $this->version = $res['version']; - $this->pId = $res['pId']; + $this->name = $res['wf_name']; + $this->description = $res['wf_description']; + $this->normalizedName = $res['wf_normalized_name']; + $this->version = $res['wf_version']; + $this->pId = $res['wf_p_id']; } /*! @@ -63,7 +63,7 @@ class Process extends Base { */ function getActivityByName($actname) { // Get the activity data - $query = "select * from `".GALAXIA_TABLE_PREFIX."activities` where `pId`=? and `name`=?"; + $query = "select * from `".GALAXIA_TABLE_PREFIX."activities` where `wf_p_id`=? and `wf_name`=?"; $pId = $this->pId; $result = $this->query($query,array($pId,$actname)); if(!$result->numRows()) return false; diff --git a/phpgwapi/inc/galaxia_workflow/src/GUI/GUI.php b/phpgwapi/inc/galaxia_workflow/src/GUI/GUI.php index d2be5116f4..de9e71872b 100644 --- a/phpgwapi/inc/galaxia_workflow/src/GUI/GUI.php +++ b/phpgwapi/inc/galaxia_workflow/src/GUI/GUI.php @@ -23,13 +23,13 @@ class GUI extends Base { { // FIXME: this doesn't support multiple sort criteria //$sort_mode = $this->convert_sortmode($sort_mode); - $sort_mode = str_replace("_"," ",$sort_mode); + $sort_mode = str_replace("__"," ",$sort_mode); - $mid = "where gp.isActive=? and gur.user=?"; + $mid = "where gp.wf_is_active=? and gur.wf_user=?"; $bindvars = array('y',$user); if($find) { $findesc = '%'.$find.'%'; - $mid .= " and ((gp.name like ?) or (gp.description like ?))"; + $mid .= " and ((gp.wf_name like ?) or (gp.wf_description like ?))"; $bindvars[] = $findesc; $bindvars[] = $findesc; } @@ -37,44 +37,44 @@ class GUI extends Base { $mid.= " and ($where) "; } - $query = "select distinct(gp.pId), - gp.isActive, - gp.name as procname, - gp.normalized_name as normalized_name, - gp.version as version + $query = "select distinct(gp.wf_p_id), + gp.wf_is_active, + gp.wf_name as wf_procname, + gp.wf_normalized_name as normalized_name, + gp.wf_version as version from ".GALAXIA_TABLE_PREFIX."processes gp - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.pId=ga.pId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gr.roleId + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gr.wf_role_id $mid order by $sort_mode"; - $query_cant = "select count(distinct(gp.pId)) + $query_cant = "select count(distinct(gp.wf_p_id)) from ".GALAXIA_TABLE_PREFIX."processes gp - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.pId=ga.pId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gr.roleId + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gr.wf_role_id $mid"; $result = $this->query($query,$bindvars,$maxRecords,$offset); $cant = $this->getOne($query_cant,$bindvars); $ret = Array(); while($res = $result->fetchRow()) { // Get instances per activity - $pId=$res['pId']; - $res['activities']=$this->getOne("select count(distinct(ga.activityId)) + $pId=$res['wf_p_id']; + $res['wf_activities']=$this->getOne("select count(distinct(ga.wf_activity_id)) from ".GALAXIA_TABLE_PREFIX."processes gp - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.pId=ga.pId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gr.roleId - where gp.pId=? and gur.user=?", + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gr.wf_role_id + where gp.wf_p_id=? and gur.wf_user=?", array($pId,$user)); - $res['instances']=$this->getOne("select count(distinct(gi.instanceId)) + $res['wf_instances']=$this->getOne("select count(distinct(gi.wf_instance_id)) from ".GALAXIA_TABLE_PREFIX."instances gi - INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.instanceId=gia.instanceId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.activityId=gar.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.roleId=gur.roleId - where gi.pId=? and ((gia.user=?) or (gia.user=? and gur.user=?))", + INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.wf_instance_id=gia.wf_instance_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.wf_activity_id=gar.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.wf_role_id=gur.wf_role_id + where gi.wf_p_id=? and ((gia.wf_user=?) or (gia.wf_user=? and gur.wf_user=?))", array($pId,$user,'*',$user)); $ret[] = $res; } @@ -89,13 +89,13 @@ class GUI extends Base { { // FIXME: this doesn't support multiple sort criteria //$sort_mode = $this->convert_sortmode($sort_mode); - $sort_mode = str_replace("_"," ",$sort_mode); + $sort_mode = str_replace("__"," ",$sort_mode); - $mid = "where gp.isActive=? and gur.user=?"; + $mid = "where gp.wf_is_active=? and gur.wf_user=?"; $bindvars = array('y',$user); if($find) { $findesc = '%'.$find.'%'; - $mid .= " and ((ga.name like ?) or (ga.description like ?))"; + $mid .= " and ((ga.wf_name like ?) or (ga.wf_description like ?))"; $bindvars[] = $findesc; $bindvars[] = $findesc; } @@ -103,41 +103,41 @@ class GUI extends Base { $mid.= " and ($where) "; } - $query = "select distinct(ga.activityId), - ga.name, - ga.type, - gp.name as procname, - ga.isInteractive, - ga.isAutoRouted, - ga.activityId, - gp.version as version, - gp.pId, - gp.isActive + $query = "select distinct(ga.wf_activity_id), + ga.wf_name, + ga.wf_type, + gp.wf_name as wf_procname, + ga.wf_is_interactive, + ga.wf_is_autorouted, + ga.wf_activity_id, + gp.wf_version as wf_version, + gp.wf_p_id, + gp.wf_is_active from ".GALAXIA_TABLE_PREFIX."processes gp - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.pId=ga.pId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gr.roleId + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gr.wf_role_id $mid order by $sort_mode"; - $query_cant = "select count(distinct(ga.activityId)) + $query_cant = "select count(distinct(ga.wf_activity_id)) from ".GALAXIA_TABLE_PREFIX."processes gp - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.pId=ga.pId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gr.roleId + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."roles gr ON gr.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gr.wf_role_id $mid"; $result = $this->query($query,$bindvars,$maxRecords,$offset); $cant = $this->getOne($query_cant,$bindvars); $ret = Array(); while($res = $result->fetchRow()) { // Get instances per activity - $res['instances']=$this->getOne("select count(distinct(gi.instanceId)) + $res['wf_instances']=$this->getOne("select count(distinct(gi.wf_instance_id)) from ".GALAXIA_TABLE_PREFIX."instances gi - INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.instanceId=gia.instanceId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.activityId=gar.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.roleId=gur.roleId - where gia.activityId=? and ((gia.user=?) or (gia.user=? and gur.user=?))", - array($res['activityId'],$user,'*',$user)); + INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.wf_instance_id=gia.wf_instance_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.wf_activity_id=gar.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.wf_role_id=gur.wf_role_id + where gia.wf_activity_id=? and ((gia.wf_user=?) or (gia.wf_user=? and gur.wf_user=?))", + array($res['wf_activity_id'],$user,'*',$user)); $ret[] = $res; } $retval = Array(); @@ -151,13 +151,13 @@ class GUI extends Base { { // FIXME: this doesn't support multiple sort criteria //$sort_mode = $this->convert_sortmode($sort_mode); - $sort_mode = str_replace("_"," ",$sort_mode); + $sort_mode = str_replace("__"," ",$sort_mode); - $mid = "where (gia.user=? or (gia.user=? and gur.user=?))"; + $mid = "where (gia.wf_user=? or (gia.wf_user=? and gur.wf_user=?))"; $bindvars = array($user,'*',$user); if($find) { $findesc = '%'.$find.'%'; - $mid .= " and ((ga.name like ?) or (ga.description like ?))"; + $mid .= " and ((ga.wf_name like ?) or (ga.wf_description like ?))"; $bindvars[] = $findesc; $bindvars[] = $findesc; } @@ -165,34 +165,34 @@ class GUI extends Base { $mid.= " and ($where) "; } - $query = "select distinct(gi.instanceId), - gi.started, - gi.owner, - gia.user, - gi.status, - gia.status as actstatus, - ga.name, - ga.type, - gp.name as procname, - ga.isInteractive, - ga.isAutoRouted, - ga.activityId, - gp.version as version, - gp.pId + $query = "select distinct(gi.wf_instance_id), + gi.wf_started, + gi.wf_owner, + gia.wf_user, + gi.wf_status, + gia.wf_status as wf_act_status, + ga.wf_name, + ga.wf_type, + gp.wf_name as wf_procname, + ga.wf_is_interactive, + ga.wf_is_autorouted, + ga.wf_activity_id, + gp.wf_version as wf_version, + gp.wf_p_id from ".GALAXIA_TABLE_PREFIX."instances gi - INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.instanceId=gia.instanceId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gia.activityId = ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.activityId=gar.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."processes gp ON gp.pId=ga.pId + INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.wf_instance_id=gia.wf_instance_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gia.wf_activity_id = ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.wf_activity_id=gar.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."processes gp ON gp.wf_p_id=ga.wf_p_id $mid order by $sort_mode"; - $query_cant = "select count(distinct(gi.instanceId)) + $query_cant = "select count(distinct(gi.wf_instance_id)) from ".GALAXIA_TABLE_PREFIX."instances gi - INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.instanceId=gia.instanceId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gia.activityId = ga.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.activityId=gar.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.roleId=gar.roleId - INNER JOIN ".GALAXIA_TABLE_PREFIX."processes gp ON gp.pId=ga.pId + INNER JOIN ".GALAXIA_TABLE_PREFIX."instance_activities gia ON gi.wf_instance_id=gia.wf_instance_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activities ga ON gia.wf_activity_id = ga.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gia.wf_activity_id=gar.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gur.wf_role_id=gar.wf_role_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."processes gp ON gp.wf_p_id=ga.wf_p_id $mid"; $result = $this->query($query,$bindvars,$maxRecords,$offset); $cant = $this->getOne($query_cant,$bindvars); @@ -215,7 +215,7 @@ class GUI extends Base { // Users can only abort instances they're currently running, or instances that they're the owner of if(!$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities gia, ".GALAXIA_TABLE_PREFIX."instances gi - where gia.instanceId=gi.instanceId and activityId=? and gia.instanceId=? and (user=? or owner=?)", + where gia.wf_instance_id=gi.wf_instance_id and wf_activity_id=? and gia.wf_instance_id=? and (wf_user=? or wf_owner=?)", array($activityId,$instanceId,$user,$user))) return false; include_once(GALAXIA_LIBRARY.'/src/API/Instance.php'); @@ -236,12 +236,12 @@ class GUI extends Base { // Users can only do exception handling for instances they're currently running, or instances that they're the owner of if(!$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities gia, ".GALAXIA_TABLE_PREFIX."instances gi - where gia.instanceId=gi.instanceId and activityId=? and gia.instanceId=? and (user=? or owner=?)", + where gia.wf_instance_id=gi.wf_instance_id and wf_activity_id=? and gia.wf_instance_id=? and (wf_user=? or wf_owner=?)", array($activityId,$instanceId,$user,$user))) return false; $query = "update ".GALAXIA_TABLE_PREFIX."instances - set status=? - where instanceId=?"; + set wf_status=? + where wf_instance_id=?"; $this->query($query, array('exception',$instanceId)); } @@ -253,12 +253,12 @@ class GUI extends Base { // Users can only resume instances they're currently running, or instances that they're the owner of if(!$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities gia, ".GALAXIA_TABLE_PREFIX."instances gi - where gia.instanceId=gi.instanceId and activityId=? and gia.instanceId=? and (user=? or owner=?)", + where gia.wf_instance_id=gi.wf_instance_id and wf_activity_id=? and gia.wf_instance_id=? and (wf_user=? or wf_owner=?)", array($activityId,$instanceId,$user,$user))) return false; $query = "update ".GALAXIA_TABLE_PREFIX."instances - set status=? - where instanceId=?"; + set wf_status=? + where wf_instance_id=?"; $this->query($query, array('active',$instanceId)); } @@ -268,14 +268,14 @@ class GUI extends Base { if(! ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities - where activityId=? and instanceId=? and user=?", + where wf_activity_id=? and wf_instance_id=? and wf_user=?", array($activityId,$instanceId,$user))) || ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities gia - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=gia.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.roleId=gur.roleId - where gia.instanceId=? and gia.activityId=? and gia.user=? and gur.user=?", + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=gia.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.wf_role_id=gur.wf_role_id + where gia.wf_instance_id=? and gia.wf_activity_id=? and gia.wf_user=? and gur.wf_user=?", array($instanceId,$activityId,'*',$user))) ) return false; include_once(GALAXIA_LIBRARY.'/src/API/Instance.php'); @@ -289,11 +289,11 @@ class GUI extends Base { { if(!$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities - where activityId=? and instanceId=? and user=?", + where wf_activity_id=? and wf_instance_id=? and wf_user=?", array($activityId,$instanceId,$user))) return false; $query = "update ".GALAXIA_TABLE_PREFIX."instance_activities - set user=? - where instanceId=? and activityId=?"; + set wf_user=? + where wf_instance_id=? and wf_activity_id=?"; $this->query($query, array('*',$instanceId,$activityId)); } @@ -302,13 +302,13 @@ class GUI extends Base { // Grab only if roles are ok if(!$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."instance_activities gia - INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.activityId=gia.activityId - INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.roleId=gur.roleId - where gia.instanceId=? and gia.activityId=? and gia.user=? and gur.user=?", + INNER JOIN ".GALAXIA_TABLE_PREFIX."activity_roles gar ON gar.wf_activity_id=gia.wf_activity_id + INNER JOIN ".GALAXIA_TABLE_PREFIX."user_roles gur ON gar.wf_role_id=gur.wf_role_id + where gia.wf_instance_id=? and gia.wf_activity_id=? and gia.wf_user=? and gur.wf_user=?", array($instanceId,$activityId,'*',$user))) return false; $query = "update ".GALAXIA_TABLE_PREFIX."instance_activities - set user=? - where instanceId=? and activityId=?"; + set wf_user=? + where wf_instance_id=? and wf_activity_id=?"; $this->query($query, array($user,$instanceId,$activityId)); } } diff --git a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ActivityManager.php b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ActivityManager.php index 727ef5c116..9f5e9fed44 100644 --- a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ActivityManager.php +++ b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ActivityManager.php @@ -30,9 +30,9 @@ class ActivityManager extends BaseManager { Asociates an activity with a role */ function add_activity_role($activityId, $roleId) { - $query = "delete from `".GALAXIA_TABLE_PREFIX."activity_roles` where `activityId`=? and `roleId`=?"; + $query = "delete from `".GALAXIA_TABLE_PREFIX."activity_roles` where `wf_activity_id`=? and `wf_role_id`=?"; $this->query($query,array($activityId, $roleId)); - $query = "insert into `".GALAXIA_TABLE_PREFIX."activity_roles`(`activityId`,`roleId`) values(?,?)"; + $query = "insert into `".GALAXIA_TABLE_PREFIX."activity_roles`(`wf_activity_id`,`wf_role_id`) values(?,?)"; $this->query($query,array($activityId, $roleId)); } @@ -40,9 +40,9 @@ class ActivityManager extends BaseManager { Gets the roles asociated to an activity */ function get_activity_roles($activityId) { - $query = "select activityId,roles.roleId,roles.name + $query = "select wf_activity_id,roles.wf_role_id,roles.wf_name from ".GALAXIA_TABLE_PREFIX."activity_roles gar, ".GALAXIA_TABLE_PREFIX."roles roles - where roles.roleId = gar.roleId and activityId=?"; + where roles.wf_role_id = gar.wf_role_id and wf_activity_id=?"; $result = $this->query($query,array($activityId)); $ret = Array(); while($res = $result->fetchRow()) { @@ -57,7 +57,7 @@ class ActivityManager extends BaseManager { function remove_activity_role($activityId, $roleId) { $query = "delete from ".GALAXIA_TABLE_PREFIX."activity_roles - where activityId=$activityId and roleId=$roleId"; + where wf_activity_id=$activityId and wf_role_id=$roleId"; $this->query($query); } @@ -66,7 +66,7 @@ class ActivityManager extends BaseManager { */ function transition_exists($pid,$actFromId,$actToId) { - return($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where pId=$pid and actFromId=$actFromId and actToId=$actToId")); + return($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where wf_p_id=$pid and wf_act_from_id=$actFromId and wf_act_to_id=$actToId")); } /*! @@ -82,24 +82,24 @@ class ActivityManager extends BaseManager { $a1 = $this->get_activity($pId, $actFromId); $a2 = $this->get_activity($pId, $actToId); if(!$a1 || !$a2) return false; - if($a1['type'] != 'switch' && $a1['type'] != 'split') { - if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where actFromId=$actFromId")) { + if($a1['wf_type'] != 'switch' && $a1['wf_type'] != 'split') { + if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_from_id=$actFromId")) { $this->error = tra('Cannot add transition only split activities can have more than one outbound transition'); return false; } } // Rule: if act is standalone no transitions allowed - if($a1['type'] == 'standalone' || $a2['type']=='standalone') return false; + if($a1['wf_type'] == 'standalone' || $a2['wf_type']=='standalone') return false; // No inbound to start - if($a2['type'] == 'start') return false; + if($a2['wf_type'] == 'start') return false; // No outbound from end - if($a1['type'] == 'end') return false; + if($a1['wf_type'] == 'end') return false; - $query = "delete from `".GALAXIA_TABLE_PREFIX."transitions` where `actFromId`=? and `actToId`=?"; + $query = "delete from `".GALAXIA_TABLE_PREFIX."transitions` where `wf_act_from_id`=? and `wf_act_to_id`=?"; $this->query($query,array($actFromId, $actToId)); - $query = "insert into `".GALAXIA_TABLE_PREFIX."transitions`(`pId`,`actFromId`,`actToId`) values(?,?,?)"; + $query = "insert into `".GALAXIA_TABLE_PREFIX."transitions`(`wf_p_id`,`wf_act_from_id`,`wf_act_to_id`) values(?,?,?)"; $this->query($query,array($pId, $actFromId, $actToId)); return true; @@ -110,7 +110,7 @@ class ActivityManager extends BaseManager { */ function remove_transition($actFromId, $actToId) { - $query = "delete from ".GALAXIA_TABLE_PREFIX."transitions where actFromId=$actFromId and actToId=$actToId"; + $query = "delete from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_from_id=$actFromId and wf_act_to_id=$actToId"; $this->query($query); return true; } @@ -120,7 +120,7 @@ class ActivityManager extends BaseManager { */ function remove_activity_transitions($pId, $aid) { - $query = "delete from ".GALAXIA_TABLE_PREFIX."transitions where pId=$pId and (actFromId=$aid or actToId=$aid)"; + $query = "delete from ".GALAXIA_TABLE_PREFIX."transitions where wf_p_id=$pId and (wf_act_from_id=$aid or wf_act_to_id=$aid)"; $this->query($query); } @@ -131,9 +131,9 @@ class ActivityManager extends BaseManager { function get_process_transitions($pId,$actid=0) { if(!$actid) { - $query = "select a1.name as actFromName, a2.name as actToName, actFromId, actToId from ".GALAXIA_TABLE_PREFIX."transitions gt,".GALAXIA_TABLE_PREFIX."activities a1, ".GALAXIA_TABLE_PREFIX."activities a2 where gt.actFromId = a1.activityId and gt.actToId = a2.activityId and gt.pId = $pId"; + $query = "select a1.wf_name as wf_act_from_name, a2.wf_name as wf_act_to_name, wf_act_from_id, wf_act_to_id from ".GALAXIA_TABLE_PREFIX."transitions gt,".GALAXIA_TABLE_PREFIX."activities a1, ".GALAXIA_TABLE_PREFIX."activities a2 where gt.wf_act_from_id = a1.wf_activity_id and gt.wf_act_to_id = a2.wf_activity_id and gt.wf_p_id = $pId"; } else { - $query = "select a1.name as actFromName, a2.name as actToName, actFromId, actToId from ".GALAXIA_TABLE_PREFIX."transitions gt,".GALAXIA_TABLE_PREFIX."activities a1, ".GALAXIA_TABLE_PREFIX."activities a2 where gt.actFromId = a1.activityId and gt.actToId = a2.activityId and gt.pId = $pId and (actFromId = $actid)"; + $query = "select a1.wf_name as wf_act_from_name, a2.wf_name as wf_act_to_name, wf_act_from_id, wf_act_to_id from ".GALAXIA_TABLE_PREFIX."transitions gt,".GALAXIA_TABLE_PREFIX."activities a1, ".GALAXIA_TABLE_PREFIX."activities a2 where gt.wf_act_from_id = a1.wf_activity_id and gt.wf_act_to_id = a2.wf_activity_id and gt.wf_p_id = $pId and (wf_act_from_id = $actid)"; } $result = $this->query($query); $ret = Array(); @@ -148,7 +148,7 @@ class ActivityManager extends BaseManager { */ function activity_is_auto_routed($actid) { - return($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where activityId=$actid and isAutoRouted='y'")); + return($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_activity_id=$actid and wf_is_autorouted='y'")); } /*! @@ -157,7 +157,7 @@ class ActivityManager extends BaseManager { */ function get_process_activities($pId) { - $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"; $result = $this->query($query); $ret = Array(); while($res = $result->fetchRow()) { @@ -186,15 +186,15 @@ class ActivityManager extends BaseManager { foreach($nodes as $node) { - if($node['isInteractive']=='y') { + if($node['wf_is_interactive']=='y') { $color='blue'; } else { $color='black'; } - $auto[$node['name']] = $node['isAutoRouted']; - $graph->addNode($node['name'],array('URL'=>"foourl?activityId=".$node['activityId'], - 'label'=>$node['name'], - 'shape' => $this->_get_activity_shape($node['type']), + $auto[$node['wf_name']] = $node['wf_is_autorouted']; + $graph->addNode($node['wf_name'],array('URL'=>"foourl?wf_activity_id=".$node['wf_activity_id'], + 'label'=>$node['wf_name'], + 'shape' => $this->_get_activity_shape($node['wf_type']), 'color' => $color ) @@ -206,12 +206,12 @@ class ActivityManager extends BaseManager { $edges = $this->get_process_transitions($pId); foreach($edges as $edge) { - if($auto[$edge['actFromName']] == 'y') { + if($auto[$edge['wf_actwf_from_name']] == 'y') { $color = 'red'; } else { $color = 'black'; } - $graph->addEdge(array($edge['actFromName'] => $edge['actToName']), array('color'=>$color)); + $graph->addEdge(array($edge['wf_act_from_name'] => $edge['wf_act_to_name']), array('color'=>$color)); } @@ -238,29 +238,29 @@ class ActivityManager extends BaseManager { { $errors = Array(); // Pre rule no cricular activities - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where pId=$pId and actFromId=actToId"); + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where wf_p_id=$pId and wf_act_from_id=wf_act_to_id"); if($cant) { $errors[] = tra('Circular reference found some activity has a transition leading to itself'); } // Rule 1 must have exactly one start and end activity - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and type='start'"); + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_type='start'"); if($cant < 1) { $errors[] = tra('Process does not have a start activity'); } - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and type='end'"); + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_type='end'"); if($cant != 1) { $errors[] = tra('Process does not have exactly one end activity'); } // Rule 2 end must be reachable from start $nodes = Array(); - $endId = $this->getOne("select activityId from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and type='end'"); + $endId = $this->getOne("select wf_activity_id from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_type='end'"); $aux['id']=$endId; $aux['visited']=false; $nodes[] = $aux; - $startId = $this->getOne("select activityId from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and type='start'"); + $startId = $this->getOne("select wf_activity_id from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_type='start'"); $start_node['id']=$startId; $start_node['visited']=true; @@ -269,11 +269,11 @@ class ActivityManager extends BaseManager { $node=&$nodes[$i]; if(!$node['visited']) { $node['visited']=true; - $query = "select actFromId from ".GALAXIA_TABLE_PREFIX."transitions where actToId=".$node['id']; + $query = "select wf_act_from_id from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_to_id=".$node['id']; $result = $this->query($query); $ret = Array(); while($res = $result->fetchRow()) { - $aux['id'] = $res['actFromId']; + $aux['id'] = $res['wf_act_from_id']; $aux['visited']=false; if(!$this->_node_in_list($aux,$nodes)) { $nodes[] = $aux; @@ -291,26 +291,26 @@ class ActivityManager extends BaseManager { //Rule 3: interactive activities must have a role //assigned. //Rule 5: standalone activities can't have transitions - $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId = $pId"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id = $pId"; $result = $this->query($query); while($res = $result->fetchRow()) { - $aid = $res['activityId']; - if($res['isInteractive'] == 'y') { - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where activityId=".$res['activityId']); + $aid = $res['wf_activity_id']; + if($res['wf_is_interactive'] == 'y') { + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where wf_activity_id=".$res['wf_activity_id']); if(!$cant) { - $errors[] = tra('Activity %1 is interactive but has no role assigned', $res['name']); + $errors[] = tra('Activity %1 is interactive but has no role assigned', $res['wf_name']); } } else { - if( $res['type'] != 'end' && $res['isAutoRouted'] == 'n') { - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where activityId=".$res['activityId']); + if( $res['wf_type'] != 'end' && $res['wf_is_autorouted'] == 'n') { + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where wf_activity_id=".$res['wf_activity_id']); if(!$cant) { - $errors[] = tra('Activity %1 is non-interactive and non-autorouted but has no role assigned', $res['name']); + $errors[] = tra('Activity %1 is non-interactive and non-autorouted but has no role assigned', $res['wf_name']); } } } - if($res['type']=='standalone') { - if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where actFromId=$aid or actToId=$aid")) { - $errors[] = tra('Activity %1 is standalone but has transitions', $res['name']); + if($res['wf_type']=='standalone') { + if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_from_id=$aid or wf_act_to_id=$aid")) { + $errors[] = tra('Activity %1 is standalone but has transitions', $res['wf_name']); } } @@ -318,12 +318,12 @@ class ActivityManager extends BaseManager { //Rule4: roles should be mapped - $query = "select * from ".GALAXIA_TABLE_PREFIX."roles where pId = $pId"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."roles where wf_p_id = $pId"; $result = $this->query($query); while($res = $result->fetchRow()) { - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."user_roles where roleId=".$res['roleId']); + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."user_roles where wf_role_id=".$res['wf_role_id']); if(!$cant) { - $errors[] = tra('Role %1 is not mapped', $res['name']); + $errors[] = tra('Role %1 is not mapped', $res['wf_name']); } } @@ -340,7 +340,7 @@ class ActivityManager extends BaseManager { $isValid = (count($errors)==0) ? 'y' : 'n'; - $query = "update ".GALAXIA_TABLE_PREFIX."processes set isValid='$isValid' where pId=$pId"; + $query = "update ".GALAXIA_TABLE_PREFIX."processes set wf_is_valid='$isValid' where wf_p_id=$pId"; $this->query($query); $this->_label_nodes($pId); @@ -361,13 +361,13 @@ class ActivityManager extends BaseManager { function validate_process_sources($pid) { $errors=Array(); - $procname= $this->getOne("select normalized_name from ".GALAXIA_TABLE_PREFIX."processes where pId=$pid"); + $wf_procname= $this->getOne("select wf_normalized_name from ".GALAXIA_TABLE_PREFIX."processes where wf_p_id=$pid"); - $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId=$pid"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pid"; $result = $this->query($query); while($res = $result->fetchRow()) { - $actname = $res['normalized_name']; - $source = GALAXIA_PROCESSES."/$procname/code/activities/$actname".'.php'; + $actname = $res['wf_normalized_name']; + $source = GALAXIA_PROCESSES."/$wf_procname/code/activities/$actname".'.php'; if (!file_exists($source)) { continue; } @@ -377,23 +377,23 @@ class ActivityManager extends BaseManager { $data.=fread($fp,8192); } fclose($fp); - if($res['type']=='standalone') { + if($res['wf_type']=='standalone') { if(strstr($data,'$instance')) { - $errors[] = tra('Activity %1 is standalone and is using the $instance object', $res['name']); + $errors[] = tra('Activity %1 is standalone and is using the $instance object', $res['wf_name']); } } else { - if($res['isInteractive']=='y') { + if($res['wf_is_interactive']=='y') { if(!strstr($data,'$instance->complete()')) { - $errors[] = tra('Activity %1 is interactive so it must use the $instance->complete() method', $res['name']); + $errors[] = tra('Activity %1 is interactive so it must use the $instance->complete() method', $res['wf_name']); } } else { if(strstr($data,'$instance->complete()')) { - $errors[] = tra('Activity %1 is non-interactive so it must not use the $instance->complete() method', $res['name']); + $errors[] = tra('Activity %1 is non-interactive so it must not use the $instance->complete() method', $res['wf_name']); } } - if($res['type']=='switch') { + if($res['wf_type']=='switch') { if(!strstr($data,'$instance->setNextActivity(')) { - $errors[] = tra('Activity %1 is switch so it must use $instance->setNextActivity($actname) method', $res['name']); + $errors[] = tra('Activity %1 is switch so it must use $instance->setNextActivity($actname) method', $res['wf_name']); } } } @@ -407,7 +407,7 @@ class ActivityManager extends BaseManager { function activity_name_exists($pId,$name) { $name = addslashes($this->_normalize_name($name)); - return $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and normalized_name='$name'"); + return $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_normalized_name='$name'"); } @@ -416,7 +416,7 @@ class ActivityManager extends BaseManager { */ function get_activity($pId, $activityId) { - $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and activityId=$activityId"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_activity_id=$activityId"; $result = $this->query($query); $res = $result->fetchRow(); return $res; @@ -427,13 +427,13 @@ class ActivityManager extends BaseManager { */ function list_activities($pId,$offset,$maxRecords,$sort_mode,$find,$where='') { - $sort_mode = str_replace("_"," ",$sort_mode); + $sort_mode = str_replace("__"," ",$sort_mode); if($find) { $findesc = '%'.$find.'%'; - $mid=" where pId=? and ((name like ?) or (description like ?))"; + $mid=" where wf_p_id=? and ((wf_name like ?) or (wf_description like ?))"; $bindvars = array($pId,$findesc,$findesc); } else { - $mid=" where pId=? "; + $mid=" where wf_p_id=? "; $bindvars = array($pId); } if($where) { @@ -445,7 +445,7 @@ class ActivityManager extends BaseManager { $cant = $this->getOne($query_cant,$bindvars); $ret = Array(); while($res = $result->fetchRow()) { - $res['roles'] = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where activityId=?",array($res['activityId'])); + $res['wf_roles'] = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activity_roles where wf_activity_id=?",array($res['wf_activity_id'])); $ret[] = $res; } $retval = Array(); @@ -464,23 +464,23 @@ class ActivityManager extends BaseManager { $pm = new ProcessManager($this->db); $proc_info = $pm->get_process($pId); $actname = $this->_get_normalized_name($activityId); - $query = "delete from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and activityId=$activityId"; + $query = "delete from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_activity_id=$activityId"; $this->query($query); - $query = "select actFromId,actToId from ".GALAXIA_TABLE_PREFIX."transitions where actFromId=$activityId or actToId=$activityId"; + $query = "select wf_act_from_id,wf_act_to_id from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_from_id=$activityId or wf_act_to_id=$activityId"; $result = $this->query($query); while($res = $result->fetchRow()) { - $this->remove_transition($res['actFromId'], $res['actToId']); + $this->remove_transition($res['wf_act_from_id'], $res['wf_act_to_id']); } - $query = "delete from ".GALAXIA_TABLE_PREFIX."activity_roles where activityId=$activityId"; + $query = "delete from ".GALAXIA_TABLE_PREFIX."activity_roles where wf_activity_id=$activityId"; $this->query($query); // And we have to remove the user and compiled files // for this activity - $procname = $proc_info['normalized_name']; - unlink(GALAXIA_PROCESSES."/$procname/code/activities/$actname".'.php'); - if (file_exists(GALAXIA_PROCESSES."/$procname/code/templates/$actname".'.tpl')) { - @unlink(GALAXIA_PROCESSES."/$procname/code/templates/$actname".'.tpl'); + $wf_procname = $proc_info['wf_normalized_name']; + unlink(GALAXIA_PROCESSES."/$wf_procname/code/activities/$actname".'.php'); + if (file_exists(GALAXIA_PROCESSES."/$wf_procname/code/templates/$actname".'.tpl')) { + @unlink(GALAXIA_PROCESSES."/$wf_procname/code/templates/$actname".'.tpl'); } - unlink(GALAXIA_PROCESSES."/$procname/compiled/$actname".'.php'); + unlink(GALAXIA_PROCESSES."/$wf_procname/compiled/$actname".'.php'); return true; } @@ -494,9 +494,9 @@ class ActivityManager extends BaseManager { { $TABLE_NAME = GALAXIA_TABLE_PREFIX."activities"; $now = date("U"); - $vars['lastModif']=$now; - $vars['pId']=$pId; - $vars['normalized_name'] = $this->_normalize_name($vars['name']); + $vars['wf_last_modif']=$now; + $vars['wf_p_id']=$pId; + $vars['wf_normalized_name'] = $this->_normalize_name($vars['wf_name']); $pm = new ProcessManager($this->db); $proc_info = $pm->get_process($pId); @@ -518,27 +518,27 @@ class ActivityManager extends BaseManager { $query.= " $key=$value "; $first = false; } - $query .= " where pId=$pId and activityId=$activityId "; + $query .= " where wf_p_id=$pId and wf_activity_id=$activityId "; $this->query($query); - $newname = $vars['normalized_name']; + $newname = $vars['wf_normalized_name']; // if the activity is changing name then we // should rename the user_file for the activity // remove the old compiled file and recompile // the activity - $user_file_old = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/activities/'.$oldname.'.php'; - $user_file_new = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/activities/'.$newname.'.php'; + $user_file_old = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/activities/'.$oldname.'.php'; + $user_file_new = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/activities/'.$newname.'.php'; rename($user_file_old, $user_file_new); - $user_file_old = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/templates/'.$oldname.'.tpl'; - $user_file_new = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/templates/'.$newname.'.tpl'; + $user_file_old = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/templates/'.$oldname.'.tpl'; + $user_file_new = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/templates/'.$newname.'.tpl'; if ($user_file_old != $user_file_new) { @rename($user_file_old, $user_file_new); } - $compiled_file = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/compiled/'.$oldname.'.php'; + $compiled_file = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/compiled/'.$oldname.'.php'; unlink($compiled_file); $this->compile_activity($pId,$activityId); @@ -546,10 +546,10 @@ class ActivityManager extends BaseManager { } else { // When inserting activity names can't be duplicated - if($this->activity_name_exists($pId, $vars['name'])) { + if($this->activity_name_exists($pId, $vars['wf_name'])) { return false; } - unset($vars['activityId']); + unset($vars['wf_activity_id']); // insert mode $first = true; $query = "insert into $TABLE_NAME("; @@ -568,20 +568,20 @@ class ActivityManager extends BaseManager { } $query .=")"; $this->query($query); - $activityId = $this->getOne("select max(activityId) from $TABLE_NAME where pId=$pId and lastModif=$now"); + $activityId = $this->getOne("select max(wf_activity_id) from $TABLE_NAME where wf_p_id=$pId and wf_last_modif=$now"); $ret = $activityId; if(!$activityId) { - print("select max(activityId) from $TABLE_NAME where pId=$pId and lastModif=$now"); + print("select max(wf_activity_id) from $TABLE_NAME where wf_p_id=$pId and wf_last_modif=$now"); die; } // Should create the code file - $procname = $proc_info["normalized_name"]; - $fw = fopen(GALAXIA_PROCESSES."/$procname/code/activities/".$vars['normalized_name'].'.php','w'); + $wf_procname = $proc_info["wf_normalized_name"]; + $fw = fopen(GALAXIA_PROCESSES."/$wf_procname/code/activities/".$vars['wf_normalized_name'].'.php','w'); fwrite($fw,'<'.'?'.'php'."\n".'?'.'>'); fclose($fw); - if($vars['isInteractive']=='y') { - $fw = fopen(GALAXIA_PROCESSES."/$procname/code/templates/".$vars['normalized_name'].'.tpl','w'); + if($vars['wf_is_interactive']=='y') { + $fw = fopen(GALAXIA_PROCESSES."/$wf_procname/code/templates/".$vars['wf_normalized_name'].'.tpl','w'); if (defined('GALAXIA_TEMPLATE_HEADER') && GALAXIA_TEMPLATE_HEADER) { fwrite($fw,GALAXIA_TEMPLATE_HEADER . "\n"); } @@ -600,7 +600,7 @@ class ActivityManager extends BaseManager { */ function set_interactivity($pId, $actid, $value) { - $query = "update ".GALAXIA_TABLE_PREFIX."activities set isInteractive='$value' where pId=$pId and activityId=$actid"; + $query = "update ".GALAXIA_TABLE_PREFIX."activities set wf_is_interactive='$value' where wf_p_id=$pId and wf_activity_id=$actid"; $this->query($query); // If template does not exist then create template $this->compile_activity($pId,$actid); @@ -611,7 +611,7 @@ class ActivityManager extends BaseManager { */ function set_autorouting($pId, $actid, $value) { - $query = "update ".GALAXIA_TABLE_PREFIX."activities set isAutoRouted='$value' where pId=$pId and activityId=$actid"; + $query = "update ".GALAXIA_TABLE_PREFIX."activities set wf_is_autorouted='$value' where wf_p_id=$pId and wf_activity_id=$actid"; $this->query($query); } @@ -622,18 +622,18 @@ class ActivityManager extends BaseManager { function compile_activity($pId, $activityId) { $act_info = $this->get_activity($pId,$activityId); - $actname = $act_info['normalized_name']; + $actname = $act_info['wf_normalized_name']; $pm = new ProcessManager($this->db); $proc_info = $pm->get_process($pId); - $compiled_file = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/compiled/'.$act_info['normalized_name'].'.php'; - $template_file = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/templates/'.$actname.'.tpl'; - $user_file = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/activities/'.$actname.'.php'; - $pre_file = GALAXIA_LIBRARY.'/compiler/'.$act_info['type'].'_pre.php'; - $pos_file = GALAXIA_LIBRARY.'/compiler/'.$act_info['type'].'_pos.php'; + $compiled_file = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/compiled/'.$act_info['wf_normalized_name'].'.php'; + $template_file = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/templates/'.$actname.'.tpl'; + $user_file = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/activities/'.$actname.'.php'; + $pre_file = GALAXIA_LIBRARY.'/compiler/'.$act_info['wf_type'].'_pre.php'; + $pos_file = GALAXIA_LIBRARY.'/compiler/'.$act_info['wf_type'].'_pos.php'; $fw = fopen($compiled_file,"wb"); // First of all add an include to to the shared code - $shared_file = GALAXIA_PROCESSES.'/'.$proc_info['normalized_name'].'/code/shared.php'; + $shared_file = GALAXIA_PROCESSES.'/'.$proc_info['wf_normalized_name'].'/code/shared.php'; fwrite($fw, '<'."?php include_once('$shared_file'); ?".'>'."\n"); @@ -681,21 +681,21 @@ class ActivityManager extends BaseManager { //Copy the templates - if($act_info['isInteractive']=='y' && !file_exists($template_file)) { + if($act_info['wf_is_interactive']=='y' && !file_exists($template_file)) { $fw = fopen($template_file,'w'); if (defined('GALAXIA_TEMPLATE_HEADER') && GALAXIA_TEMPLATE_HEADER) { fwrite($fw,GALAXIA_TEMPLATE_HEADER . "\n"); } fclose($fw); } - if($act_info['isInteractive']!='y' && file_exists($template_file)) { + if($act_info['wf_is_interactive']!='y' && file_exists($template_file)) { @unlink($template_file); - if (GALAXIA_TEMPLATES && file_exists(GALAXIA_TEMPLATES.'/'.$proc_info['normalized_name']."/$actname.tpl")) { - @unlink(GALAXIA_TEMPLATES.'/'.$proc_info['normalized_name']."/$actname.tpl"); + if (GALAXIA_TEMPLATES && file_exists(GALAXIA_TEMPLATES.'/'.$proc_info['wf_normalized_name']."/$actname.tpl")) { + @unlink(GALAXIA_TEMPLATES.'/'.$proc_info['wf_normalized_name']."/$actname.tpl"); } } if (GALAXIA_TEMPLATES && file_exists($template_file)) { - @copy($template_file,GALAXIA_TEMPLATES.'/'.$proc_info['normalized_name']."/$actname.tpl"); + @copy($template_file,GALAXIA_TEMPLATES.'/'.$proc_info['wf_normalized_name']."/$actname.tpl"); } } @@ -706,8 +706,8 @@ class ActivityManager extends BaseManager { function _get_activity_id_by_name($pid,$name) { $name = addslashes($name); - if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pid and name='$name'")) { - return($this->getOne("select activityId from ".GALAXIA_TABLE_PREFIX."activities where pId=$pid and name='$name'")); + if($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pid and wf_name='$name'")) { + return($this->getOne("select wf_activity_id from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pid and wf_name='$name'")); } else { return ''; } @@ -782,7 +782,7 @@ class ActivityManager extends BaseManager { */ function _get_normalized_name($activityId) { - return $this->getOne("select normalized_name from ".GALAXIA_TABLE_PREFIX."activities where activityId=$activityId"); + return $this->getOne("select wf_normalized_name from ".GALAXIA_TABLE_PREFIX."activities where wf_activity_id=$activityId"); } /*! @@ -796,14 +796,14 @@ class ActivityManager extends BaseManager { ///an empty list of nodes starts the process $nodes = Array(); // the end activity id - $endId = $this->getOne("select activityId from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId and type='end'"); + $endId = $this->getOne("select wf_activity_id from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId and wf_type='end'"); // and the number of total nodes (=activities) - $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId"); + $cant = $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"); $nodes[] = $endId; $label = $cant; $num = $cant; - $query = "update ".GALAXIA_TABLE_PREFIX."activities set flowNum=$cant+1 where pId=$pId"; + $query = "update ".GALAXIA_TABLE_PREFIX."activities set wf_flow_num=$cant+1 where wf_p_id=$pId"; $this->query($query); $seen = array(); @@ -813,13 +813,13 @@ class ActivityManager extends BaseManager { // avoid endless loops if (isset($seen[$node])) continue; $seen[$node] = 1; - $query = "update ".GALAXIA_TABLE_PREFIX."activities set flowNum=$num where activityId=$node"; + $query = "update ".GALAXIA_TABLE_PREFIX."activities set wf_flow_num=$num where wf_activity_id=$node"; $this->query($query); - $query = "select actFromId from ".GALAXIA_TABLE_PREFIX."transitions where actToId=".$node; + $query = "select wf_act_from_id from ".GALAXIA_TABLE_PREFIX."transitions where wf_act_to_id=".$node; $result = $this->query($query); $ret = Array(); while($res = $result->fetchRow()) { - $newnodes[] = $res['actFromId']; + $newnodes[] = $res['wf_act_from_id']; } } $num--; @@ -828,8 +828,8 @@ class ActivityManager extends BaseManager { } - $min = $this->getOne("select min(flowNum) from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId"); - $query = "update ".GALAXIA_TABLE_PREFIX."activities set flowNum=flowNum-$min where pId=$pId"; + $min = $this->getOne("select min(wf_flow_num) from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"); + $query = "update ".GALAXIA_TABLE_PREFIX."activities set wf_flow_num=wf_flow_num-$min where wf_p_id=$pId"; $this->query($query); //$query = "update ".GALAXIA_TABLE_PREFIX."activities set flowNum=0 where flowNum=$cant+1"; diff --git a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/InstanceManager.php b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/InstanceManager.php index 076a920a97..7d2b48e1e1 100644 --- a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/InstanceManager.php +++ b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/InstanceManager.php @@ -22,7 +22,7 @@ class InstanceManager extends BaseManager { function get_instance_activities($iid) { - $query = "select ga.type,ga.isInteractive,ga.isAutoRouted,gi.pId,ga.activityId,ga.name,gi.instanceId,gi.status,gia.activityId,gia.user,gi.started,gia.status as actstatus from ".GALAXIA_TABLE_PREFIX."activities ga,".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where ga.activityId=gia.activityId and gi.instanceId=gia.instanceId and gi.instanceId=$iid"; + $query = "select ga.wf_type,ga.wf_is_interactive,ga.wf_is_autorouted,gi.wf_p_id,ga.wf_activity_id,ga.wf_name,gi.wf_instance_id,gi.wf_status,gia.wf_activity_id,gia.wf_user,gi.wf_started,gia.wf_status as wf_act_status from ".GALAXIA_TABLE_PREFIX."activities ga,".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where ga.wf_activity_id=gia.wf_activity_id and gi.wf_instance_id=gia.wf_instance_id and gi.wf_instance_id=$iid"; $result = $this->query($query); $ret = Array(); while($res = $result->fetchRow()) { @@ -34,50 +34,50 @@ class InstanceManager extends BaseManager { function get_instance($iid) { - $query = "select * from ".GALAXIA_TABLE_PREFIX."instances gi where instanceId=$iid"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."instances gi where wf_instance_id=$iid"; $result = $this->query($query); $res = $result->fetchRow(); - $res['workitems']=$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."workitems where instanceId=$iid"); + $res['wf_workitems']=$this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."workitems where wf_instance_id=$iid"); return $res; } function get_instance_properties($iid) { - $prop = unserialize($this->getOne("select properties from ".GALAXIA_TABLE_PREFIX."instances gi where instanceId=$iid")); + $prop = unserialize($this->getOne("select wf_properties from ".GALAXIA_TABLE_PREFIX."instances gi where wf_instance_id=$iid")); return $prop; } function set_instance_properties($iid,&$prop) { $props = addslashes(serialize($prop)); - $query = "update ".GALAXIA_TABLE_PREFIX."instances set properties='$props' where instanceId=$iid"; + $query = "update ".GALAXIA_TABLE_PREFIX."instances set wf_properties='$props' where wf_instance_id=$iid"; $this->query($query); } function set_instance_owner($iid,$owner) { - $query = "update ".GALAXIA_TABLE_PREFIX."instances set owner='$owner' where instanceId=$iid"; + $query = "update ".GALAXIA_TABLE_PREFIX."instances set wf_owner='$owner' where wf_instance_id=$iid"; $this->query($query); } function set_instance_status($iid,$status) { - $query = "update ".GALAXIA_TABLE_PREFIX."instances set status='$status' where instanceId=$iid"; + $query = "update ".GALAXIA_TABLE_PREFIX."instances set wf_status='$status' where wf_instance_id=$iid"; $this->query($query); } function set_instance_destination($iid,$activityId) { - $query = "delete from ".GALAXIA_TABLE_PREFIX."instance_activities where instanceId=$iid"; + $query = "delete from ".GALAXIA_TABLE_PREFIX."instance_activities where wf_instance_id=$iid"; $this->query($query); - $query = "insert into ".GALAXIA_TABLE_PREFIX."instance_activities(instanceId,activityId,user,status) + $query = "insert into ".GALAXIA_TABLE_PREFIX."instance_activities(wf_instance_id,wf_activity_id,wf_user,wf_status) values($iid,$activityId,'*','running')"; $this->query($query); } function set_instance_user($iid,$activityId,$user) { - $query = "update ".GALAXIA_TABLE_PREFIX."instance_activities set user='$user', status='running' where instanceId=$iid and activityId=$activityId"; + $query = "update ".GALAXIA_TABLE_PREFIX."instance_activities set wf_user='$user', wf_status='running' where wf_instance_id=$iid and wf_activity_id=$activityId"; $this->query($query); } diff --git a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ProcessManager.php b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ProcessManager.php index eda8e6eb4c..a29783e5ab 100644 --- a/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ProcessManager.php +++ b/phpgwapi/inc/galaxia_workflow/src/ProcessManager/ProcessManager.php @@ -29,7 +29,7 @@ class ProcessManager extends BaseManager { */ function activate_process($pId) { - $query = "update ".GALAXIA_TABLE_PREFIX."processes set isActive='y' where pId=$pId"; + $query = "update ".GALAXIA_TABLE_PREFIX."processes set wf_is_active='y' where wf_p_id=$pId"; $this->query($query); $msg = sprintf(tra('Process %d has been activated'),$pId); $this->notify_all(3,$msg); @@ -40,7 +40,7 @@ class ProcessManager extends BaseManager { */ function deactivate_process($pId) { - $query = "update ".GALAXIA_TABLE_PREFIX."processes set isActive='n' where pId=$pId"; + $query = "update ".GALAXIA_TABLE_PREFIX."processes set wf_is_active='n' where wf_p_id=$pId"; $this->query($query); $msg = sprintf(tra('Process %d has been deactivated'),$pId); $this->notify_all(3,$msg); @@ -54,15 +54,15 @@ class ProcessManager extends BaseManager { // $out = ''."\n"; $proc_info = $this->get_process($pId); - $procname = $proc_info['normalized_name']; - $out.= ' '.htmlspecialchars($proc_info['name']).''."\n"; - $out.= ' '.htmlspecialchars($proc_info['isValid']).''."\n"; - $out.= ' '.htmlspecialchars($proc_info['version']).''."\n"; - $out.= ' '.htmlspecialchars($proc_info['isActive']).''."\n"; - $out.=' '.htmlspecialchars($proc_info['description']).''."\n"; - $out.= ' '.date("d/m/Y [h:i:s]",$proc_info['lastModif']).''."\n"; + $wf_procname = $proc_info['wf_normalized_name']; + $out.= ' '.htmlspecialchars($proc_info['wf_name']).''."\n"; + $out.= ' '.htmlspecialchars($proc_info['wf_is_valid']).''."\n"; + $out.= ' '.htmlspecialchars($proc_info['wf_version']).''."\n"; + $out.= ' '.htmlspecialchars($proc_info['wf_is_active']).''."\n"; + $out.=' '.htmlspecialchars($proc_info['wf_description']).''."\n"; + $out.= ' '.date("d/m/Y [h:i:s]",$proc_info['wf_last_modif']).''."\n"; $out.= ' '."\n"; // Now loop over activities - $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId"; + $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"; $result = $this->query($query); $out.=' '."\n"; $am = new ActivityManager($this->db); while($res = $result->fetchRow()) { - $name = $res['normalized_name']; + $name = $res['wf_normalized_name']; $out.=' '."\n"; - $out.=' '.htmlspecialchars($res['name']).''."\n"; - $out.=' '.htmlspecialchars($res['type']).''."\n"; - $out.=' '.htmlspecialchars($res['description']).''."\n"; - $out.=' '.date("d/m/Y [h:i:s]",$res['lastModif']).''."\n"; - $out.=' '.$res['isInteractive'].''."\n"; - $out.=' '.$res['isAutoRouted'].''."\n"; + $out.=' '.htmlspecialchars($res['wf_name']).''."\n"; + $out.=' '.htmlspecialchars($res['wf_type']).''."\n"; + $out.=' '.htmlspecialchars($res['wf_description']).''."\n"; + $out.=' '.date("d/m/Y [h:i:s]",$res['wf_last_modif']).''."\n"; + $out.=' '.$res['wf_is_interactive'].''."\n"; + $out.=' '.$res['wf_is_autorouted'].''."\n"; $out.=' '."\n"; - $roles = $am->get_activity_roles($res['activityId']); + $roles = $am->get_activity_roles($res['wf_activity_id']); foreach($roles as $role) { - $out.=' '.htmlspecialchars($role['name']).''."\n"; + $out.=' '.htmlspecialchars($role['wf_name']).''."\n"; } $out.=' '."\n"; $out.=' '; - if($res['isInteractive']=='y') { + if($res['wf_is_interactive']=='y') { $out.='