From d25ef3b1c36602cd40872887dcf1279603f83b6a Mon Sep 17 00:00:00 2001 From: Carlos Pacha Date: Fri, 4 Feb 2011 16:32:13 +0000 Subject: [PATCH] this bug 5882 was solved, we added a way to validate it --- workflow/engine/classes/model/Step.php | 59 +++++++++++++++++++ workflow/engine/js/dbConnections/main.js | 9 ++- .../dbConnections/dbConnectionsAjax.php | 11 +++- .../xmlform/dbConnections/dbConnections.xml | 4 +- 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/workflow/engine/classes/model/Step.php b/workflow/engine/classes/model/Step.php index cf0321b73..d007d7b5e 100644 --- a/workflow/engine/classes/model/Step.php +++ b/workflow/engine/classes/model/Step.php @@ -454,6 +454,65 @@ class Step extends BaseStep { } } + /** + * verify if a dbconnection is assigned in some dynaforms or triggers + * + * @param string $sproUid the uid of the process + * @param string $sdbsUid the uid of the db connection + */ + function loadInfoAssigConnecctionDB($sproUid,$sdbsUid){ + + require_once ( "classes/model/DynaformPeer.php" ); + G::LoadSystem('dynaformhandler'); + $swDynaform = true; + $swTriggers = true; + //we are looking for triggers if there is at least one db connection + $oC = new Criteria('workflow'); + $oC->add(TriggersPeer::PRO_UID, $sproUid); + $oDataset = TriggersPeer::doSelectRS($oC); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + //print $sproUid; + while($aRowT = $oDataset->getRow()){ + $uidConnection =preg_quote($sdbsUid) ; + if( strrpos($uidConnection,$aRowT['TRI_WEBBOT']) ) { + $swTriggers = false; + } + $oDataset->next(); + } + //we are looking for dynaforms if there is at least one db connection + $oC = new Criteria('workflow'); + $oC->add(DynaformPeer::PRO_UID, $sproUid); + $oDataset = DynaformPeer::doSelectRS($oC); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while($aRow = $oDataset->getRow()){ + if($aRow['DYN_TYPE']=='xmlform') { + $dynHandler = new dynaFormHandler(PATH_DYNAFORM.$aRow['DYN_FILENAME'].".xml"); + $dynFields = $dynHandler->getFields(); + $sxmlgrid = ''; + $sType = ''; + $check=0; + foreach($dynFields as $field){ + $ssqlConnection = $this->getAttribute($field, 'sqlconnection'); + if($ssqlConnection==$sdbsUid) + $swDynaform=false; + }//end foreach + + }//end if + $oDataset->next(); + }//end while + //is there a connecction? + if ($swDynaform && $swTriggers){ + //there is no db connection, you can delete this connection + return true; + } else { + //there is a db connection, you can not delete this connection + return false; + } + die; + } + /** * Get related steps for a determinated case * diff --git a/workflow/engine/js/dbConnections/main.js b/workflow/engine/js/dbConnections/main.js index 8d490c1ae..dce01b2ec 100755 --- a/workflow/engine/js/dbConnections/main.js +++ b/workflow/engine/js/dbConnections/main.js @@ -157,8 +157,15 @@ function editDbConnection(DBS_UID) oRPC.make(); } -function deleteDbConnection(DBS_UID) +function deleteDbConnection(DBS_UID,PRO_UID) { + + isokDependent = ajax_function(PROCESS_REQUEST_FILE,'loadInfoAssigConnecctionDB','DBS_UID='+DBS_UID+'&PRO_UID='+PRO_UID,'POST'); + + if(!isokDependent){ + msgBox(G_STRINGS.ID_DB_CONNECTION_ASSIGN,"alert"); + return; + } new leimnud.module.app.confirm().make({ label:G_STRINGS.ID_MSG_CONFIRM_REMOVE_DBS, action:function(){ diff --git a/workflow/engine/methods/dbConnections/dbConnectionsAjax.php b/workflow/engine/methods/dbConnections/dbConnectionsAjax.php index a8290e1f5..d6a6bfe76 100644 --- a/workflow/engine/methods/dbConnections/dbConnectionsAjax.php +++ b/workflow/engine/methods/dbConnections/dbConnectionsAjax.php @@ -30,8 +30,8 @@ * @Param var action from POST request */ -if( isset($_POST['action']) ){ - $action = $_POST['action']; +if( isset($_POST['action']) || isset($_POST['function']) ){ + $action = (isset($_POST['action']))?$_POST['action']:$_POST['function']; } else { throw new Exception('dbconnections Fatal error, No action defined!...'); } @@ -50,7 +50,12 @@ G::LoadClass ('dbConnections'); global $_DBArray; switch ( $action ){ - + + case 'loadInfoAssigConnecctionDB': + $oStep = new Step(); + return print ($oStep->loadInfoAssigConnecctionDB($_POST['PRO_UID'],$_POST['DBS_UID'])); + break; + case 'showDbConnectionsList': $oProcess = new processMap(); diff --git a/workflow/engine/xmlform/dbConnections/dbConnections.xml b/workflow/engine/xmlform/dbConnections/dbConnections.xml index f077f2db1..54948ec87 100644 --- a/workflow/engine/xmlform/dbConnections/dbConnections.xml +++ b/workflow/engine/xmlform/dbConnections/dbConnections.xml @@ -25,10 +25,10 @@ Edit - + Delete - \ No newline at end of file +