Merge pull request #806 from ralpheav/master

Code Style change  workflow/engine/methods/dbConnections
This commit is contained in:
ferOnti
2012-10-18 06:56:46 -07:00
4 changed files with 285 additions and 306 deletions

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* upgrade.php * upgrade.php
* *
@@ -20,7 +21,6 @@
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
/* /*
global $RBAC; global $RBAC;
@@ -44,7 +44,7 @@ $G_ID_MENU_SELECTED = 'PROCESSES';
$G_ID_SUB_MENU_SELECTED = 'DB_CONNECTIONS'; $G_ID_SUB_MENU_SELECTED = 'DB_CONNECTIONS';
*/ */
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher();
G::LoadClass( 'processMap' ); G::LoadClass( 'processMap' );
$oProcess = new processMap(); $oProcess = new processMap();
@@ -75,3 +75,4 @@ if (ProcessPeer::doCount($oCriteria) > 0) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/noProcesses' ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/noProcesses' );
} }
G::RenderPage( 'publish' ); G::RenderPage( 'publish' );

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* upgrade.php * upgrade.php
* *
@@ -20,7 +21,6 @@
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
/* /*
@@ -36,33 +36,32 @@ if( isset($_POST['action']) || isset($_POST['function']) ){
throw new Exception( 'dbconnections Fatal error, No action defined!...' ); throw new Exception( 'dbconnections Fatal error, No action defined!...' );
} }
if(isset($_POST['PROCESS'])) if (isset( $_POST['PROCESS'] )) {
$_SESSION['PROCESS'] = $_POST['PROCESS']; $_SESSION['PROCESS'] = $_POST['PROCESS'];
}
#Global Definitions #Global Definitions
require_once 'classes/model/DbSource.php'; require_once 'classes/model/DbSource.php';
require_once 'classes/model/Content.php'; require_once 'classes/model/Content.php';
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher();
G::LoadClass( 'processMap' ); G::LoadClass( 'processMap' );
G::LoadClass( 'ArrayPeer' ); G::LoadClass( 'ArrayPeer' );
G::LoadClass( 'dbConnections' ); G::LoadClass( 'dbConnections' );
global $_DBArray; global $_DBArray;
switch ($action) { switch ($action) {
case 'loadInfoAssigConnecctionDB': case 'loadInfoAssigConnecctionDB':
$oStep = new Step(); $oStep = new Step();
return print ($oStep->loadInfoAssigConnecctionDB( $_POST['PRO_UID'], $_POST['DBS_UID'] )) ; return print ($oStep->loadInfoAssigConnecctionDB( $_POST['PRO_UID'], $_POST['DBS_UID'] )) ;
break; break;
case 'showDbConnectionsList': case 'showDbConnectionsList':
$oProcess = new processMap(); $oProcess = new processMap();
$oCriteria = $oProcess->getConditionProcessList(); $oCriteria = $oProcess->getConditionProcessList();
if (ProcessPeer::doCount( $oCriteria ) > 0) { if (ProcessPeer::doCount( $oCriteria ) > 0) {
$aProcesses = array (); $aProcesses = array ();
$aProcesses[] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char'); $aProcesses[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char'
);
$oDataset = ArrayBasePeer::doSelectRS( $oCriteria ); $oDataset = ArrayBasePeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
@@ -71,7 +70,8 @@ switch ( $action ){
if ($sProcessUID == '') { if ($sProcessUID == '') {
$sProcessUID = $aRow['PRO_UID']; $sProcessUID = $aRow['PRO_UID'];
} }
$aProcesses[] = array('PRO_UID' => (isset($aRow['PRO_UID']) ? $aRow['PRO_UID'] : ''), 'PRO_TITLE' => (isset($aRow['PRO_TITLE']) ? $aRow['PRO_TITLE'] : '')); $aProcesses[] = array ('PRO_UID' => (isset( $aRow['PRO_UID'] ) ? $aRow['PRO_UID'] : ''),'PRO_TITLE' => (isset( $aRow['PRO_TITLE'] ) ? $aRow['PRO_TITLE'] : '')
);
$oDataset->next(); $oDataset->next();
} }
@@ -85,19 +85,14 @@ switch ( $action ){
} }
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
break; break;
case 'showConnections': case 'showConnections':
$oDBSource = new DbSource(); $oDBSource = new DbSource();
$oCriteria = $oDBSource->getCriteriaDBSList( $_SESSION['PROCESS'] ); $oCriteria = $oDBSource->getCriteriaDBSList( $_SESSION['PROCESS'] );
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria ); $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria );
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
break; break;
case 'newDdConnection': case 'newDdConnection':
$dbs = new dbConnections( $_SESSION['PROCESS'] ); $dbs = new dbConnections( $_SESSION['PROCESS'] );
$dbServices = $dbs->getDbServicesAvailables(); $dbServices = $dbs->getDbServicesAvailables();
$dbService = $dbs->getEncondeList(); $dbService = $dbs->getEncondeList();
@@ -106,27 +101,28 @@ switch ( $action ){
$dbs->encryptThepassw( $_SESSION['PROCESS'] ); $dbs->encryptThepassw( $_SESSION['PROCESS'] );
//end updating //end updating
$rows[] = array('uid' => 'char', 'name' => 'char'); $rows[] = array ('uid' => 'char','name' => 'char'
);
foreach ($dbServices as $srv) { foreach ($dbServices as $srv) {
$rows[] = array('uid' => $srv['id'], 'name' => $srv['name']); $rows[] = array ('uid' => $srv['id'],'name' => $srv['name']
);
} }
$_DBArray['BDCONNECTIONS'] = $rows; $_DBArray['BDCONNECTIONS'] = $rows;
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_New', '', '' ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_New', '', '' );
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
break; break;
case 'editDdConnection': case 'editDdConnection':
$dbs = new dbConnections( $_SESSION['PROCESS'] ); $dbs = new dbConnections( $_SESSION['PROCESS'] );
$dbServices = $dbs->getDbServicesAvailables(); $dbServices = $dbs->getDbServicesAvailables();
$rows[] = array('uid' => 'char', 'name' => 'char'); $rows[] = array ('uid' => 'char','name' => 'char'
);
foreach ($dbServices as $srv) { foreach ($dbServices as $srv) {
$rows[] = array('uid' => $srv['id'], 'name' => $srv['name']); $rows[] = array ('uid' => $srv['id'],'name' => $srv['name']
);
} }
$_DBArray['BDCONNECTIONS'] = $rows; $_DBArray['BDCONNECTIONS'] = $rows;
@@ -142,52 +138,30 @@ switch ( $action ){
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_Edit', '', $aFields ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_Edit', '', $aFields );
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
break; break;
case 'saveEditConnection': case 'saveEditConnection':
$oDBSource = new DbSource(); $oDBSource = new DbSource();
$oContent = new Content(); $oContent = new Content();
if(strpos($_POST['server'], "\\")) if (strpos( $_POST['server'], "\\" )) {
$_POST['port'] = 'none'; $_POST['port'] = 'none';
$aData = Array( }
'DBS_UID' => $_POST['dbs_uid'], $aData = Array ('DBS_UID' => $_POST['dbs_uid'],'PRO_UID' => $_SESSION['PROCESS'],'DBS_TYPE' => $_POST['type'],'DBS_SERVER' => $_POST['server'],'DBS_DATABASE_NAME' => $_POST['db_name'],'DBS_USERNAME' => $_POST['user'],'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "" : G::encrypt( $_POST['passwd'], $_POST['db_name'] )) . "_2NnV3ujj3w",'DBS_PORT' => (($_POST['port'] == 'none') ? "" : $_POST['port']),'DBS_ENCODE' => $_POST['enc']
'PRO_UID' => $_SESSION['PROCESS'],
'DBS_TYPE' => $_POST['type'],
'DBS_SERVER' => $_POST['server'],
'DBS_DATABASE_NAME' => $_POST['db_name'],
'DBS_USERNAME' => $_POST['user'],
'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "": G::encrypt($_POST['passwd'], $_POST['db_name']))."_2NnV3ujj3w",
'DBS_PORT' => (($_POST['port'] == 'none') ? "": $_POST['port']),
'DBS_ENCODE' => $_POST['enc']
); );
$oDBSource->update( $aData ); $oDBSource->update( $aData );
$oContent->addContent( 'DBS_DESCRIPTION', '', $_POST['dbs_uid'], SYS_LANG, $_POST['desc'] ); $oContent->addContent( 'DBS_DESCRIPTION', '', $_POST['dbs_uid'], SYS_LANG, $_POST['desc'] );
break; break;
case 'saveConnection': case 'saveConnection':
$oDBSource = new DbSource(); $oDBSource = new DbSource();
$oContent = new Content(); $oContent = new Content();
if(strpos($_POST['server'], "\\")) if (strpos( $_POST['server'], "\\" )) {
$_POST['port'] = 'none'; $_POST['port'] = 'none';
$aData = Array( }
'PRO_UID' => $_SESSION['PROCESS'], $aData = Array ('PRO_UID' => $_SESSION['PROCESS'],'DBS_TYPE' => $_POST['type'],'DBS_SERVER' => $_POST['server'],'DBS_DATABASE_NAME' => $_POST['db_name'],'DBS_USERNAME' => $_POST['user'],'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "" : G::encrypt( $_POST['passwd'], $_POST['db_name'] )) . "_2NnV3ujj3w",'DBS_PORT' => (($_POST['port'] == 'none') ? "" : $_POST['port']),'DBS_ENCODE' => $_POST['enc']
'DBS_TYPE' => $_POST['type'],
'DBS_SERVER' => $_POST['server'],
'DBS_DATABASE_NAME' => $_POST['db_name'],
'DBS_USERNAME' => $_POST['user'],
'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "": G::encrypt($_POST['passwd'], $_POST['db_name']))."_2NnV3ujj3w",
'DBS_PORT' => (($_POST['port'] == 'none') ? "": $_POST['port']),
'DBS_ENCODE' => $_POST['enc']
); );
$newid = $oDBSource->create( $aData ); $newid = $oDBSource->create( $aData );
$sDelimiter = DBAdapter::getStringDelimiter(); $sDelimiter = DBAdapter::getStringDelimiter();
$oContent->addContent( 'DBS_DESCRIPTION', '', $newid, SYS_LANG, $_POST['desc'] ); $oContent->addContent( 'DBS_DESCRIPTION', '', $newid, SYS_LANG, $_POST['desc'] );
break; break;
case 'deleteDbConnection': case 'deleteDbConnection':
try { try {
$oDBSource = new DbSource(); $oDBSource = new DbSource();
@@ -205,14 +179,11 @@ switch ( $action ){
} }
print G::json_encode( $result ); print G::json_encode( $result );
break; break;
case 'showTestConnection': case 'showTestConnection':
$G_PUBLISH = new Publisher();
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent( 'view', 'dbConnections/dbConnections' ); $G_PUBLISH->AddContent( 'view', 'dbConnections/dbConnections' );
G::RenderPage( 'publish', 'raw' ); G::RenderPage( 'publish', 'raw' );
break; break;
case 'testConnection': case 'testConnection':
sleep( 0 ); sleep( 0 );
$step = $_POST['step']; $step = $_POST['step'];
@@ -226,10 +197,18 @@ switch ( $action ){
if (($port == 'none') || ($port == 0)) { if (($port == 'none') || ($port == 0)) {
//setting defaults ports //setting defaults ports
switch ($type) { switch ($type) {
case 'mysql': $port = 3306; break; case 'mysql':
case 'pgsql': $port = 5432; break; $port = 3306;
case 'mssql': $port = 1433; break; break;
case 'oracle': $port = 1521; break; case 'pgsql':
$port = 5432;
break;
case 'mssql':
$port = 1433;
break;
case 'oracle':
$port = 1521;
break;
} }
} }
@@ -247,7 +226,6 @@ switch ( $action ){
print (FAILED . ',' . $Server->error) ; print (FAILED . ',' . $Server->error) ;
} }
break; break;
case 2: case 2:
$Server->scannPort( $port ); $Server->scannPort( $port );
if ($Server->getErrno() == 0) { if ($Server->getErrno() == 0) {
@@ -256,7 +234,6 @@ switch ( $action ){
print (FAILED . ',' . $Server->error) ; print (FAILED . ',' . $Server->error) ;
} }
break; break;
case 3: case 3:
$Server->loginDbServer( $user, $passwd ); $Server->loginDbServer( $user, $passwd );
$Server->setDataBase( $db_name, $port ); $Server->setDataBase( $db_name, $port );
@@ -272,7 +249,6 @@ switch ( $action ){
print (FAILED . ',' . $Server->error) ; print (FAILED . ',' . $Server->error) ;
} }
break; break;
case 4: case 4:
$Server->loginDbServer( $user, $passwd ); $Server->loginDbServer( $user, $passwd );
$Server->setDataBase( $db_name, $port ); $Server->setDataBase( $db_name, $port );
@@ -292,12 +268,10 @@ switch ( $action ){
print (FAILED . ',' . $Server->error) ; print (FAILED . ',' . $Server->error) ;
} }
break; break;
default: default:
print ('finished') ; print ('finished') ;
} }
break; break;
case 'showEncodes': case 'showEncodes':
G::LoadThirdParty( 'pear/json', 'class.json' ); G::LoadThirdParty( 'pear/json', 'class.json' );
$oJSON = new Services_JSON(); $oJSON = new Services_JSON();
@@ -312,3 +286,4 @@ switch ( $action ){
} }
break; break;
} }

View File

@@ -1,8 +1,10 @@
<?php <?php
/** /**
* @Author: Erik Amaru Ortiz <erik@colosa.com> * Description: This is a additional configuration for load all connections; if exist in a particular proccess
* @Description:This is a additional configuration for load all connections; if exist in a particular proccess
* @Date: 15-05-2008 * @Date: 15-05-2008
*
* @author : Erik Amaru Ortiz <erik@colosa.com>
*/ */
if (isset( $_SESSION['PROCESS'] )) { if (isset( $_SESSION['PROCESS'] )) {
$pro = include (PATH_CORE . "config/databases.php"); $pro = include (PATH_CORE . "config/databases.php");
@@ -23,4 +25,3 @@ if( isset($_SESSION['PROCESS']) ){
return $pro; return $pro;
} }
?>

View File

@@ -1,8 +1,9 @@
<?php <?php
/** /**
* @Author: Erik Amaru Ortiz <erik@colosa.com> * ription:This is a additional configuration for load all connections; if exist in a particular proccess
* @Description:This is a additional configuration for load all connections; if exist in a particular proccess
* @Date: 15-05-2008 * @Date: 15-05-2008
*
* @author : Erik Amaru Ortiz <erik@colosa.com>
*/ */
$dbHash = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) ); $dbHash = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) );
@@ -19,3 +20,4 @@
$pro['datasources']['root']['adapter'] = "mysql"; $pro['datasources']['root']['adapter'] = "mysql";
return $pro; return $pro;