Merge remote branch 'upstream/master' into BUG-9180

This commit is contained in:
Herbert Saal Gutierrez
2012-06-18 18:03:31 -04:00
76 changed files with 5744 additions and 4788 deletions

View File

@@ -265,6 +265,7 @@ class dynaformEditor extends WebResource
var DYNAFORM_URL="'.$Parameters['URL'].'";
leimnud.event.add(window,"load",function(){ loadEditor(); });
');
$oHeadPublisher->addScriptCode(' var jsMeta;');
G::RenderPage( "publish", 'blank' );
}
@@ -664,8 +665,12 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $sCode
* @return array
*/
function set_javascript($A,$fieldName,$sCode)
function set_javascript($A,$fieldName,$sCode,$meta)
{
if ($fieldName == '___pm_boot_strap___') {
return 0;
}
$sCode = urldecode($sCode) ;
try {
$sCode = rtrim($sCode);
@@ -678,7 +683,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
G::LoadSystem('dynaformhandler');
$dynaform = new dynaFormHandler(PATH_DYNAFORM."{$file}.xml");
$dynaform->replace($fieldName, $fieldName, Array('type'=>'javascript', '#cdata'=>$sCode));
$dynaform->replace($fieldName, $fieldName, Array('type'=>'javascript', 'meta'=>$meta, '#cdata'=>$sCode));
return 0;
} catch(Exception $e) {

View File

@@ -395,7 +395,7 @@ class NET
@oci_close($link);
}
else {
$this->error = "the user $this->db_user doesn't has privileges to run queries!";
$this->error = "the user $this->db_user doesn't have privileges to run queries!";
$this->errstr = "NET::ORACLE->Couldn't execute any query on this server!";
$this->errno = 40010;
}

View File

@@ -254,43 +254,46 @@ function pauseCase($sApplicationUID = '', $iDelegation = 0, $sUserUID = '', $sUn
* @return array or string | $Resultquery | Result | Result of the query | If executing a SELECT statement, it returns an array of associative arrays
*
*/
function executeQuery($SqlStatement, $DBConnectionUID = 'workflow') {
function executeQuery($SqlStatement, $DBConnectionUID = 'workflow', $aParameter = array()) {
$con = Propel::getConnection($DBConnectionUID);
$con->begin();
try {
$statement = trim($SqlStatement);
$statement = str_replace('(', '', $statement);
$con = Propel::getConnection($DBConnectionUID);
$con->begin();
$result = false;
if (getEngineDataBaseName($con) != 'oracle' ) {
switch(true) {
case preg_match("/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement):
$rs = $con->executeQuery($SqlStatement);
$con->commit();
switch(true) {
case preg_match("/^SELECT\s/i", $statement):
case preg_match("/^EXECUTE\s/i", $statement):
$rs = $con->executeQuery($SqlStatement);
$con->commit();
$result = Array();
$i=1;
while ($rs->next()) {
$result[$i++] = $rs->getRow();
}
break;
case preg_match("/^INSERT\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
//$result = $lastId->getId();
$result = 1;
break;
case preg_match("/^UPDATE\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
$result = $con->getUpdateCount();
break;
case preg_match("/^DELETE\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
$result = $con->getUpdateCount();
break;
$result = Array();
$i = 1;
while ($rs->next()) {
$result[$i++] = $rs->getRow();
}
break;
case preg_match("/^INSERT\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
//$result = $lastId->getId();
$result = 1;
break;
case preg_match("/^UPDATE\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
$result = $con->getUpdateCount();
break;
case preg_match("/^DELETE\s/i", $statement):
$rs = $con->executeUpdate($SqlStatement);
$con->commit();
$result = $con->getUpdateCount();
break;
}
}
else {
$result = executeQueryOci($SqlStatement, $con, $aParameter);
}
return $result;

View File

@@ -630,4 +630,109 @@ function registerError($iType, $sError, $iLine, $sCode)
{
$sType = ($iType == 1 ? 'ERROR' : 'FATAL');
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '') . ':<br /><br />' . $sCode;
}
}
/**
* Obtain engine Data Base name
*
* @param type $connection
* @return type
*/
function getEngineDataBaseName($connection)
{
$aDNS = $connection->getDSN();
return $aDNS["phptype"];
}
/**
* Execute Queries for Oracle Database
*
* @param type $sql
* @param type $connection
*/
function executeQueryOci($sql, $connection, $aParameter = array())
{
$aDNS = $connection->getDSN();
$sUsername = $aDNS["username"];
$sPassword = $aDNS["password"];
$sHostspec = $aDNS["hostspec"];
$sDatabse = $aDNS["database"];
$sPort = $aDNS["port"];
if ($sPort != "1521") { // if not default port
$conn = oci_connect($sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse);
}
else {
$conn = oci_connect($sUsername, $sPassword, $sHostspec . "/" . $sDatabse);
}
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
return $e;
}
switch(true) {
case preg_match("/^(SELECT|SHOW|DESCRIBE|DESC)\s/i", $sql):
$stid = oci_parse($conn, $sql);
if (count($aParameter) > 0) {
foreach ($aParameter as $key => $val) {
oci_bind_by_name($stid, $key, $val);
}
}
oci_execute($stid, OCI_DEFAULT);
$result = Array();
$i = 1;
while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
$result[$i++] = $row;
}
oci_free_statement($stid);
oci_close($conn);
return $result;
break;
case preg_match("/^(INSERT|UPDATE|DELETE)\s/i", $sql):
$stid = oci_parse($conn, $sql);
$isValid = true;
if (count($aParameter) > 0){
foreach ($aParameter as $key => $val) {
oci_bind_by_name($stid, $key, $val);
}
}
$objExecute = oci_execute($stid, OCI_DEFAULT);
if ($objExecute) {
oci_commit($conn);
}
else {
oci_rollback($conn);
$isValid = false;
}
oci_free_statement($stid);
oci_close($conn);
if ($isValid) {
return true;
}
else {
return oci_error();
}
break;
default:
// Stored procedures
$stid = oci_parse($conn, $sql);
$aParameterRet = array();
if (count($aParameter) > 0){
foreach ($aParameter as $key => $val) {
$aParameterRet[$key] = $val;
// The third parameter ($aParameterRet[$key]) returned a value by reference.
oci_bind_by_name($stid, $key, $aParameterRet[$key]);
}
}
$objExecute = oci_execute($stid, OCI_DEFAULT);
oci_free_statement($stid);
oci_close($conn);
return $aParameterRet;
break;
}
}

View File

@@ -104,17 +104,29 @@ class PmTable
default:
require_once 'classes/model/DbSource.php';
$dbSource = DbSource::load($this->dataSource);
if (!is_object($dbSource)) {
$oDBSource = new DbSource();
$proUid = $oDBSource->getValProUid($this->dataSource);
$dbSource = $oDBSource->load($this->dataSource, $proUid);
if (is_object($dbSource)) {
$this->dbConfig->adapter= $dbSource->getDbsType();
$this->dbConfig->host = $dbSource->getDbsServer();
$this->dbConfig->name = $dbSource->getDbsDatabaseName();
$this->dbConfig->user = $dbSource->getDbsUsername();
$this->dbConfig->passwd = $dbSource->getDbsPassword();
$this->dbConfig->port = $dbSource->getDbsPort();
}
if (is_array($dbSource)) {
$this->dbConfig->adapter= $dbSource['DBS_TYPE'];
$this->dbConfig->host = $dbSource['DBS_SERVER'];
$this->dbConfig->name = $dbSource['DBS_DATABASE_NAME'];
$this->dbConfig->user = $dbSource['DBS_USERNAME'];
$this->dbConfig->passwd = $dbSource['DBS_PASSWORD'] ;
$this->dbConfig->port = $dbSource['DBS_PORT'];
}
else {
throw new Exception("Db source with id $dbsUid does not exist!");
}
$this->dbConfig->adapter= $dbSource->getDbsType();
$this->dbConfig->host = $dbSource->getDbsServer();
$this->dbConfig->name = $dbSource->getDbsDatabaseName();
$this->dbConfig->user = $dbSource->getDbsUsername();
$this->dbConfig->passwd = $dbSource->getDbsPassword();
$this->dbConfig->port = $dbSource->getDbsPort();
}
}
@@ -394,78 +406,193 @@ class PmTable
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
$previous = NULL;
$queryStack = array();
$aDNS = $con->getDSN();
$dbEngine = $aDNS["phptype"];
foreach ($lines as $j => $line) {
$line = trim($line); // Remove comments from the script
if (strpos($line, "--") === 0) {
$line = substr($line, 0, strpos($line, "--"));
}
switch($dbEngine) {
case 'mysql' :
$line = trim($line); // Remove comments from the script
if (empty($line)) {
continue;
}
if (strpos($line, "#") === 0) {
$line = substr($line, 0, strpos($line, "#"));
}
if (empty($line)) {
continue;
}
// Concatenate the previous line, if any, with the current
if ($previous) {
$line = $previous . " " . $line;
}
$previous = NULL;
// If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements.
if (strrpos($line, ";") != strlen($line) - 1) {
$previous = $line;
continue;
}
$line = substr($line, 0, strrpos($line, ";"));
// just execute the drop and create table for target table nad not for others
if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) {
$isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\'\"\`]{1}' . $this->tableName . '[\'\"\`]{1}/i', $line, $match);
if ($isCreateForCurrentTable) {
$queryStack['create'] = $line;
}
else {
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\'\"\`]{1}' . $this->tableName . '[\'\"\`]{1}/i', $line, $match);
if ($isDropForCurrentTable) {
$queryStack['drop'] = $line;
if (strpos($line, "--") === 0) {
$line = substr($line, 0, strpos($line, "--"));
}
}
if (empty($line)) {
continue;
}
if (strpos($line, "#") === 0) {
$line = substr($line, 0, strpos($line, "#"));
}
if (empty($line)) {
continue;
}
// Concatenate the previous line, if any, with the current
if ($previous) {
$line = $previous . " " . $line;
}
$previous = NULL;
// If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements.
if (strrpos($line, ";") != strlen($line) - 1) {
$previous = $line;
continue;
}
$line = substr($line, 0, strrpos($line, ";"));
// just execute the drop and create table for target table nad not for others
if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) {
$isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match);
if ($isCreateForCurrentTable) {
$queryStack['create'] = $line;
}
else {
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match);
if ($isDropForCurrentTable) {
$queryStack['drop'] = $line;
}
}
}
break;
case 'mssql' :
$line = trim($line); // Remove comments from the script
if (strpos($line, "--") === 0) {
$line = substr($line, 0, strpos($line, "--"));
}
if (empty($line)) {
continue;
}
if (strpos($line, "#") === 0) {
$line = substr($line, 0, strpos($line, "#"));
}
if (empty($line)) {
continue;
}
// Concatenate the previous line, if any, with the current
if ($previous) {
$line = $previous . " " . $line;
}
$previous = NULL;
// If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements.
if (strrpos($line, ";") != strlen($line) - 1) {
$previous = $line;
continue;
}
$line = substr($line, 0, strrpos($line, ";"));
if (strpos($line, $this->tableName) == false) {
continue;
}
$auxCreate = explode('CREATE', $line);
$auxDrop = explode('IF EXISTS', $auxCreate['0']);
$queryStack['drop'] = 'IF EXISTS' . $auxDrop['1'];
$queryStack['create'] = 'CREATE' . $auxCreate['1'];
break;
case 'oracle' :
$line = trim($line);
if (empty($line)) {
continue;
}
switch(true) {
case preg_match("/^CREATE TABLE\s/i", $line):
if (strpos($line, $this->tableName) == true) {
$inCreate = true;
$lineCreate .= $line . ' ';
}
break;
case preg_match("/ALTER TABLE\s/i", $line):
if (strpos($line, $this->tableName) == true) {
$inAlter = true;
$lineAlter .= $line . ' ';
}
break;
case preg_match("/^DROP TABLE\s/i", $line):
if (strpos($line, $this->tableName) == true) {
$inDrop = true;
$lineDrop .= $line . ' ';
if (strrpos($line, ";") > 0) {
$queryStack['drop'] = $lineDrop;
$inDrop = false;
}
}
break;
default :
if ($inCreate) {
$lineCreate .= $line . ' ';
if (strrpos($line, ";") > 0) {
$queryStack['create'] = $lineCreate;
$inCreate = false;
}
}
if ($inAlter) {
$lineAlter .= $line . ' ';
if (strrpos($line, ";") > 0) {
$queryStack['alter'] = $lineAlter;
$inAlter = false;
}
}
if ($inDrop) {
$lineDrop .= $line . ' ';
if (strrpos($line, ";")>0) {
$queryStack['drop'] = $lineDrop;
$inDrop = false;
}
}
}
break;
}
}
if (isset($queryStack['create'])) {
// first at all we need to verify if we have a valid schema defined,
// so we verify that creating a dummy table
$swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']);
// if there is a problem with user defined table schema executeQuery() will throw a sql exception
$stmt->executeQuery($swapQuery);
// if there was not problem above proceced deleting the dummy table and drop and create the target table
$stmt->executeQuery("DROP TABLE {$this->tableName}_TMP");
if (!isset($queryStack['drop'])) {
$queryStack['drop'] = "DROP TABLE {$this->tableName}";
if ($dbEngine == 'oracle') {
$queryStack['drop'] = substr($queryStack['drop'], 0, strrpos($queryStack['drop'], ";"));
$queryStack['create'] = substr($queryStack['create'], 0, strrpos($queryStack['create'], ";"));
$queryStack['alter'] = substr($queryStack['alter'], 0, strrpos($queryStack['alter'], ";"));
$queryIfExistTable = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = '" . $this->tableName . "'";
$rs = $stmt->executeQuery($queryIfExistTable);
if ($rs->next()) {
$stmt->executeQuery($queryStack['drop']);
}
if (!isset($queryStack['create'])) {
throw new Exception('A problem occurred resolving the schema to update for this table');
}
$stmt->executeQuery($queryStack['drop']);
$stmt->executeQuery($queryStack['create']);
$stmt->executeQuery($queryStack['alter']);
}
else {
if (isset($queryStack['create'])) {
// first at all we need to verify if we have a valid schema defined,
// so we verify that creating a dummy table
$swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']);
// if there is a problem with user defined table schema executeQuery() will throw a sql exception
$stmt->executeQuery($swapQuery);
// if there was not problem above proceced deleting the dummy table and drop and create the target table
$stmt->executeQuery("DROP TABLE {$this->tableName}_TMP");
if (!isset($queryStack['drop'])) {
$queryStack['drop'] = "DROP TABLE {$this->tableName}";
}
if (!isset($queryStack['create'])) {
throw new Exception('A problem occurred resolving the schema to update for this table');
}
$stmt->executeQuery($queryStack['drop']);
$stmt->executeQuery($queryStack['create']);
}
}
}
public function upgradeDatabaseFor($dataSource, $tablesList = array())

View File

@@ -542,7 +542,6 @@ class propelTable
$template = PATH_CORE . 'templates' . PATH_SEP . $menu->type . '.html';
$menu->setValues($this->xmlForm->values);
$menu->setValues(array( 'PAGED_TABLE_ID' => $this->id ));
$menu->setValues(array( 'PAGED_TABLE_FAST_SEARCH' => $this->fastSearch ));
if (isset($filterForm->name)) {
$menu->setValues(array('SEARCH_FILTER_FORM' => $filterForm->name));
}

View File

@@ -651,19 +651,21 @@ class wsBase
$fileTemplate = $pathEmail . $sTemplate;
G::mk_dir( $pathEmail, 0777,true);
if ( ! file_exists ( $fileTemplate ) ) {
if (!file_exists($fileTemplate)) {
$data['FILE_TEMPLATE'] = $fileTemplate;
$result = new wsResponse (28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data) );
$result = new wsResponse(28, G::LoadTranslation('ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data));
return $result;
}
if ( $appFields == null ) {
$Fields = $oldFields['APP_DATA'];
if ($appFields == null) {
$Fields = $oldFields['APP_DATA'];
}
else {
$Fields = $appFields;
$Fields = array_merge($oldFields['APP_DATA'], $appFields);
}
$templateContents = file_get_contents ( $fileTemplate );
$templateContents = file_get_contents($fileTemplate);
//$sContent = G::unhtmlentities($sContent);
$iAux = 0;
@@ -1246,6 +1248,16 @@ class wsBase
*/
public function newCase($processId, $userId, $taskId, $variables) {
try {
//GET, POST & $_SESSION Vars
//Unset any variable, because we are starting a new case
if (isset($_SESSION['APPLICATION'])) unset($_SESSION['APPLICATION']);
if (isset($_SESSION['PROCESS'])) unset($_SESSION['PROCESS']);
if (isset($_SESSION['TASK'])) unset($_SESSION['TASK']);
if (isset($_SESSION['INDEX'])) unset($_SESSION['INDEX']);
if (isset($_SESSION['USER_LOGGED'])) unset($_SESSION['USER_LOGGED']);
//if (isset($_SESSION['USR_USERNAME'])) unset($_SESSION['USR_USERNAME']);
//if (isset($_SESSION['STEP_POSITION'])) unset($_SESSION['STEP_POSITION']);
$Fields = array();
if ( is_array($variables) && count($variables)>0 ) {
$Fields = $variables;
@@ -1284,10 +1296,19 @@ class wsBase
$result = new wsResponse (14, G::loadTranslation ('ID_TASK_INVALID_USER_NOT_ASSIGNED_TASK'));
return $result;
}
$case = $oCase->startCase($taskId, $userId);
$caseId = $case['APPLICATION'];
$caseNr = $case['CASE_NUMBER'];
$case = $oCase->startCase($taskId, $userId);
$_SESSION['APPLICATION'] = $case['APPLICATION'];
$_SESSION['PROCESS'] = $case['PROCESS'];
$_SESSION['TASK'] = $taskId;
$_SESSION['INDEX'] = $case['INDEX'];
$_SESSION['USER_LOGGED'] = $userId;
//$_SESSION['USR_USERNAME'] = $case['USR_USERNAME'];
//$_SESSION['STEP_POSITION'] = 0;
$caseId = $case['APPLICATION'];
$caseNr = $case['CASE_NUMBER'];
$oldFields = $oCase->loadCase( $caseId );

View File

@@ -89,9 +89,11 @@ class AppCacheView extends BaseAppCacheView {
else {
$Criteria = $this->addPMFieldsToCriteria('todo');
}
$Criteria->addSelectColumn(AppCacheViewPeer::TAS_UID);
$Criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
$Criteria->add (AppCacheViewPeer::APP_STATUS, "TO_DO" , CRITERIA::EQUAL );
$Criteria->add (AppCacheViewPeer::USR_UID, $userUid);
$Criteria->add (AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
$Criteria->add (AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
$Criteria->add (AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');

View File

@@ -103,6 +103,18 @@ class DbSource extends BaseDbSource
}
}
public function getValProUid($Uid)
{
$oCriteria = new Criteria('workflow');
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn(DbSourcePeer::PRO_UID);
$oCriteria->add(DbSourcePeer::DBS_UID, $Uid);
$result = DbSourcePeer::doSelectRS($oCriteria);
$result->next();
$aRow = $result->getRow();
return $aRow[0];
}
function Exists ( $Uid, $ProUID ) {
try {
$oPro = DbSourcePeer::retrieveByPk( $Uid, $ProUID );