function remove_process($pId) { $this->deactivate_process($pId); $name = $this->_get_normalized_name($pId); $aM = new ActivityManager($this->db); // Remove process activities $query = "select `activityId` from `" . GALAXIA_TABLE_PREFIX . "activities` where `pId`=?"; $result = $this->query($query, array($pId)); while ($res = $result->fetchRow()) { $aM->remove_activity($pId, $res['activityId']); } // Remove process roles $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "roles` WHERE `pId`=?"; $this->query($query, array($pId)); $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "user_roles` WHERE `pId`=?"; $this->query($query, array($pId)); // Remove all instance data $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "workitems` USING `"; $query .= GALAXIA_TABLE_PREFIX . "workitems` gw , `" . GALAXIA_TABLE_PREFIX . "instances` gi "; $query .= "WHERE gw.`instanceId` = gi.`instanceId` AND gi.`pId` = ?"; $this->query($query, array($pId)); $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "instance_activities` USING `"; $query .= GALAXIA_TABLE_PREFIX . "instance_activities` gia , `" . GALAXIA_TABLE_PREFIX . "instances` gi "; $query .= "WHERE gia.`instanceId` = gi.`instanceId` AND gi.`pId` = ?"; $this->query($query, array($pId)); $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "instance_comments` USING `"; $query .= GALAXIA_TABLE_PREFIX . "instance_comments` gic , `" . GALAXIA_TABLE_PREFIX . "instances` gi "; $query .= "WHERE gic.`instanceId` = gi.`instanceId` AND gi.`pId` = ?"; $this->query($query, array($pId)); $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "instances` WHERE `pId` = ?"; $this->query($query); // Remove the directory structure if (!empty($name) && is_dir(GALAXIA_PROCESSES . "/{$name}")) { $this->_remove_directory(GALAXIA_PROCESSES . "/{$name}", true); } if (GALAXIA_TEMPLATES && !empty($name) && is_dir(GALAXIA_TEMPLATES . "/{$name}")) { $this->_remove_directory(GALAXIA_TEMPLATES . "/{$name}", true); } // And finally remove the proc $query = "delete from `" . GALAXIA_TABLE_PREFIX . "processes` where `pId`=?"; $this->query($query, array($pId)); $msg = sprintf(tra('Process %s removed'), $name); $this->notify_all(5, $msg); return true; }
function remove_process($p_id) { $this->deactivate_process($p_id); $name = $this->_get_normalized_name($p_id); // Remove process activities $aM = new ActivityManager(); $query = "select `activity_id` from `" . GALAXIA_TABLE_PREFIX . "activities` where `p_id`=?"; $result = $this->mDb->query($query, array($p_id)); while ($res = $result->fetchRow()) { $aM->remove_activity($p_id, $res['activity_id']); } // Remove process roles $rM = new RoleManager(); $query = "select `role_id` from `" . GALAXIA_TABLE_PREFIX . "roles` where `p_id`=?"; $result = $this->mDb->query($query, array($p_id)); while ($res = $result->fetchRow()) { $rM->remove_role($p_id, $res['role_id']); } $query = "delete from `" . GALAXIA_TABLE_PREFIX . "instances` where `p_id`=?"; $this->mDb->query($query, array($p_id)); // Remove the directory structure if (!empty($name) && is_dir(GALAXIA_PROCESSES . "/{$name}")) { $this->_remove_directory(GALAXIA_PROCESSES . "/{$name}", true); } if (GALAXIA_TEMPLATES && !empty($name) && is_dir(GALAXIA_TEMPLATES . "/{$name}")) { $this->_remove_directory(GALAXIA_TEMPLATES . "/{$name}", true); } // And finally remove the proc $query = "delete from `" . GALAXIA_TABLE_PREFIX . "processes` where `p_id`={$p_id}"; $this->mDb->query($query); $msg = sprintf(tra('Process %s removed'), $name); $this->notify_all(5, $msg); return true; }