Big changes everywhere only to support postgres

This commit is contained in:
alpeb 2004-09-03 22:56:15 +00:00
parent 33e65129be
commit 4b6047655f
10 changed files with 526 additions and 541 deletions

View File

@ -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));
}
}

View File

@ -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;$i<count($this->activities);$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;$i<count($this->activities);$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;$i<count($this->activities);$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;$i<count($this->activities);$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;$i<count($this->activities);$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;$i<count($this->activities);$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;$i<count($this->activities);$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()) {

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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";

View File

@ -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);
}

View File

@ -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 {
// <process>
$out = '<process>'."\n";
$proc_info = $this->get_process($pId);
$procname = $proc_info['normalized_name'];
$out.= ' <name>'.htmlspecialchars($proc_info['name']).'</name>'."\n";
$out.= ' <isValid>'.htmlspecialchars($proc_info['isValid']).'</isValid>'."\n";
$out.= ' <version>'.htmlspecialchars($proc_info['version']).'</version>'."\n";
$out.= ' <isActive>'.htmlspecialchars($proc_info['isActive']).'</isActive>'."\n";
$out.=' <description>'.htmlspecialchars($proc_info['description']).'</description>'."\n";
$out.= ' <lastModif>'.date("d/m/Y [h:i:s]",$proc_info['lastModif']).'</lastModif>'."\n";
$wf_procname = $proc_info['wf_normalized_name'];
$out.= ' <name>'.htmlspecialchars($proc_info['wf_name']).'</name>'."\n";
$out.= ' <isValid>'.htmlspecialchars($proc_info['wf_is_valid']).'</isValid>'."\n";
$out.= ' <version>'.htmlspecialchars($proc_info['wf_version']).'</version>'."\n";
$out.= ' <isActive>'.htmlspecialchars($proc_info['wf_is_active']).'</isActive>'."\n";
$out.=' <description>'.htmlspecialchars($proc_info['wf_description']).'</description>'."\n";
$out.= ' <lastModif>'.date("d/m/Y [h:i:s]",$proc_info['wf_last_modif']).'</lastModif>'."\n";
$out.= ' <sharedCode><![CDATA[';
$fp=fopen(GALAXIA_PROCESSES."/$procname/code/shared.php","r");
$fp=fopen(GALAXIA_PROCESSES."/$wf_procname/code/shared.php","r");
while(!feof($fp)) {
$line=fread($fp,8192);
$out.=$line;
@ -70,37 +70,37 @@ class ProcessManager extends BaseManager {
fclose($fp);
$out.= ' ]]></sharedCode>'."\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.=' <activities>'."\n";
$am = new ActivityManager($this->db);
while($res = $result->fetchRow()) {
$name = $res['normalized_name'];
$name = $res['wf_normalized_name'];
$out.=' <activity>'."\n";
$out.=' <name>'.htmlspecialchars($res['name']).'</name>'."\n";
$out.=' <type>'.htmlspecialchars($res['type']).'</type>'."\n";
$out.=' <description>'.htmlspecialchars($res['description']).'</description>'."\n";
$out.=' <lastModif>'.date("d/m/Y [h:i:s]",$res['lastModif']).'</lastModif>'."\n";
$out.=' <isInteractive>'.$res['isInteractive'].'</isInteractive>'."\n";
$out.=' <isAutoRouted>'.$res['isAutoRouted'].'</isAutoRouted>'."\n";
$out.=' <name>'.htmlspecialchars($res['wf_name']).'</name>'."\n";
$out.=' <type>'.htmlspecialchars($res['wf_type']).'</type>'."\n";
$out.=' <description>'.htmlspecialchars($res['wf_description']).'</description>'."\n";
$out.=' <lastModif>'.date("d/m/Y [h:i:s]",$res['wf_last_modif']).'</lastModif>'."\n";
$out.=' <isInteractive>'.$res['wf_is_interactive'].'</isInteractive>'."\n";
$out.=' <isAutoRouted>'.$res['wf_is_autorouted'].'</isAutoRouted>'."\n";
$out.=' <roles>'."\n";
$roles = $am->get_activity_roles($res['activityId']);
$roles = $am->get_activity_roles($res['wf_activity_id']);
foreach($roles as $role) {
$out.=' <role>'.htmlspecialchars($role['name']).'</role>'."\n";
$out.=' <role>'.htmlspecialchars($role['wf_name']).'</role>'."\n";
}
$out.=' </roles>'."\n";
$out.=' <code><![CDATA[';
$fp=fopen(GALAXIA_PROCESSES."/$procname/code/activities/$name.php","r");
$fp=fopen(GALAXIA_PROCESSES."/$wf_procname/code/activities/$name.php","r");
while(!feof($fp)) {
$line=fread($fp,8192);
$out.=$line;
}
fclose($fp);
$out.=' ]]></code>';
if($res['isInteractive']=='y') {
if($res['wf_is_interactive']=='y') {
$out.=' <template><![CDATA[';
$fp=fopen(GALAXIA_PROCESSES."/$procname/code/templates/$name.tpl","r");
$fp=fopen(GALAXIA_PROCESSES."/$wf_procname/code/templates/$name.tpl","r");
while(!feof($fp)) {
$line=fread($fp,8192);
$out.=$line;
@ -115,13 +115,13 @@ class ProcessManager extends BaseManager {
$transitions = $am->get_process_transitions($pId);
foreach($transitions as $tran) {
$out.=' <transition>'."\n";
$out.=' <from>'.htmlspecialchars($tran['actFromName']).'</from>'."\n";
$out.=' <to>'.htmlspecialchars($tran['actToName']).'</to>'."\n";
$out.=' <from>'.htmlspecialchars($tran['wf_act_from_name']).'</from>'."\n";
$out.=' <to>'.htmlspecialchars($tran['wf_act_to_name']).'</to>'."\n";
$out.=' </transition>'."\n";
}
$out.=' </transitions>'."\n";
$out.= '</process>'."\n";
//$fp = fopen(GALAXIA_PROCESSES."/$procname/$procname.xml","w");
//$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/$wf_procname.xml","w");
//fwrite($fp,$out);
//fclose($fp);
return $out;
@ -240,37 +240,37 @@ class ProcessManager extends BaseManager {
$pid = $this->replace_process(0,$vars,false);
//Put the shared code
$proc_info = $this->get_process($pid);
$procname = $proc_info['normalized_name'];
$fp = fopen(GALAXIA_PROCESSES."/$procname/code/shared.php","w");
$wf_procname = $proc_info['wf_normalized_name'];
$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/code/shared.php","w");
fwrite($fp,$data['sharedCode']);
fclose($fp);
$actids = Array();
// Foreach activity create activities
foreach($data['activities'] as $activity) {
$vars = Array(
'name' => $activity['name'],
'description' => $activity['description'],
'type' => $activity['type'],
'lastModif' => $activity['lastModif'],
'isInteractive' => $activity['isInteractive'],
'isAutoRouted' => $activity['isAutoRouted']
'name' => $activity['wf_name'],
'description' => $activity['wf_description'],
'type' => $activity['wf_type'],
'lastModif' => $activity['wf_lastModif'],
'isInteractive' => $activity['wf_is_interactive'],
'isAutoRouted' => $activity['wf_is_autorouted']
);
$actname=$am->_normalize_name($activity['name']);
$actname=$am->_normalize_name($activity['wf_name']);
$actid = $am->replace_activity($pid,0,$vars);
$fp = fopen(GALAXIA_PROCESSES."/$procname/code/activities/$actname".'.php',"w");
$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/code/activities/$actname".'.php',"w");
fwrite($fp,$activity['code']);
fclose($fp);
if($activity['isInteractive']=='y') {
$fp = fopen(GALAXIA_PROCESSES."/$procname/code/templates/$actname".'.tpl',"w");
$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/code/templates/$actname".'.tpl',"w");
fwrite($fp,$activity['template']);
fclose($fp);
}
$actids[$activity['name']] = $am->_get_activity_id_by_name($pid,$activity['name']);
$actname = $am->_normalize_name($activity['name']);
$actids[$activity['name']] = $am->_get_activity_id_by_name($pid,$activity['wf_name']);
$actname = $am->_normalize_name($activity['wf_name']);
$now = date("U");
foreach($activity['roles'] as $role) {
foreach($activity['wf_roles'] as $role) {
$vars = Array(
'name' => $role,
'description' => $role,
@ -297,7 +297,7 @@ class ProcessManager extends BaseManager {
$am->build_process_graph($pid);
unset($am);
unset($rm);
$msg = sprintf(tra('Process %s %s imported'),$proc_info['name'],$proc_info['version']);
$msg = sprintf(tra('Process %s %s imported'),$proc_info['wf_name'],$proc_info['wf_version']);
$this->notify_all(2,$msg);
}
@ -312,75 +312,75 @@ class ProcessManager extends BaseManager {
{
$oldpid = $pId;
$proc_info = $this->get_process($pId);
$name = $proc_info['name'];
$name = $proc_info['wf_name'];
if(!$proc_info) return false;
// Now update the version
$version = $this->_new_version($proc_info['version'],$minor);
while($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."processes where name='$name' and version='$version'")) {
$version = $this->_new_version($proc_info['wf_version'],$minor);
while($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."processes where wf_name='$name' and wf_version='$version'")) {
$version = $this->_new_version($version,$minor);
}
// Make new versions unactive
$proc_info['version'] = $version;
$proc_info['isActive'] = 'n';
$proc_info['wf_version'] = $version;
$proc_info['wf_is_active'] = 'n';
// create a new process, but don't create start/end activities
$pid = $this->replace_process(0, $proc_info, false);
// And here copy all the activities & so
$am = new ActivityManager($this->db);
$query = "select * from ".GALAXIA_TABLE_PREFIX."activities where pId=$oldpid";
$query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$oldpid";
$result = $this->query($query);
$newaid = array();
while($res = $result->fetchRow()) {
$oldaid = $res['activityId'];
$oldaid = $res['wf_activity_id'];
$newaid[$oldaid] = $am->replace_activity($pid,0,$res);
}
// create transitions
$query = "select * from ".GALAXIA_TABLE_PREFIX."transitions where pId=$oldpid";
$query = "select * from ".GALAXIA_TABLE_PREFIX."transitions where wf_p_id=$oldpid";
$result = $this->query($query);
while($res = $result->fetchRow()) {
if (empty($newaid[$res['actFromId']]) || empty($newaid[$res['actToId']])) {
if (empty($newaid[$res['wf_act_from_id']]) || empty($newaid[$res['wf_act_io_id']])) {
continue;
}
$am->add_transition($pid,$newaid[$res['actFromId']],$newaid[$res['actToId']]);
$am->add_transition($pid,$newaid[$res['wf_act_from_id']],$newaid[$res['wf_act_to_id']]);
}
// create roles
$rm = new RoleManager($this->db);
$query = "select * from ".GALAXIA_TABLE_PREFIX."roles where pId=$oldpid";
$query = "select * from ".GALAXIA_TABLE_PREFIX."roles where wf_p_id=$oldpid";
$result = $this->query($query);
$newrid = array();
while($res = $result->fetchRow()) {
if(!$rm->role_name_exists($pid,$res['name'])) {
if(!$rm->role_name_exists($pid,$res['wf_name'])) {
$rid=$rm->replace_role($pid,0,$res);
} else {
$rid = $rm->get_role_id($pid,$res['name']);
$rid = $rm->get_role_id($pid,$res['wf_name']);
}
$newrid[$res['roleId']] = $rid;
$newrid[$res['wf_role_id']] = $rid;
}
// map users to roles
if (count($newrid) > 0) {
$query = "select * from ".GALAXIA_TABLE_PREFIX."user_roles where pId=$oldpid";
$query = "select * from ".GALAXIA_TABLE_PREFIX."user_roles where wf_p_id=$oldpid";
$result = $this->query($query);
while($res = $result->fetchRow()) {
if (empty($newrid[$res['roleId']])) {
if (empty($newrid[$res['wf_role_id']])) {
continue;
}
$rm->map_user_to_role($pid,$res['user'],$newrid[$res['roleId']]);
$rm->map_user_to_role($pid,$res['wf_user'],$newrid[$res['wf_role_id']]);
}
}
// add roles to activities
if (count($newaid) > 0 && count($newrid ) > 0) {
$query = "select * from ".GALAXIA_TABLE_PREFIX."activity_roles where activityId in (" . join(', ',array_keys($newaid)) . ")";
$query = "select * from ".GALAXIA_TABLE_PREFIX."activity_roles where wf_activity_id in (" . join(', ',array_keys($newaid)) . ")";
$result = $this->query($query);
while($res = $result->fetchRow()) {
if (empty($newaid[$res['activityId']]) || empty($newrid[$res['roleId']])) {
if (empty($newaid[$res['wf_activity_id']]) || empty($newrid[$res['wf_role_id']])) {
continue;
}
$am->add_activity_role($newaid[$res['activityId']],$newrid[$res['roleId']]);
$am->add_activity_role($newaid[$res['wf_activity_id']],$newrid[$res['wf_role_id']]);
}
}
//Now since we are copying a process we should copy
//the old directory structure to the new directory
$oldname = $proc_info['normalized_name'];
$oldname = $proc_info['wf_normalized_name'];
$newname = $this->_get_normalized_name($pid);
$this->_rec_copy(GALAXIA_PROCESSES."/$oldname",GALAXIA_PROCESSES."/$newname");
@ -398,7 +398,7 @@ class ProcessManager extends BaseManager {
function process_name_exists($name,$version)
{
$name = addslashes($this->_normalize_name($name,$version));
return $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."processes where normalized_name='$name'");
return $this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."processes where wf_normalized_name='$name'");
}
@ -407,7 +407,7 @@ class ProcessManager extends BaseManager {
*/
function get_process($pId)
{
$query = "select * from ".GALAXIA_TABLE_PREFIX."processes where pId=$pId";
$query = "select * from ".GALAXIA_TABLE_PREFIX."processes where wf_p_id=$pId";
$result = $this->query($query);
if(!$result->numRows()) return false;
$res = $result->fetchRow();
@ -422,7 +422,7 @@ class ProcessManager extends BaseManager {
$sort_mode = $this->convert_sortmode($sort_mode);
if($find) {
$findesc = '%'.$find.'%';
$mid=" where ((name like ?) or (description like ?))";
$mid=" where ((wf_name like ?) or (wf_description like ?))";
$bindvars = array($findesc,$findesc);
} else {
$mid="";
@ -454,7 +454,7 @@ class ProcessManager extends BaseManager {
*/
function invalidate_process($pid)
{
$query = "update ".GALAXIA_TABLE_PREFIX."processes set isValid='n' where pId=$pid";
$query = "update ".GALAXIA_TABLE_PREFIX."processes set wf_is_valid='n' where wf_p_id=$pid";
$this->query($query);
}
@ -467,16 +467,16 @@ class ProcessManager extends BaseManager {
$name = $this->_get_normalized_name($pId);
$aM = new ActivityManager($this->db);
// Remove process activities
$query = "select activityId from ".GALAXIA_TABLE_PREFIX."activities where pId=$pId";
$query = "select wf_activity_id from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId";
$result = $this->query($query);
while($res = $result->fetchRow()) {
$aM->remove_activity($pId,$res['activityId']);
$aM->remove_activity($pId,$res['wf_activity_id']);
}
// Remove process roles
$query = "delete from ".GALAXIA_TABLE_PREFIX."roles where pId=$pId";
$query = "delete from ".GALAXIA_TABLE_PREFIX."roles where wf_p_id=$pId";
$this->query($query);
$query = "delete from ".GALAXIA_TABLE_PREFIX."user_roles where pId=$pId";
$query = "delete from ".GALAXIA_TABLE_PREFIX."user_roles where wf_p_id=$pId";
$this->query($query);
// Remove the directory structure
@ -487,7 +487,7 @@ class ProcessManager extends BaseManager {
$this->_remove_directory(GALAXIA_TEMPLATES."/$name",true);
}
// And finally remove the proc
$query = "delete from ".GALAXIA_TABLE_PREFIX."processes where pId=$pId";
$query = "delete from ".GALAXIA_TABLE_PREFIX."processes where wf_p_id=$pId";
$this->query($query);
$msg = sprintf(tra('Process %s removed'),$name);
$this->notify_all(5,$msg);
@ -504,8 +504,8 @@ class ProcessManager extends BaseManager {
{
$TABLE_NAME = GALAXIA_TABLE_PREFIX."processes";
$now = date("U");
$vars['lastModif']=$now;
$vars['normalized_name'] = $this->_normalize_name($vars['name'],$vars['version']);
$vars['wf_last_modif']=$now;
$vars['wf_normalized_name'] = $this->_normalize_name($vars['wf_name'],$vars['wf_version']);
foreach($vars as $key=>$value)
{
$vars[$key]=addslashes($value);
@ -522,21 +522,21 @@ class ProcessManager extends BaseManager {
$query.= " $key=$value ";
$first = false;
}
$query .= " where pId=$pId ";
$query .= " where wf_p_id=$pId ";
$this->query($query);
// Note that if the name is being changed then
// the directory has to be renamed!
$oldname = $old_proc['normalized_name'];
$newname = $vars['normalized_name'];
$oldname = $old_proc['wf_normalized_name'];
$newname = $vars['wf_normalized_name'];
if ($newname != $oldname) {
rename(GALAXIA_PROCESSES."/$oldname",GALAXIA_PROCESSES."/$newname");
}
$msg = sprintf(tra('Process %s has been updated'),$vars['name']);
$msg = sprintf(tra('Process %s has been updated'),$vars['wf_name']);
$this->notify_all(3,$msg);
} else {
unset($vars['pId']);
unset($vars['wf_p_id']);
// insert mode
$name = $this->_normalize_name($vars['name'],$vars['version']);
$name = $this->_normalize_name($vars['wf_name'],$vars['wf_version']);
$this->_create_directory_structure($name);
$first = true;
$query = "insert into $TABLE_NAME(";
@ -555,30 +555,30 @@ class ProcessManager extends BaseManager {
}
$query .=")";
$this->query($query);
$pId = $this->getOne("select max(pId) from $TABLE_NAME where lastModif=$now");
$pId = $this->getOne("select max(wf_p_id) from $TABLE_NAME where wf_last_modif=$now");
// Now automatically add a start and end activity
// unless importing ($create = false)
if($create) {
$aM= new ActivityManager($this->db);
$vars1 = Array(
'name' => 'start',
'description' => 'default start activity',
'type' => 'start',
'isInteractive' => 'y',
'isAutoRouted' => 'y'
'wf_name' => 'start',
'wf_description' => 'default start activity',
'wf_type' => 'start',
'wf_is_interactive' => 'y',
'wf_is_autorouted' => 'y'
);
$vars2 = Array(
'name' => 'end',
'description' => 'default end activity',
'type' => 'end',
'isInteractive' => 'n',
'isAutoRouted' => 'y'
'wf_name' => 'end',
'wf_description' => 'default end activity',
'wf_type' => 'end',
'wf_is_interactive' => 'n',
'wf_is_autorouted' => 'y'
);
$aM->replace_activity($pId,0,$vars1);
$aM->replace_activity($pId,0,$vars2);
}
$msg = sprintf(tra('Process %s has been created'),$vars['name']);
$msg = sprintf(tra('Process %s has been created'),$vars['wf_name']);
$this->notify_all(4,$msg);
}
// Get the id
@ -592,7 +592,7 @@ class ProcessManager extends BaseManager {
function _get_normalized_name($pId)
{
$info = $this->get_process($pId);
return $info['normalized_name'];
return $info['wf_normalized_name'];
}
/*!

View File

@ -31,7 +31,7 @@ class RoleManager extends BaseManager {
function get_role_id($pid,$name)
{
$name = addslashes($name);
return ($this->getOne("select roleId from ".GALAXIA_TABLE_PREFIX."roles where name='$name' and pId=$pid"));
return ($this->getOne("select wf_role_id from ".GALAXIA_TABLE_PREFIX."roles where wf_name='$name' and wf_p_id=$pid"));
}
/*!
@ -39,7 +39,7 @@ class RoleManager extends BaseManager {
*/
function get_role($pId, $roleId)
{
$query = "select * from `".GALAXIA_TABLE_PREFIX."roles` where `pId`=? and `roleId`=?";
$query = "select * from `".GALAXIA_TABLE_PREFIX."roles` where `wf_p_id`=? and `wf_role_id`=?";
$result = $this->query($query,array($pId, $roleId));
$res = $result->fetchRow();
return $res;
@ -51,7 +51,7 @@ class RoleManager extends BaseManager {
function role_name_exists($pid,$name)
{
$name = addslashes($name);
return ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."roles where pId=$pid and name='$name'"));
return ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."roles where wf_p_id=$pid and wf_name='$name'"));
}
/*!
@ -59,9 +59,9 @@ class RoleManager extends BaseManager {
*/
function map_user_to_role($pId,$user,$roleId)
{
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `roleId`=? and `user`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `wf_role_id`=? and `wf_user`=?";
$this->query($query,array($roleId, $user));
$query = "insert into `".GALAXIA_TABLE_PREFIX."user_roles`(`pId`, `user`, `roleId`) values(?,?,?)";
$query = "insert into `".GALAXIA_TABLE_PREFIX."user_roles`(`wf_p_id`, `wf_user`, `wf_role_id`) values(?,?,?)";
$this->query($query,array($pId,$user,$roleId));
}
@ -70,7 +70,7 @@ class RoleManager extends BaseManager {
*/
function remove_mapping($user,$roleId)
{
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `user`=? and `roleId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `wf_user`=? and `wf_role_id`=?";
$this->query($query,array($user, $roleId));
}
@ -82,14 +82,14 @@ class RoleManager extends BaseManager {
if($find) {
// no more quoting here - this is done in bind vars already
$findesc = '%'.$find.'%';
$query = "select `name`,`gr`.`roleId`,`user` from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`roleId`=`gur`.`roleId` and `gur`.`pId`=? and ((`name` like ?) or (`user` like ?) or (`description` like ?)) order by $sort_mode";
$query = "select `wf_name`,`gr`.`wf_role_id`,`wf_user` from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`wf_role_id`=`gur`.`wf_role_id` and `gur`.`wf_p_id`=? and ((`wf_name` like ?) or (`wf_user` like ?) or (`wf_description` like ?)) order by $sort_mode";
$result = $this->query($query,array($pId,$findesc,$findesc,$findesc), $maxRecords, $offset);
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`roleId`=`gur`.`roleId` and `gur`.`pId`=? and ((`name` like ?) or (`user` like ?) or (`description` like ?))";
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`wf_role_id`=`gur`.`wf_role_id` and `gur`.`wf_p_id`=? and ((`wf_name` like ?) or (`wf_user` like ?) or (`wf_description` like ?))";
$cant = $this->getOne($query_cant,array($pId,$findesc,$findesc,$findesc));
} else {
$query = "select `name`,`gr`.`roleId`,`user` from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`roleId`=`gur`.`roleId` and `gur`.`pId`=? order by $sort_mode";
$query = "select `wf_name`,`gr`.`wf_role_id`,`wf_user` from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`wf_role_id`=`gur`.`wf_role_id` and `gur`.`wf_p_id`=? order by $sort_mode";
$result = $this->query($query,array($pId), $maxRecords, $offset);
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`roleId`=`gur`.`roleId` and `gur`.`pId`=?";
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."roles` gr, `".GALAXIA_TABLE_PREFIX."user_roles` gur where `gr`.`wf_role_id`=`gur`.`wf_role_id` and `gur`.`wf_p_id`=?";
$cant = $this->getOne($query_cant,array($pId));
}
$ret = Array();
@ -111,10 +111,10 @@ class RoleManager extends BaseManager {
if($find) {
// no more quoting here - this is done in bind vars already
$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) {
@ -141,11 +141,11 @@ class RoleManager extends BaseManager {
*/
function remove_role($pId, $roleId)
{
$query = "delete from `".GALAXIA_TABLE_PREFIX."roles` where `pId`=? and `roleId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."roles` where `wf_p_id`=? and `wf_role_id`=?";
$this->query($query,array($pId, $roleId));
$query = "delete from `".GALAXIA_TABLE_PREFIX."activity_roles` where `roleId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."activity_roles` where `wf_role_id`=?";
$this->query($query,array($roleId));
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `roleId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."user_roles` where `wf_role_id`=?";
$this->query($query,array($roleId));
}
@ -159,8 +159,8 @@ class RoleManager extends BaseManager {
{
$TABLE_NAME = GALAXIA_TABLE_PREFIX."roles";
$now = date("U");
$vars['lastModif']=$now;
$vars['pId']=$pId;
$vars['wf_last_modif']=$now;
$vars['wf_p_id']=$pId;
foreach($vars as $key=>$value)
{
@ -177,14 +177,14 @@ class RoleManager extends BaseManager {
$query.= " $key=$value ";
$first = false;
}
$query .= " where pId=$pId and roleId=$roleId ";
$query .= " where wf_p_id=$pId and wf_role_id=$roleId ";
$this->query($query);
} else {
$name = $vars['name'];
if ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."roles where pId=$pId and name='$name'")) {
$name = $vars['wf_name'];
if ($this->getOne("select count(*) from ".GALAXIA_TABLE_PREFIX."roles where wf_p_id=$pId and wf_name='$name'")) {
return false;
}
unset($vars['roleId']);
unset($vars['wf_role_id']);
// insert mode
$first = true;
$query = "insert into $TABLE_NAME(";
@ -203,7 +203,7 @@ class RoleManager extends BaseManager {
}
$query .=")";
$this->query($query);
$roleId = $this->getOne("select max(roleId) from $TABLE_NAME where pId=$pId and lastModif=$now");
$roleId = $this->getOne("select max(wf_role_id) from $TABLE_NAME where wf_p_id=$pId and wf_last_modif=$now");
}
// Get the id
return $roleId;

View File

@ -9,16 +9,16 @@ class ProcessMonitor extends Base {
function monitor_stats() {
$res = Array();
$res['active_processes'] = $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."processes` where `isActive`=?",array('y'));
$res['active_processes'] = $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."processes` where `wf_is_active`=?",array('y'));
$res['processes'] = $this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."processes`");
$result = $this->query("select distinct(`pId`) from `".GALAXIA_TABLE_PREFIX."instances` where `status`=?",array('active'));
$result = $this->query("select distinct(`wf_p_id`) from `".GALAXIA_TABLE_PREFIX."instances` where `wf_status`=?",array('active'));
$res['running_processes'] = $result->numRows();
// get the number of instances per status
$query = "select status, count(*) as num_instances from ".GALAXIA_TABLE_PREFIX."instances group by status";
$query = "select wf_status, count(*) as num_instances from ".GALAXIA_TABLE_PREFIX."instances group by wf_status";
$result = $this->query($query);
$status = array();
while($info = $result->fetchRow()) {
$status[$info['status']] = $info['num_instances'];
$status[$info['wf_status']] = $info['wf_num_instances'];
}
$res['active_instances'] = isset($status['active']) ? $status['active'] : 0;
$res['completed_instances'] = isset($status['completed']) ? $status['completed'] : 0;
@ -28,49 +28,49 @@ class ProcessMonitor extends Base {
}
function update_instance_status($iid,$status) {
$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,$iid));
}
function update_instance_activity_status($iid,$activityId,$status) {
$query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `status`=? where `instanceId`=? and `activityId`=?";
$query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_status`=? where `wf_instance_id`=? and `wf_activity_id`=?";
$this->query($query,array($status,$iid,$activityId));
}
function remove_instance($iid) {
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?";
$this->query($query,array($iid));
$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($iid));
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `instanceId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `wf_instance_id`=?";
$this->query($query,array($iid));
}
function remove_aborted() {
$query="select `instanceId` from `".GALAXIA_TABLE_PREFIX."instances` where `status`=?";
$query="select `wf_instance_id` from `".GALAXIA_TABLE_PREFIX."instances` where `wf_status`=?";
$result = $this->query($query,array('aborted'));
while($res = $result->fetchRow()) {
$iid = $res['instanceId'];
$query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?";
$iid = $res['wf_instance_id'];
$query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=?";
$this->query($query,array($iid));
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?";
$this->query($query,array($iid));
}
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `status`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `wf_status`=?";
$this->query($query,array('aborted'));
}
function remove_all($pId) {
$query="select `instanceId` from `".GALAXIA_TABLE_PREFIX."instances` where `pId`=?";
$query="select `wf_instance_id` from `".GALAXIA_TABLE_PREFIX."instances` where `wf_p_id`=?";
$result = $this->query($query,array($pId));
while($res = $result->fetchRow()) {
$iid = $res['instanceId'];
$query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `instanceId`=?";
$iid = $res['wf_instance_id'];
$query = "delete from `".GALAXIA_TABLE_PREFIX."instance_activities` where `wf_instance_id`=?";
$this->query($query,array($iid));
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?";
$this->query($query,array($iid));
}
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `pId`=?";
$query = "delete from `".GALAXIA_TABLE_PREFIX."instances` where `wf_p_id`=?";
$this->query($query,array($pId));
}
@ -79,7 +79,7 @@ class ProcessMonitor extends Base {
$sort_mode = $this->convert_sortmode($sort_mode);
if($find) {
$findesc = '%'.$find.'%';
$mid=" where ((name like ?) or (description like ?))";
$mid=" where ((wf_name like ?) or (wf_description like ?))";
$bindvars = array($findesc,$findesc);
} else {
$mid="";
@ -99,7 +99,7 @@ class ProcessMonitor extends Base {
$cant = $this->getOne($query_cant,$bindvars);
$ret = Array();
while($res = $result->fetchRow()) {
$pId = $res['pId'];
$pId = $res['wf_p_id'];
// Number of active instances
$res['active_instances'] = 0;
// Number of exception instances
@ -120,14 +120,14 @@ class ProcessMonitor extends Base {
return $retval;
}
// get number of instances and timing statistics per process and status
$query = "select pId, status, count(*) as num_instances,
min(ended - started) as min_time, avg(ended - started) as avg_time, max(ended - started) as max_time
from ".GALAXIA_TABLE_PREFIX."instances where pId in (" . join(', ', array_keys($ret)) . ") group by pId, status";
$query = "select wf_p_id, wf_status, count(*) as num_instances,
min(wf_ended - wf_started) as min_time, avg(wf_ended - wf_started) as avg_time, max(wf_ended - wf_started) as max_time
from ".GALAXIA_TABLE_PREFIX."instances where wf_p_id in (" . join(', ', array_keys($ret)) . ") group by wf_p_id, wf_status";
$result = $this->query($query);
while($res = $result->fetchRow()) {
$pId = $res['pId'];
$pId = $res['wf_p_id'];
if (!isset($ret[$pId])) continue;
switch ($res['status']) {
switch ($res['wf_status']) {
case 'active':
$ret[$pId]['active_instances'] = $res['num_instances'];
$ret[$pId]['all_instances'] += $res['num_instances'];
@ -148,10 +148,10 @@ class ProcessMonitor extends Base {
}
}
// get number of activities per process
$query = "select pId, count(*) as num_activities
$query = "select wf_p_id, count(*) as num_activities
from ".GALAXIA_TABLE_PREFIX."activities
where pId in (" . join(', ', array_keys($ret)) . ")
group by pId";
where wf_p_id in (" . join(', ', array_keys($ret)) . ")
group by wf_p_id";
$result = $this->query($query);
while($res = $result->fetchRow()) {
$pId = $res['pId'];
@ -168,7 +168,7 @@ class ProcessMonitor extends Base {
$sort_mode = $this->convert_sortmode($sort_mode);
if($find) {
$findesc = '%'.$find.'%';
$mid=" where ((ga.name like ?) or (ga.description like ?))";
$mid=" where ((ga.wf_name like ?) or (ga.wf_description like ?))";
$bindvars = array($findesc,$findesc);
} else {
$mid="";
@ -182,9 +182,9 @@ class ProcessMonitor extends Base {
$mid.= " where ($where) ";
}
}
$query = "select gp.`name` as `procname`, gp.`version`, ga.*
$query = "select gp.`wf_name` as `wf_procname`, gp.`wf_version`, ga.*
from ".GALAXIA_TABLE_PREFIX."activities ga
left join ".GALAXIA_TABLE_PREFIX."processes gp on gp.pId=ga.pId
left join ".GALAXIA_TABLE_PREFIX."processes gp on gp.wf_p_id=ga.wf_p_id
$mid order by $sort_mode";
$query_cant = "select count(*) from ".GALAXIA_TABLE_PREFIX."activities ga $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
@ -192,16 +192,16 @@ class ProcessMonitor extends Base {
$ret = Array();
while($res = $result->fetchRow()) {
// Number of active instances
$aid = $res['activityId'];
$res['active_instances']=$this->getOne("select count(gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.instanceId=gia.instanceId and gia.activitYId=$aid and gi.status='active' and pId=".$res['pId']);
$aid = $res['wf_activity_id'];
$res['active_instances']=$this->getOne("select count(gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.wf_instance_id=gia.wf_instance_id and gia.wf_activity_id=$aid and gi.wf_status='active' and wf_p_id=".$res['wf_p_id']);
// activities of completed instances are all removed from the instance_activities table for some reason, so we need to look at workitems
$res['completed_instances']=$this->getOne("select count(distinct gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."workitems gw where gi.instanceId=gw.instanceId and gw.activityId=$aid and gi.status='completed' and pId=".$res['pId']);
$res['completed_instances']=$this->getOne("select count(distinct gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."workitems gw where gi.wf_instance_id=gw.wf_instance_id and gw.wf_activity_id=$aid and gi.wf_status='completed' and wf_p_id=".$res['wf_p_id']);
// activities of aborted instances are all removed from the instance_activities table for some reason, so we need to look at workitems
$res['aborted_instances']=$this->getOne("select count(distinct gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."workitems gw where gi.instanceId=gw.instanceId and gw.activityId=$aid and gi.status='aborted' and pId=".$res['pId']);
$res['exception_instances']=$this->getOne("select count(gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.instanceId=gia.instanceId and gia.activityId=$aid and gi.status='exception' and pId=".$res['pId']);
$res['act_running_instances']=$this->getOne("select count(gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.instanceId=gia.instanceId and gia.activityId=$aid and gia.status='running' and pId=".$res['pId']);
$res['aborted_instances']=$this->getOne("select count(distinct gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."workitems gw where gi.wf_instance_id=gw.wf_instance_id and gw.wf_activity_id=$aid and gi.wf_status='aborted' and wf_p_id=".$res['wf_p_id']);
$res['exception_instances']=$this->getOne("select count(gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.wf_instance_id=gia.wf_instance_id and gia.wf_activity_id=$aid and gi.wf_status='exception' and wf_p_id=".$res['wf_p_id']);
$res['act_running_instances']=$this->getOne("select count(gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.wf_instance_id=gia.wf_instance_id and gia.wf_activity_id=$aid and gia.wf_status='running' and wf_p_id=".$res['wf_p_id']);
// completed activities are removed from the instance_activities table unless they're part of a split for some reason, so this won't work
// $res['act_completed_instances']=$this->getOne("select count(gi.instanceId) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.instanceId=gia.instanceId and gia.activityId=$aid and gia.status='completed' and pId=".$res['pId']);
// $res['act_completed_instances']=$this->getOne("select count(gi.wf_instance_id) from ".GALAXIA_TABLE_PREFIX."instances gi,".GALAXIA_TABLE_PREFIX."instance_activities gia where gi.wf_instance_id=gia.wf_instance_id and gia.activityId=$aid and gia.status='completed' and pId=".$res['pId']);
$res['act_completed_instances'] = 0;
$ret[$aid] = $res;
}
@ -211,14 +211,14 @@ class ProcessMonitor extends Base {
$retval["cant"] = $cant;
return $retval;
}
$query = "select activityId, count(distinct instanceId) as num_instances, min(ended - started) as min_time, avg(ended - started) as avg_time, max(ended - started) as max_time
$query = "select wf_activity_id, count(distinct wf_instance_id) as num_instances, min(wf_ended - wf_started) as min_time, avg(wf_ended - wf_started) as avg_time, max(wf_ended - wf_started) as max_time
from ".GALAXIA_TABLE_PREFIX."workitems
where activityId in (" . join(', ', array_keys($ret)) . ")
group by activityId";
where wf_activity_id in (" . join(', ', array_keys($ret)) . ")
group by wf_activity_id";
$result = $this->query($query);
while($res = $result->fetchRow()) {
// Number of active instances
$aid = $res['activityId'];
$aid = $res['wf_activity_id'];
if (!isset($ret[$aid])) continue;
$ret[$aid]['act_completed_instances'] = $res['num_instances'] - $ret[$aid]['aborted_instances'];
$ret[$aid]['duration'] = array('min' => $res['min_time'], 'avg' => $res['avg_time'], 'max' => $res['max_time']);
@ -243,20 +243,20 @@ class ProcessMonitor extends Base {
$mid.= " where ($where) ";
}
}
$query = "select gp.`pId`, ga.`isInteractive`, gi.`owner`, gp.`name` as `procname`, gp.`version`, ga.`type`,";
$query.= " ga.`activityId`, ga.`name`, gi.`instanceId`, gi.`status`, gia.`activityId`, gia.`user`, gi.`started`, gi.`ended`, gia.`status` as actstatus ";
$query.=" from `".GALAXIA_TABLE_PREFIX."instances` gi LEFT JOIN `".GALAXIA_TABLE_PREFIX."instance_activities` gia ON gi.`instanceId`=gia.`instanceId` ";
$query.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."activities` ga ON gia.`activityId` = ga.`activityId` ";
$query.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."processes` gp ON gp.`pId`=gi.`pId` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select gp.`wf_p_id`, ga.`wf_is_interactive`, gi.`wf_owner`, gp.`wf_name` as `wf_wf_procname`, gp.`wf_version`, ga.`wf_type`,";
$query.= " ga.`wf_activity_id`, ga.`wf_name`, gi.`wf_instance_id`, gi.`wf_status`, gia.`wf_activity_id`, gia.`wf_user`, gi.`wf_started`, gi.`wf_ended`, gia.`wf_status` as wf_act_status ";
$query.=" from `".GALAXIA_TABLE_PREFIX."instances` gi LEFT JOIN `".GALAXIA_TABLE_PREFIX."instance_activities` gia ON gi.`wf_instance_id`=gia.`wf_instance_id` ";
$query.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."activities` ga ON gia.`wf_activity_id` = ga.`wf_activity_id` ";
$query.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."processes` gp ON gp.`wf_p_id`=gi.`wf_p_id` $mid order by ".$this->convert_sortmode($sort_mode);
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."instances` gi LEFT JOIN `".GALAXIA_TABLE_PREFIX."instance_activities` gia ON gi.`instanceId`=gia.`instanceId` ";
$query_cant.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."activities` ga ON gia.`activityId` = ga.`activityId` LEFT JOIN `".GALAXIA_TABLE_PREFIX."processes` gp ON gp.`pId`=gi.`pId` $mid";
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."instances` gi LEFT JOIN `".GALAXIA_TABLE_PREFIX."instance_activities` gia ON gi.`wf_instance_id`=gia.`wf_instance_id` ";
$query_cant.= "LEFT JOIN `".GALAXIA_TABLE_PREFIX."activities` ga ON gia.`wf_activity_id` = ga.`wf_activity_id` LEFT JOIN `".GALAXIA_TABLE_PREFIX."processes` gp ON gp.`wf_p_id`=gi.`wf_p_id` $mid";
$result = $this->query($query,$wherevars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$wherevars);
$ret = Array();
while($res = $result->fetchRow()) {
$iid = $res['instanceId'];
$res['workitems']=$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."workitems` where `instanceId`=?",array($iid));
$iid = $res['wf_instance_id'];
$res['workitems']=$this->getOne("select count(*) from `".GALAXIA_TABLE_PREFIX."workitems` where `wf_instance_id`=?",array($iid));
$ret[$iid] = $res;
}
$retval = Array();
@ -266,93 +266,93 @@ class ProcessMonitor extends Base {
}
function monitor_list_all_processes($sort_mode = 'name_asc', $where = '') {
function monitor_list_all_processes($sort_mode = 'wf_name_asc', $where = '') {
if (!empty($where)) {
$where = " where ($where) ";
}
$query = "select `name`,`version`,`pId` from `".GALAXIA_TABLE_PREFIX."processes` $where order by ".$this->convert_sortmode($sort_mode);
$query = "select `wf_name`,`wf_version`,`wf_p_id` from `".GALAXIA_TABLE_PREFIX."processes` $where order by ".$this->convert_sortmode($sort_mode);
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$pId = $res['pId'];
$pId = $res['wf_p_id'];
$ret[$pId] = $res;
}
return $ret;
}
function monitor_list_all_activities($sort_mode = 'name_asc', $where = '') {
function monitor_list_all_activities($sort_mode = 'wf_name_asc', $where = '') {
if (!empty($where)) {
$where = " where ($where) ";
}
$query = "select `name`,`activityId` from `".GALAXIA_TABLE_PREFIX."activities` $where order by ".$this->convert_sortmode($sort_mode);
$query = "select `wf_name`,`wf_activity_id` from `".GALAXIA_TABLE_PREFIX."activities` $where order by ".$this->convert_sortmode($sort_mode);
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$aid = $res['activityId'];
$aid = $res['wf_activity_id'];
$ret[$aid] = $res;
}
return $ret;
}
function monitor_list_statuses() {
$query = "select distinct(`status`) from `".GALAXIA_TABLE_PREFIX."instances`";
$query = "select distinct(`wf_status`) from `".GALAXIA_TABLE_PREFIX."instances`";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$ret[] = $res['status'];
$ret[] = $res['wf_status'];
}
return $ret;
}
function monitor_list_users() {
$query = "select distinct(`user`) from `".GALAXIA_TABLE_PREFIX."instance_activities`";
$query = "select distinct(`wf_user`) from `".GALAXIA_TABLE_PREFIX."instance_activities`";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$ret[] = $res['user'];
$ret[] = $res['wf_user'];
}
return $ret;
}
function monitor_list_wi_users() {
$query = "select distinct(`user`) from `".GALAXIA_TABLE_PREFIX."workitems`";
$query = "select distinct(`wf_user`) from `".GALAXIA_TABLE_PREFIX."workitems`";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$ret[] = $res['user'];
$ret[] = $res['wf_user'];
}
return $ret;
}
function monitor_list_owners() {
$query = "select distinct(`owner`) from `".GALAXIA_TABLE_PREFIX."instances`";
$query = "select distinct(`wf_owner`) from `".GALAXIA_TABLE_PREFIX."instances`";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$ret[] = $res['owner'];
$ret[] = $res['wf_owner'];
}
return $ret;
}
function monitor_list_activity_types() {
$query = "select distinct(`type`) from `".GALAXIA_TABLE_PREFIX."activities`";
$query = "select distinct(`wf_type`) from `".GALAXIA_TABLE_PREFIX."activities`";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow()) {
$ret[] = $res['type'];
$ret[] = $res['wf_type'];
}
return $ret;
}
function monitor_get_workitem($itemId) {
$query = "select gw.`orderId`,ga.`name`,ga.`type`,ga.`isInteractive`,gp.`name` as `procname`,gp.`version`,";
$query.= "gw.`itemId`,gw.`properties`,gw.`user`,`started`,`ended`-`started` as duration ";
$query.= "from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp where ga.`activityId`=gw.`activityId` and ga.`pId`=gp.`pId` and `itemId`=?";
$query = "select gw.`wf_order_id`,ga.`wf_name`,ga.`wf_type`,ga.`wf_is_interactive`,gp.`wf_name` as `wf_wf_procname`,gp.`wf_version`,";
$query.= "gw.`wf_item_id`,gw.`wf_properties`,gw.`wf_user`,`wf_started`,`wf_ended`-`wf_started` as wf_duration ";
$query.= "from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp where ga.`wf_activity_id`=gw.`wf_activity_id` and ga.`wf_p_id`=gp.`wf_p_id` and `wf_item_id`=?";
$result = $this->query($query, array($itemId));
$res = $result->fetchRow();
$res['properties'] = unserialize($res['properties']);
$res['wf_properties'] = unserialize($res['wf_properties']);
return $res;
}
@ -364,18 +364,18 @@ class ProcessMonitor extends Base {
}
if($find) {
$findesc = $this->qstr('%'.$find.'%');
$mid.=" and (`properties` like $findesc)";
$mid.=" and (`wf_properties` like $findesc)";
}
// TODO: retrieve instance status as well
$query = "select `itemId`,`ended`-`started` as duration,ga.`isInteractive`, ga.`type`,gp.`name` as procname,gp.`version`,ga.`name` as actname,";
$query.= "ga.`activityId`,`instanceId`,`orderId`,`properties`,`started`,`ended`,`user` from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp ";
$query.= "where gw.`activityId`=ga.`activityId` and ga.`pId`=gp.`pId` $mid order by gp.`pId` desc,".$this->convert_sortmode($sort_mode);
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp where gw.`activityId`=ga.`activityId` and ga.`pId`=gp.`pId` $mid";
$query = "select `wf_item_id`,`wf_ended`-`wf_started` as wf_duration,ga.`wf_is_interactive`, ga.`wf_type`,gp.`wf_name` as wf_procname,gp.`wf_version`,ga.`wf_name` as wf_act_name,";
$query.= "ga.`wf_activity_id`,`wf_instance_id`,`wf_order_id`,`wf_properties`,`wf_started`,`wf_ended`,`wf_user` from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp ";
$query.= "where gw.`wf_activity_id`=ga.`wf_activity_id` and ga.`wf_p_id`=gp.`wf_p_id` $mid order by gp.`wf_p_id` desc,".$this->convert_sortmode($sort_mode);
$query_cant = "select count(*) from `".GALAXIA_TABLE_PREFIX."workitems` gw,`".GALAXIA_TABLE_PREFIX."activities` ga,`".GALAXIA_TABLE_PREFIX."processes` gp where gw.`wf_activity_id`=ga.`wf_activity_id` and ga.`wf_p_id`=gp.`wf_p_id` $mid";
$result = $this->query($query,$wherevars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$wherevars);
$ret = Array();
while($res = $result->fetchRow()) {
$itemId = $res['itemId'];
$itemId = $res['wf_item_id'];
$ret[$itemId] = $res;
}
$retval = Array();

View File

@ -85,23 +85,8 @@ class Base extends Observable {
function convert_sortmode($sort_mode) {
global $ADODB_LASTDB;
switch ($ADODB_LASTDB) {
case "pgsql72":
case "postgres7":
case "oci8":
case "sybase":
// Postgres needs " " around column names
//preg_replace("#([A-Za-z]+)#","\"\$1\"",$sort_mode);
$sort_mode = str_replace("_", "\" ", $sort_mode);
$sort_mode = "\"" . $sort_mode;
break;
case "mysql3":
case "mysql":
default:
$sort_mode = str_replace("_", "` ", $sort_mode);
$sort_mode = "`" . $sort_mode;
break;
}
$sort_mode = str_replace("__", "` ", $sort_mode);
$sort_mode = "`" . $sort_mode;
return $sort_mode;
}