CODE STYLE, gulliver/system/...

FILES:
class.dbMaintenance.php
class.dbconnection.php
class.dbrecordset.php
class.dbsession.php
class.dbtable.php
class.httpProxyController.php
class.i18n_po.php
class.mailer.php
class.menu.php
class.objectTemplate.php
class.testTools.php
class.tree.php
class.unitTest.php
class.webResource.php
class.xmlDocument.php
class.xmlformExtension.php
This commit is contained in:
jennylee
2012-10-18 10:54:46 -04:00
parent 37bb8a1f5f
commit e456979aa3
16 changed files with 3515 additions and 3358 deletions

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.database_base.php * class.database_base.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -25,6 +27,7 @@
*/ */
/** /**
*
* *
* Database Maintenance class * Database Maintenance class
* *
@@ -115,9 +118,10 @@ class DataBaseMaintenance
public function setTempDir ($tmpDir) public function setTempDir ($tmpDir)
{ {
$this->tmpDir = $tmpDir; $this->tmpDir = $tmpDir;
if (!file_exists($tmpDir)) if (! file_exists( $tmpDir )) {
mkdir( $this->tmpDir ); mkdir( $this->tmpDir );
} }
}
/** /**
* getTempDir * getTempDir
@@ -139,7 +143,6 @@ class DataBaseMaintenance
return $$this->link; return $$this->link;
} }
/** /**
* connect * connect
* *
@@ -190,7 +193,7 @@ class DataBaseMaintenance
public function selectDataBase ($dbname) public function selectDataBase ($dbname)
{ {
$this->setDbName( $dbname ); $this->setDbName( $dbname );
If( ! @mysql_select_db($this->dbName, $this->link) ) { if (! @mysql_select_db( $this->dbName, $this->link )) {
throw new Exception( "Couldn't select database $dbname" ); throw new Exception( "Couldn't select database $dbname" );
} }
} }
@@ -338,8 +341,9 @@ class DataBaseMaintenance
$this->infile = $this->tmpDir . $table . ".sql"; $this->infile = $this->tmpDir . $table . ".sql";
if (is_file( $this->infile )) { if (is_file( $this->infile )) {
$queries = $this->restoreFromSql( $this->infile, true ); $queries = $this->restoreFromSql( $this->infile, true );
if (!isset($queries)) if (! isset( $queries )) {
$queries = "unknown"; $queries = "unknown";
}
printf( "%-59s%20s", "Restored table $table", "$queries queries\n" ); printf( "%-59s%20s", "Restored table $table", "$queries queries\n" );
} }
} else { } else {
@@ -414,7 +418,8 @@ class DataBaseMaintenance
$mysqli->close(); $mysqli->close();
} }
function lockTables() { function lockTables ()
{
$aTables = $this->getTablesList(); $aTables = $this->getTablesList();
if (empty( $aTables )) if (empty( $aTables ))
return false; return false;
@@ -428,13 +433,15 @@ class DataBaseMaintenance
} }
} }
function unlockTables() { function unlockTables ()
{
printf( "%-70s", "UNLOCK TABLES" ); printf( "%-70s", "UNLOCK TABLES" );
if( @mysql_query("UNLOCK TABLES;") ) if (@mysql_query( "UNLOCK TABLES;" )) {
echo " [OK]\n"; echo " [OK]\n";
else } else {
echo "[FAILED]\n" . mysql_error() . "\n"; echo "[FAILED]\n" . mysql_error() . "\n";
} }
}
/** /**
* dumpSqlInserts * dumpSqlInserts
@@ -542,7 +549,7 @@ class DataBaseMaintenance
} }
} else { } else {
$queries = NULL; $queries = null;
try { try {
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName ); $mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
/* check connection */ /* check connection */
@@ -558,8 +565,9 @@ class DataBaseMaintenance
return false; return false;
} }
if( trim($query) == "" ) if (trim( $query ) == "") {
return false; return false;
}
/* execute multi query */ /* execute multi query */
if ($mysqli->multi_query( $query )) { if ($mysqli->multi_query( $query )) {
@@ -576,7 +584,9 @@ class DataBaseMaintenance
//printf("-----------------\n"); //printf("-----------------\n");
} }
} while ($mysqli->next_result()); } while ($mysqli->next_result());
} else throw new Exception(mysqli_error($mysqli)); } else {
throw new Exception( mysqli_error( $mysqli ) );
}
/* close connection */ /* close connection */
$mysqli->close(); $mysqli->close();
@@ -607,9 +617,9 @@ class DataBaseMaintenance
$tableSchema .= $row['Create Table'] . ";\n\n"; $tableSchema .= $row['Create Table'] . ";\n\n";
} }
mysql_free_result( $result ); mysql_free_result( $result );
} else } else {
echo mysql_error(); echo mysql_error();
}
return $tableSchema; return $tableSchema;
} }
@@ -649,11 +659,3 @@ $o2->restoreFromSql('/home/erik/backs/schema_os.sql');
$o2->restoreAllData('sql'); $o2->restoreAllData('sql');
*/ */

View File

@@ -96,19 +96,22 @@ class DBConnection
function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2) function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
{ {
$this->errorLevel = $errorLevel; $this->errorLevel = $errorLevel;
if ($type == null) if ($type == null) {
$type = 'mysql'; $type = 'mysql';
}
$this->type = $type; $this->type = $type;
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>"; //print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
if ($type == "mysql") if ($type == "mysql") {
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB"; $dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
}
if ($type == "pgsql") { if ($type == "pgsql") {
//$dsn = "pgsql://postgres@$strServer/$strDB"; //$dsn = "pgsql://postgres@$strServer/$strDB";
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort"); $prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB"; $dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
} }
if ($type == "odbc") if ($type == "odbc") {
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB"; $dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
}
if ($type == "mssql") { if ($type == "mssql") {
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) ); $strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort"); $prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
@@ -179,7 +182,7 @@ class DBConnection
* @param string $errorLevel * @param string $errorLevel
* @return void * @return void
*/ */
function logError ($obj, $errorLevel = NULL) function logError ($obj, $errorLevel = null)
{ {
global $_SESSION; global $_SESSION;
global $_SERVER; global $_SERVER;

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.dbrecordset.php * class.dbrecordset.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -27,6 +29,7 @@
/** /**
* DBRecordset class definition * DBRecordset class definition
* Provides access to a generalized table it assumes that the dbconnection object is already initialized for the table should be also provided in order to provide * Provides access to a generalized table it assumes that the dbconnection object is already initialized for the table should be also provided in order to provide
*
* @package gulliver.system * @package gulliver.system
* *
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
@@ -60,9 +63,7 @@ class DBRecordSet
function SetTo ($intResult = null) function SetTo ($intResult = null)
{ {
if ($intResult === null) { if ($intResult === null) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
DBconnection::logError( $dberror ); DBconnection::logError( $dberror );
} }
if ($intResult) { if ($intResult) {
@@ -72,6 +73,7 @@ class DBRecordSet
/** /**
* Function Free * Function Free
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -79,9 +81,7 @@ class DBRecordSet
function Free () function Free ()
{ {
if ($this->result === null) { if ($this->result === null) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
DBconnection::logError( $dberror ); DBconnection::logError( $dberror );
} }
$this->result->free(); $this->result->free();
@@ -90,6 +90,7 @@ class DBRecordSet
/** /**
* Function Count * Function Count
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -97,9 +98,7 @@ class DBRecordSet
function Count () function Count ()
{ {
if ($this->result === null) { if ($this->result === null) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
DBconnection::logError( $dberror ); DBconnection::logError( $dberror );
} }
return $this->result->numRows(); return $this->result->numRows();
@@ -107,6 +106,7 @@ class DBRecordSet
/** /**
* Function Read * Function Read
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -114,15 +114,14 @@ class DBRecordSet
function Read () function Read ()
{ {
if ($this->result === null) { if ($this->result === null) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
DBconnection::logError( $dberror ); DBconnection::logError( $dberror );
} }
$res = $this->result->fetchRow( DB_FETCHMODE_ASSOC ); $res = $this->result->fetchRow( DB_FETCHMODE_ASSOC );
//for Pgsql databases, //for Pgsql databases,
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); } //if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
/* Comment Code: This block is not required now because /* Comment Code: This block is not required now because
* of the the use of the G::sqlEscape() instead of addslashes * of the the use of the G::sqlEscape() instead of addslashes
* funcion over each field in DBTable. * funcion over each field in DBTable.
@@ -137,6 +136,7 @@ class DBRecordSet
/** /**
* Function ReadAbsolute * Function ReadAbsolute
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -149,3 +149,4 @@ class DBRecordSet
return $res; return $res;
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.dbsession.php * class.dbsession.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -27,6 +29,7 @@
/** /**
* DBSession class definition * DBSession class definition
* It is useful to stablish a database connection using an specific database * It is useful to stablish a database connection using an specific database
*
* @package gulliver.system * @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team. * @copyright (C) 2002 by Colosa Development Team.
@@ -34,12 +37,13 @@
*/ */
class DBSession class DBSession
{ {
var $dbc = NULL; var $dbc = null;
var $dbname = ''; var $dbname = '';
var $result = false; var $result = false;
/** /**
* Starts a session using a connection with an specific database * Starts a session using a connection with an specific database
*
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* *
* @access public * @access public
@@ -48,15 +52,17 @@ class DBSession
* @return void * @return void
* *
*/ */
function DBSession( $objConnection = NULL, $strDBName = '' ) function DBSession ($objConnection = null, $strDBName = '')
{ {
if ($strDBName!='') $strDBName = $objConnection->db->_db; if ($strDBName != '') {
$strDBName = $objConnection->db->_db;
}
$this->setTo( $objConnection, $strDBName ); $this->setTo( $objConnection, $strDBName );
} }
/** /**
* It's like a constructor * It's like a constructor
*
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* *
* @access public * @access public
@@ -65,10 +71,9 @@ class DBSession
* @return void * @return void
* *
*/ */
function setTo( $objConnection = NULL, $strDBName = DB_NAME ) function setTo ($objConnection = null, $strDBName = DB_NAME)
{
if ( $objConnection != NULL )
{ {
if ($objConnection != null) {
$this->Free(); $this->Free();
$this->dbc = $objConnection; $this->dbc = $objConnection;
$this->dbname = $strDBName; $this->dbname = $strDBName;
@@ -80,9 +85,9 @@ class DBSession
} }
} }
/** /**
* UseDB stablish a database for the connection * UseDB stablish a database for the connection
*
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* *
* @access public * @access public
@@ -97,6 +102,7 @@ class DBSession
/** /**
* Function Execute, to execute a query and send back the recordset. * Function Execute, to execute a query and send back the recordset.
*
* @access public * @access public
* @param eter string strQuery * @param eter string strQuery
* @param eter string debug * @param eter string debug
@@ -106,16 +112,16 @@ class DBSession
function Execute ($strQuery = '', $debug = false, $errorLevel = null) function Execute ($strQuery = '', $debug = false, $errorLevel = null)
{ {
//BUG::traceRoute(); //BUG::traceRoute();
if ($this->dbc == NULL ) { if ($this->dbc == null) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', 'You have tried to call a DBSession function without create an instance of DBConnection', 'G_Error', true );
'You have tried to call a DBSession function without create an instance of DBConnection',
'G_Error', true);
DBconnection::logError( $dberror, $errorLevel ); DBconnection::logError( $dberror, $errorLevel );
return $dberror; return $dberror;
}; }
;
if ( $errorLevel === null ) $errorLevel = $this->dbc->errorLevel;
if ($errorLevel === null) {
$errorLevel = $this->dbc->errorLevel;
}
$this->Free( true ); $this->Free( true );
if ($debug) { if ($debug) {
@@ -132,6 +138,7 @@ class DBSession
/** /**
* Function Query, just to execute the query. * Function Query, just to execute the query.
*
* @access public * @access public
* @param eter string strQuery * @param eter string strQuery
* @param eter string debug * @param eter string debug
@@ -160,20 +167,21 @@ class DBSession
die; die;
} }
return; return;
} }
*/ */
/** /**
* Function Free * Function Free
*
* @access public * @access public
* @param eter string debug * @param eter string debug
* @return string * @return string
*/ */
function Free ($debug = false) function Free ($debug = false)
{ {
if ( is_resource($this->result) ) if (is_resource( $this->result )) {
$this->result->Free(); $this->result->Free();
}
return; return;
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.dbtable.php * class.dbtable.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -29,6 +31,7 @@
* This class provides acces to a generalized table * This class provides acces to a generalized table
* it assumes that the dbconnection object is already initialized, the table name, as well as the primary keys * it assumes that the dbconnection object is already initialized, the table name, as well as the primary keys
* for the table should be also provided in order to provide the class a way to generate an UPDATE query properly. * for the table should be also provided in order to provide the class a way to generate an UPDATE query properly.
*
* @package gulliver.system * @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team. * @copyright (C) 2002 by Colosa Development Team.
@@ -54,14 +57,13 @@ class DBTable
* @param object $objConnection conecction string * @param object $objConnection conecction string
* @return void * @return void
*/ */
function dBTable( $objConnection = NULL, $strTable = "", $arrKeys = array( 'UID' ) ) function dBTable ($objConnection = null, $strTable = "", $arrKeys = array( 'UID' ))
{ {
$this->_dbc = NULL; $this->_dbc = null;
$this->_dbses = NULL; $this->_dbses = null;
$this->SetTo( $objConnection, $strTable, $arrKeys ); $this->SetTo( $objConnection, $strTable, $arrKeys );
} }
/** /**
* Initiate a database conecction using default values * Initiate a database conecction using default values
* *
@@ -76,25 +78,23 @@ class DBTable
{ {
$this->_dbc = $objDBConnection; $this->_dbc = $objDBConnection;
if( $this->_dbc != NULL && strcasecmp( get_class( $objDBConnection ) , 'dbconnection' ) == 0 ) if ($this->_dbc != null && strcasecmp( get_class( $objDBConnection ), 'dbconnection' ) == 0) {
{
$this->_dbses = new DBSession( $this->_dbc ); $this->_dbses = new DBSession( $this->_dbc );
$this->_dbses->UseDB( DB_NAME ); $this->_dbses->UseDB( DB_NAME );
} } else {
else { $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBTable function without create an instance of DBConnection", 'G_Error', true );
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBTable function without create an instance of DBConnection",
'G_Error', true);
//DBconnection::logError( $dberror ); //DBconnection::logError( $dberror );
return $dberror; return $dberror;
} }
$this->is_new = true; $this->is_new = true;
$this->Fields = NULL; $this->Fields = null;
$this->table_name = $strTable; $this->table_name = $strTable;
if ( is_array ( $arrKeys ) ) if (is_array( $arrKeys )) {
$this->table_keys = $arrKeys; $this->table_keys = $arrKeys;
else } else {
$this->table_keys = array ( 0 => $arrKeys ); $this->table_keys = array (0 => $arrKeys
);
}
$this->errorLevel = $this->_dbc->errorLevel; $this->errorLevel = $this->_dbc->errorLevel;
} }
@@ -111,29 +111,23 @@ class DBTable
$dset = $this->_dbses->execute( $stQry ); $dset = $this->_dbses->execute( $stQry );
//$dset = new DBRecordSet( $this->_dbses->Result ); //$dset = new DBRecordSet( $this->_dbses->Result );
$nlim = $dset->Count(); $nlim = $dset->Count();
$this->Fields = NULL; $this->Fields = null;
for( $ncount = 0; $ncount < $nlim; $ncount++ ) for ($ncount = 0; $ncount < $nlim; $ncount ++) {
{
$data = $dset->Read(); $data = $dset->Read();
$fname = $data['Field']; $fname = $data['Field'];
$fval = ""; $fval = "";
$ftypearr = explode( $data['Type'], '(' ); $ftypearr = explode( $data['Type'], '(' );
$ftype = $ftypearr[0]; $ftype = $ftypearr[0];
if( $data['Key'] == 'PRI' ) if ($data['Key'] == 'PRI') {
{ if (is_array( $this->table_keys )) {
if( is_array($this->table_keys) )
{
$this->table_keys[count( $this->table_keys ) - 1] = $fname; $this->table_keys[count( $this->table_keys ) - 1] = $fname;
} } else {
else
{
$this->table_keys[0] = $fname; $this->table_keys[0] = $fname;
} }
} }
switch( $ftype ) switch ($ftype) {
{
case 'int': case 'int':
case 'smallint': case 'smallint':
case 'tinyint': case 'tinyint':
@@ -160,11 +154,12 @@ class DBTable
*/ */
function loadWhere ($strWhere) function loadWhere ($strWhere)
{ {
$this->Fields = NULL; $this->Fields = null;
$stQry = "SELECT * FROM `" . $this->table_name . "`"; $stQry = "SELECT * FROM `" . $this->table_name . "`";
if( $strWhere != "" ) $stQry .= " WHERE " . $strWhere; if ($strWhere != "") {
$stQry .= " WHERE " . $strWhere;
}
$this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel ); $this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel );
if (DB::isError( $this->_dset )) { if (DB::isError( $this->_dset )) {
return $this->_dset; return $this->_dset;
@@ -173,10 +168,8 @@ class DBTable
if ($this->_dset->Count() > 0) { if ($this->_dset->Count() > 0) {
$this->Fields = $this->_dset->Read(); $this->Fields = $this->_dset->Read();
$this->is_new = false; $this->is_new = false;
} } else {
else $this->Fields = null;
{
$this->Fields = NULL;
$this->is_new = true; $this->is_new = true;
} }
@@ -201,19 +194,15 @@ class DBTable
foreach ($this->table_keys as $key => $val) { foreach ($this->table_keys as $key => $val) {
if ($stWhere == "") { if ($stWhere == "") {
$stWhere .= " $val = '" . $arrKeys[0][$val] . "' "; $stWhere .= " $val = '" . $arrKeys[0][$val] . "' ";
}else } else {
$stWhere .= " AND $val = '" . $arrKeys[0][$val] . "' "; $stWhere .= " AND $val = '" . $arrKeys[0][$val] . "' ";
} }
} }
else { } else {
foreach( $arrKeys as $val ) foreach ($arrKeys as $val) {
{ if ($stWhere == "") {
if( $stWhere == "" )
{
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'"; $stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
} } else {
else
{
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'"; $stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
} }
$ncount ++; $ncount ++;
@@ -224,6 +213,7 @@ class DBTable
/** /**
* Function nextvalPGSql * Function nextvalPGSql
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string seq * @param eter string seq
@@ -247,25 +237,28 @@ class DBTable
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* @access public * @access public
* @return boolean * @return boolean
*
*/ */
function insert () { function insert ()
{
$strFields = ""; $strFields = "";
$strValues = ""; $strValues = "";
if( defined('DB_ADAPTER')) if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER; $DBEngine = DB_ADAPTER;
else } else {
$DBEngine = 'mysql'; $DBEngine = 'mysql';
}
foreach ($this->Fields as $field => $val) { foreach ($this->Fields as $field => $val) {
$strFields .= $field . ","; $strFields .= $field . ",";
$iskey = false; $iskey = false;
if ( isset ( $this->table_keys ) && is_array ( $this->table_keys ) ) if (isset( $this->table_keys ) && is_array( $this->table_keys )) {
$iskey = in_array( $field, $this->table_keys ) && strtoupper( substr( trim( $val ), 0, 7 ) ) == "NEXTVAL"; $iskey = in_array( $field, $this->table_keys ) && strtoupper( substr( trim( $val ), 0, 7 ) ) == "NEXTVAL";
}
$dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine; $dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
// Commented by new format of textarea in javascript // Commented by new format of textarea in javascript
if( ! $iskey ) if (! $iskey) {
$val = "'" . $val . "'"; $val = "'" . $val . "'";
}
///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'"; ///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
$strValues .= $val . ", "; $strValues .= $val . ", ";
} }
@@ -292,26 +285,26 @@ class DBTable
$stWhere = ''; $stWhere = '';
$remainKeys = array (); $remainKeys = array ();
if(defined('DB_ADAPTER')) if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER; $DBEngine = DB_ADAPTER;
else } else {
$DBEngine = 'mysql'; $DBEngine = 'mysql';
}
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false; foreach ($this->table_keys as $k => $v) {
foreach( $this->Fields as $field => $val ) $remainKeys[$v] = false;
{ }
foreach ($this->Fields as $field => $val) {
$iskey = false; $iskey = false;
$iskey = in_array( $field, $this->table_keys ); $iskey = in_array( $field, $this->table_keys );
if ($iskey == false) { if ($iskey == false) {
$stQry .= $field . "='" . $val . "', "; $stQry .= $field . "='" . $val . "', ";
// Commented by new format of textarea in javascript // Commented by new format of textarea in javascript
///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', "; ///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
} } else {
else {
if ($stWhere == "") { if ($stWhere == "") {
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; $stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} } else {
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; $stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} }
$remainKeys[$field] = true; $remainKeys[$field] = true;
@@ -319,17 +312,23 @@ class DBTable
} }
foreach ($remainKeys as $field => $bool) foreach ($remainKeys as $field => $bool)
if ($bool == false) { if ($bool == false) {
if( $stWhere != "" ) $stWhere = " AND "; if ($stWhere != "") {
$stWhere = " AND ";
}
$stWhere .= $field . "= ''"; $stWhere .= $field . "= ''";
$remainKeys[$field] = true; $remainKeys[$field] = true;
} }
$stQry = trim( $stQry ); $stQry = trim( $stQry );
$stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma , $stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma ,
if (!$stQry) return; if (! $stQry) {
return;
}
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry; $stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
$stWhere = trim( $stWhere ); $stWhere = trim( $stWhere );
if( $stWhere != "" ) $stQry .= " WHERE " . $stWhere; if ($stWhere != "") {
$stQry .= " WHERE " . $stWhere;
}
$result = false; $result = false;
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel ); $result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
@@ -348,11 +347,12 @@ class DBTable
*/ */
function save () function save ()
{ {
if ( $this->is_new == true ) if ($this->is_new == true) {
return $this->Insert(); return $this->Insert();
else } else {
return $this->Update(); return $this->Update();
} }
}
/** /**
* Delete an existing row * Delete an existing row
@@ -367,22 +367,22 @@ class DBTable
$stWhere = ''; $stWhere = '';
$remainKeys = array (); $remainKeys = array ();
if(defined('DB_ADAPTER')) if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER; $DBEngine = DB_ADAPTER;
else } else {
$DBEngine = 'mysql'; $DBEngine = 'mysql';
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false; }
foreach ($this->table_keys as $k => $v) {
$remainKeys[$v] = false;
}
if (is_array( $this->Fields )) { if (is_array( $this->Fields )) {
foreach( $this->Fields as $field => $val ) foreach ($this->Fields as $field => $val) {
{
$iskey = false; $iskey = false;
$iskey = in_array( $field, $this->table_keys ); $iskey = in_array( $field, $this->table_keys );
if ($iskey == true) { if ($iskey == true) {
if ($stWhere == "") { if ($stWhere == "") {
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; $stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} } else {
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; $stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} }
$remainKeys[$field] = true; $remainKeys[$field] = true;
@@ -391,7 +391,9 @@ class DBTable
} }
foreach ($remainKeys as $field => $bool) foreach ($remainKeys as $field => $bool)
if ($bool == false) { if ($bool == false) {
if( $stWhere != "" ) $stWhere .= " AND "; if ($stWhere != "") {
$stWhere .= " AND ";
}
$stWhere .= $field . "= ''"; $stWhere .= $field . "= ''";
$remainKeys[$field] = true; $remainKeys[$field] = true;
} }
@@ -399,9 +401,7 @@ class DBTable
$stQry = trim( $stQry ); $stQry = trim( $stQry );
$stWhere = trim( $stWhere ); $stWhere = trim( $stWhere );
if ($stWhere == '') { if ($stWhere == '') {
$dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null', $dberror = PEAR::raiseError( null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true );
"You tried to call delete method without WHERE clause, if you want to delete all records use dbsession",
'G_Error', true);
DBconnection::logError( $dberror, $this->errorLevel ); DBconnection::logError( $dberror, $this->errorLevel );
return $dberror; return $dberror;
} }
@@ -426,3 +426,4 @@ class DBTable
$this->Fields = $this->_dset->read(); $this->Fields = $this->_dset->read();
} }
} }

View File

@@ -1,19 +1,23 @@
<?php <?php
/** /**
* HttpProxyController * HttpProxyController
*
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com> * @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @package gulliver.system * @package gulliver.system
* @access private * @access private
*/ */
class HttpProxyController { class HttpProxyController
{
/** /**
*
* @var array - private array to store proxy data * @var array - private array to store proxy data
*/ */
private $__data__ = array (); private $__data__ = array ();
/** /**
*
* @var object - private object to store the http request data * @var object - private object to store the http request data
*/ */
private $__request__; private $__request__;
@@ -21,13 +25,15 @@ class HttpProxyController {
public $jsonResponse = true; public $jsonResponse = true;
private $sendResponse = true; private $sendResponse = true;
/** /**
* Magic setter method * Magic setter method
* *
* @param string $name * @param string $name
* @param string $value * @param string $value
*/ */
public function __set($name, $value) { public function __set ($name, $value)
{
//echo "Setting '$name' to '$value'\n"; //echo "Setting '$name' to '$value'\n";
$this->__data__[$name] = $value; $this->__data__[$name] = $value;
} }
@@ -38,7 +44,8 @@ class HttpProxyController {
* @param string $name * @param string $name
* @return string or NULL if the internal var doesn't exist * @return string or NULL if the internal var doesn't exist
*/ */
public function __get($name) { public function __get ($name)
{
//echo "Getting '$name'\n"; //echo "Getting '$name'\n";
if (array_key_exists( $name, $this->__data__ )) { if (array_key_exists( $name, $this->__data__ )) {
return $this->__data__[$name]; return $this->__data__[$name];
@@ -58,18 +65,19 @@ class HttpProxyController {
* *
* @param string $name * @param string $name
*/ */
public function __isset($name) { public function __isset ($name)
{
//echo "Is '$name' set?\n"; //echo "Is '$name' set?\n";
return isset( $this->__data__[$name] ); return isset( $this->__data__[$name] );
} }
/** /**
* Magic unset method * Magic unset method
* *
* @param string $name * @param string $name
*/ */
public function __unset($name) { public function __unset ($name)
{
//echo "Unsetting '$name'\n"; //echo "Unsetting '$name'\n";
unset( $this->__data__[$name] ); unset( $this->__data__[$name] );
} }
@@ -88,17 +96,26 @@ class HttpProxyController {
return null; return null;
} }
if( ! $result ) if (! $result) {
$result = $this->__data__; $result = $this->__data__;
}
} catch (Exception $e) { } catch (Exception $e) {
$result->success = false; $result->success = false;
$result->message = $result->msg = $e->getMessage(); $result->message = $result->msg = $e->getMessage();
switch (get_class( $e )) { switch (get_class( $e )) {
case 'Exception': $error = "SYSTEM ERROR"; break; case 'Exception':
case 'PMException': $error = "PROCESSMAKER ERROR"; break; $error = "SYSTEM ERROR";
case 'PropelException': $error = "DATABASE ERROR"; break; break;
case 'UserException': $error = "USER ERROR"; break; case 'PMException':
$error = "PROCESSMAKER ERROR";
break;
case 'PropelException':
$error = "DATABASE ERROR";
break;
case 'UserException':
$error = "USER ERROR";
break;
} }
$result->error = $e->getMessage(); $result->error = $e->getMessage();
@@ -120,11 +137,13 @@ class HttpProxyController {
public function setHttpRequestData ($data) public function setHttpRequestData ($data)
{ {
if (is_array( $data )) { if (is_array( $data )) {
while( $var = each($data) ) while ($var = each( $data )) {
$this->__request__->$var['key'] = $var['value']; $this->__request__->$var['key'] = $var['value'];
} else }
} else {
$this->__request__ = $data; $this->__request__ = $data;
} }
}
public function setJsonResponse ($bool) public function setJsonResponse ($bool)
{ {
@@ -141,3 +160,4 @@ class HttpProxyController {
$this->sendResponse = $val; $this->sendResponse = $val;
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.dbtable.php * class.dbtable.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -36,7 +38,7 @@
class i18n_PO class i18n_PO
{ {
private $_file = NULL; private $_file = null;
private $_string = ''; private $_string = '';
private $_meta; private $_meta;
private $_fp; private $_fp;
@@ -72,7 +74,7 @@ class i18n_PO
// lock PO file exclusively // lock PO file exclusively
if (! flock( $this->_fp, LOCK_EX )) { if (! flock( $this->_fp, LOCK_EX )) {
fclose( $this->_fp ); fclose( $this->_fp );
return FALSE; return false;
} }
$this->_meta = 'msgid ""'; $this->_meta = 'msgid ""';
@@ -80,10 +82,11 @@ class i18n_PO
$this->_meta = 'msgstr ""'; $this->_meta = 'msgstr ""';
$this->_writeLine( $this->_meta ); $this->_writeLine( $this->_meta );
$this->_editingHeader = TRUE; $this->_editingHeader = true;
} }
function readInit(){ function readInit ()
{
$this->_fp = fopen( $this->file, 'r' ); $this->_fp = fopen( $this->file, 'r' );
if (! is_resource( $this->_fp )) { if (! is_resource( $this->_fp )) {
@@ -167,14 +170,19 @@ class i18n_PO
//$string = str_replace('\"', '"', $string); //$string = str_replace('\"', '"', $string);
//$string = stripslashes($string); //$string = stripslashes($string);
if ($reverse) { if ($reverse) {
$smap = array('"', "\n", "\t", "\r"); $smap = array ('"',"\n","\t","\r"
$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r'); );
$rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r'
);
return (string) str_replace( $smap, $rmap, $string ); return (string) str_replace( $smap, $rmap, $string );
} else { } else {
$string = preg_replace( '/"\s+"/', '', $string ); $string = preg_replace( '/"\s+"/', '', $string );
$smap = array('\\n', '\\r', '\\t', '\"'); $smap = array ('\\n','\\r','\\t','\"'
$rmap = array("\n", "\r", "\t", '"'); );
$rmap = array ("\n","\r","\t",'"'
);
return (string) str_replace( $smap, $rmap, $string ); return (string) str_replace( $smap, $rmap, $string );
} }
} }
@@ -182,13 +190,17 @@ class i18n_PO
function headerStroke () function headerStroke ()
{ {
if ($this->_editingHeader) { if ($this->_editingHeader) {
$this->_editingHeader = FALSE; $this->_editingHeader = false;
$this->_writeLine('');; $this->_writeLine( '' );
;
} }
} }
/** read funtions **/ /**
private function skipCommets(){ * read funtions *
*/
private function skipCommets ()
{
$this->_fileComments = ''; $this->_fileComments = '';
do { do {
$lastPos = ftell( $this->_fp ); $lastPos = ftell( $this->_fp );
@@ -212,6 +224,7 @@ class i18n_PO
if ($this->flagInit) { //in first instance if ($this->flagInit) { //in first instance
$this->flagInit = false; //unset init flag $this->flagInit = false; //unset init flag
//read the first and second line of the file //read the first and second line of the file
$firstLine = fgets( $this->_fp ); $firstLine = fgets( $this->_fp );
$secondLine = fgets( $this->_fp ); $secondLine = fgets( $this->_fp );
@@ -248,6 +261,7 @@ class i18n_PO
} }
} //end looking for headeers } //end looking for headeers
//verifying the headers data //verifying the headers data
if (! isset( $this->_meta['X-Poedit-Language'] )) { if (! isset( $this->_meta['X-Poedit-Language'] )) {
$this->flagError = true; $this->flagError = true;
@@ -270,11 +284,13 @@ class i18n_PO
} }
} }
function getHeaders() { function getHeaders ()
{
return $this->_meta; return $this->_meta;
} }
public function getTranslation(){ public function getTranslation ()
{
$flagReadingComments = true; $flagReadingComments = true;
$this->translatorComments = Array (); $this->translatorComments = Array ();
@@ -289,8 +305,9 @@ class i18n_PO
//set line number //set line number
$this->lineNumber ++; $this->lineNumber ++;
if( ! $this->_fileLine ) if (! $this->_fileLine) {
return false; return false;
}
$prefix = substr( $this->_fileLine, 0, 2 ); $prefix = substr( $this->_fileLine, 0, 2 );
@@ -300,33 +317,33 @@ class i18n_PO
$this->translatorComments[] = $lineItem; $this->translatorComments[] = $lineItem;
break; break;
case '#.': case '#.':
if( substr_count($this->_fileLine, '#. ') == 0 ) if (substr_count( $this->_fileLine, '#. ' ) == 0) {
$this->flagError = true; $this->flagError = true;
else { } else {
$lineItem = str_replace( '#. ', '', $this->_fileLine ); $lineItem = str_replace( '#. ', '', $this->_fileLine );
$this->extractedComments[] = $lineItem; $this->extractedComments[] = $lineItem;
} }
break; break;
case '#:': case '#:':
if( substr_count($this->_fileLine, '#: ') == 0 ) if (substr_count( $this->_fileLine, '#: ' ) == 0) {
$this->flagError = true; $this->flagError = true;
else { } else {
$lineItem = str_replace( '#: ', '', $this->_fileLine ); $lineItem = str_replace( '#: ', '', $this->_fileLine );
$this->references[] = $lineItem; $this->references[] = $lineItem;
} }
break; break;
case '#,': case '#,':
if( substr_count($this->_fileLine, '#, ') == 0 ) if (substr_count( $this->_fileLine, '#, ' ) == 0) {
$this->flagError = true; $this->flagError = true;
else { } else {
$lineItem = str_replace( '#, ', '', $this->_fileLine ); $lineItem = str_replace( '#, ', '', $this->_fileLine );
$this->flags[] = $lineItem; $this->flags[] = $lineItem;
} }
break; break;
case '#|': case '#|':
if( substr_count($this->_fileLine, '#| ') == 0 ) if (substr_count( $this->_fileLine, '#| ' ) == 0) {
$this->flagError = true; $this->flagError = true;
else { } else {
$lineItem = str_replace( '#| ', '', $this->_fileLine ); $lineItem = str_replace( '#| ', '', $this->_fileLine );
$this->previousUntranslatedStrings[] = $lineItem; $this->previousUntranslatedStrings[] = $lineItem;
} }
@@ -336,14 +353,16 @@ class i18n_PO
} }
} }
if( ! $this->_fileLine ) if (! $this->_fileLine) {
return false; return false;
}
//Getting the msgid //Getting the msgid
preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match ); preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match );
if( sizeof($match) != 2 ) if (sizeof( $match ) != 2) {
throw new Exception( 'Invalid PO file format1' ); throw new Exception( 'Invalid PO file format1' );
}
$msgid = ''; $msgid = '';
@@ -357,8 +376,9 @@ class i18n_PO
//Getting the msgstr //Getting the msgstr
preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match ); preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match );
if( sizeof($match) != 2 ) if (sizeof( $match ) != 2) {
throw new Exception( 'Invalid PO file format2' ); throw new Exception( 'Invalid PO file format2' );
}
$msgstr = ''; $msgstr = '';
@@ -369,19 +389,21 @@ class i18n_PO
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match ); preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
} while (sizeof( $match ) == 2); } while (sizeof( $match ) == 2);
/*g::pr($this->translatorComments); /*g::pr($this->translatorComments);
g::pr($this->references); g::pr($this->references);
g::pr($match); g::pr($match);
die;*/ die;*/
return Array('msgid'=>trim($msgid), 'msgstr'=>trim($msgstr)); return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr )
);
} }
//garbage //garbage
function __destruct () function __destruct ()
{ {
if ( $this->_fp ) if ($this->_fp) {
fclose( $this->_fp ); fclose( $this->_fp );
} }
} }
}

View File

@@ -1,6 +1,7 @@
<?php <?php
/** /**
* class.mailer.php * class.mailer.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -39,10 +40,11 @@ G::LoadThirdParty('phpmailer','class.phpmailer');
* @author David Callizaya <davidsantos@colosa.com> * @author David Callizaya <davidsantos@colosa.com>
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
**/ *
*/
class mailer class mailer
{ {
@@ -54,7 +56,7 @@ class mailer
*/ */
function instanceMailer () function instanceMailer ()
{ {
$mailer = new PHPMailer; $mailer = new PHPMailer();
$mailer->PluginDir = PATH_THIRDPARTY . 'phpmailer/'; $mailer->PluginDir = PATH_THIRDPARTY . 'phpmailer/';
//DEFAULT CONFIGURATION //DEFAULT CONFIGURATION
$mailer->Mailer = 'mail'; $mailer->Mailer = 'mail';
@@ -65,14 +67,30 @@ class mailer
$mailer->Timeout = 30; $mailer->Timeout = 30;
$mailer->CharSet = 'utf-8'; $mailer->CharSet = 'utf-8';
$mailer->Encoding = 'base64'; $mailer->Encoding = 'base64';
if (defined('MAIL_MAILER')) $mailer->Mailer = MAIL_MAILER; if (defined( 'MAIL_MAILER' )) {
if (defined('MAIL_HOST')) $mailer->Host = MAIL_HOST; $mailer->Mailer = MAIL_MAILER;
if (defined('MAIL_SMTPAUTH')) $mailer->SMTPAuth = MAIL_SMTPAUTH; }
if (defined('MAIL_USERNAME')) $mailer->Username = MAIL_USERNAME; if (defined( 'MAIL_HOST' )) {
if (defined('MAIL_PASSWORD')) $mailer->Password = MAIL_PASSWORD; $mailer->Host = MAIL_HOST;
if (defined('MAIL_TIMEOUT')) $mailer->Timeout = MAIL_TIMEOUT; }
if (defined('MAIL_CHARSET')) $mailer->CharSet = MAIL_CHARSET; if (defined( 'MAIL_SMTPAUTH' )) {
if (defined('MAIL_ENCODING')) $mailer->Encoding= MAIL_ENCODING; $mailer->SMTPAuth = MAIL_SMTPAUTH;
}
if (defined( 'MAIL_USERNAME' )) {
$mailer->Username = MAIL_USERNAME;
}
if (defined( 'MAIL_PASSWORD' )) {
$mailer->Password = MAIL_PASSWORD;
}
if (defined( 'MAIL_TIMEOUT' )) {
$mailer->Timeout = MAIL_TIMEOUT;
}
if (defined( 'MAIL_CHARSET' )) {
$mailer->CharSet = MAIL_CHARSET;
}
if (defined( 'MAIL_ENCODING' )) {
$mailer->Encoding = MAIL_ENCODING;
}
return $mailer; return $mailer;
} }
@@ -116,8 +134,9 @@ class mailer
//Replace the @@Fields with the $Fields array. //Replace the @@Fields with the $Fields array.
$content = mailer::replaceFields( $Fields, $content ); $content = mailer::replaceFields( $Fields, $content );
//Compatibility with class.Application //Compatibility with class.Application
if ($attachs==='FALSE') if ($attachs === 'FALSE') {
return $content; return $content;
}
//Create the alternative body (text only) //Create the alternative body (text only)
//$h2t =& new html2text($content); //$h2t =& new html2text($content);
$text = ''; //$h2t->get_text(); $text = ''; //$h2t->get_text();
@@ -131,10 +150,12 @@ class mailer
$mailer->AddCC( $cc ); $mailer->AddCC( $cc );
$mailer->AddBCC( $bcc ); $mailer->AddBCC( $bcc );
$mailer->Subject = $subject; $mailer->Subject = $subject;
if ($plainText) if ($plainText) {
$content = $text; $content = $text;
if ($content==='') }
if ($content === '') {
$content = 'empty'; $content = 'empty';
}
$mailer->Body = $content; $mailer->Body = $content;
//$mailer->AltBody = $text; //$mailer->AltBody = $text;
$mailer->isHTML( ! $plainText ); $mailer->isHTML( ! $plainText );
@@ -146,10 +167,14 @@ class mailer
//Send the e-mail. //Send the e-mail.
for ($r = 1; $r <= 4; $r ++) { for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send(); $result = $mailer->Send();
if ($result) break; if ($result) {
break;
}
} }
//unset($h2t); //unset($h2t);
if ($result && $returnContent) return $content; if ($result && $returnContent) {
return $content;
}
return $result; return $result;
} }
@@ -186,8 +211,12 @@ class mailer
$mailer->AddCC( $cc ); $mailer->AddCC( $cc );
$mailer->AddBCC( $bcc ); $mailer->AddBCC( $bcc );
$mailer->Subject = $subject; $mailer->Subject = $subject;
if ($plainText) $content = $text; if ($plainText) {
if ($content==='') $content='empty'; $content = $text;
}
if ($content === '') {
$content = 'empty';
}
$mailer->Body = $content; $mailer->Body = $content;
//$mailer->AltBody = $text; //$mailer->AltBody = $text;
$mailer->isHTML( ! $plainText ); $mailer->isHTML( ! $plainText );
@@ -199,10 +228,14 @@ class mailer
//Send the e-mail. //Send the e-mail.
for ($r = 1; $r <= 4; $r ++) { for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send(); $result = $mailer->Send();
if ($result) break; if ($result) {
break;
}
} }
//unset($h2t); //unset($h2t);
if ($result && $returnContent) return $content; if ($result && $returnContent) {
return $content;
}
return $result; return $result;
} }
@@ -231,18 +264,24 @@ class mailer
$mailer->AddCC( $cc ); $mailer->AddCC( $cc );
$mailer->AddBCC( $bcc ); $mailer->AddBCC( $bcc );
$mailer->Subject = $subject; $mailer->Subject = $subject;
if ($content==='') $content='empty'; if ($content === '') {
$content = 'empty';
}
$mailer->Body = $content; $mailer->Body = $content;
$mailer->AltBody = $content; $mailer->AltBody = $content;
$mailer->isHTML( false ); $mailer->isHTML( false );
//Attach the required files //Attach the required files
if (sizeof($attachs)>0) if (sizeof( $attachs ) > 0) {
foreach($attachs as $aFile) foreach ($attachs as $aFile) {
$mailer->AddAttachment( $aFile, basename( $aFile ) ); $mailer->AddAttachment( $aFile, basename( $aFile ) );
}
}
//Send the e-mail. //Send the e-mail.
for ($r = 1; $r <= 4; $r ++) { for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send(); $result = $mailer->Send();
if ($result) break; if ($result) {
break;
}
} }
return $result; return $result;
} }
@@ -264,6 +303,7 @@ class mailer
* html2text * html2text
* *
* empty * empty
*
* @return none * @return none
*/ */
function html2text () function html2text ()
@@ -272,4 +312,4 @@ class mailer
//return $h2t->get_text(); //return $h2t->get_text();
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.menu.php * class.menu.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -24,12 +26,16 @@
* *
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
*
*/ */
/** /**
*
* *
* Menu class definition * Menu class definition
* Render Menus * Render Menus
*
* @package gulliver.system * @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com> * @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team. * @copyright (C) 2002 by Colosa Development Team.
@@ -37,18 +43,18 @@
*/ */
class Menu class Menu
{ {
var $Id = NULL; var $Id = null;
var $Options = NULL; var $Options = null;
var $Labels = NULL; var $Labels = null;
var $Icons = NULL; var $Icons = null;
var $JS = NULL; var $JS = null;
var $Types = NULL; var $Types = null;
var $Class = "mnu"; var $Class = "mnu";
var $Classes = NULL; var $Classes = null;
var $Enabled = NULL; var $Enabled = null;
var $optionOn = - 1; var $optionOn = - 1;
var $id_optionOn = ""; var $id_optionOn = "";
var $ElementClass = NULL; var $ElementClass = null;
/** /**
* Set menu style * Set menu style
@@ -74,8 +80,8 @@ class Menu
function Load ($strMenuName) function Load ($strMenuName)
{ {
global $G_TMP_MENU; global $G_TMP_MENU;
$G_TMP_MENU = NULL; $G_TMP_MENU = null;
$G_TMP_MENU = new Menu; $G_TMP_MENU = new Menu();
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php"; $fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
//if the menu file doesn't exists, then try with the plugins folders //if the menu file doesn't exists, then try with the plugins folders
@@ -83,14 +89,15 @@ class Menu
$aux = explode( PATH_SEP, $strMenuName ); $aux = explode( PATH_SEP, $strMenuName );
if (count( $aux ) == 2) { if (count( $aux ) == 2) {
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php"; $fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
} }
} }
}
if( !is_file( $fMenu ) ) if (! is_file( $fMenu )) {
return; return;
}
include ($fMenu); include ($fMenu);
//this line will add options to current menu. //this line will add options to current menu.
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
@@ -111,11 +118,14 @@ class Menu
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i]; $this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
$c ++; $c ++;
} else { } else {
if ($i == $this->optionOn) $this->optionOn = -1; if ($i == $this->optionOn)
elseif ($i < $this->optionOn) $this->optionOn--; $this->optionOn = - 1;
elseif ($this->optionOn > 0) $this->optionOn--;//added this line elseif ($i < $this->optionOn)
$this->optionOn --;
elseif ($this->optionOn > 0)
$this->optionOn --; //added this line
} }
$G_TMP_MENU = NULL; $G_TMP_MENU = null;
} }
/** /**
@@ -128,8 +138,7 @@ class Menu
function OptionCount () function OptionCount ()
{ {
$result = 0; $result = 0;
if( is_array( $this->Options ) ) if (is_array( $this->Options )) {
{
$result = count( $this->Options ); $result = count( $this->Options );
} }
return $result; return $result;
@@ -177,9 +186,9 @@ class Menu
if (is_array( $strId )) { if (is_array( $strId )) {
$this->Id[$pos] = $strId[0]; $this->Id[$pos] = $strId[0];
$this->Classes[$pos] = $strId[1]; $this->Classes[$pos] = $strId[1];
} } else {
else
$this->Id[$pos] = $strId; $this->Id[$pos] = $strId;
}
unset( $pos ); unset( $pos );
} }
@@ -228,9 +237,9 @@ class Menu
if (is_array( $strId )) { if (is_array( $strId )) {
$this->Id[$pos] = $strId[0]; $this->Id[$pos] = $strId[0];
$this->Classes[$pos] = $strId[1]; $this->Classes[$pos] = $strId[1];
} } else {
else
$this->Id[$pos] = $strId; $this->Id[$pos] = $strId;
}
unset( $pos ); unset( $pos );
} }
@@ -257,9 +266,10 @@ class Menu
*/ */
function DisableOptionId ($id) function DisableOptionId ($id)
{ {
if ( array_search ($id, $this->Id) ) if (array_search( $id, $this->Id )) {
$this->Enabled[array_search( $id, $this->Id )] = 0; $this->Enabled[array_search( $id, $this->Id )] = 0;
} }
}
/** /**
* Render an menu's option * Render an menu's option
@@ -271,24 +281,23 @@ class Menu
*/ */
function RenderOption ($intPos) function RenderOption ($intPos)
{ {
if ( $this->Enabled[$intPos] != 1) if ($this->Enabled[$intPos] != 1) {
return; return;
$classname = $this->Class . "Link";
if ( $this->Classes[$intPos] != "" ) $classname = $this->Classes[$intPos];
$target = $this->Options[$intPos];
if( $this->Types[$intPos] != "absolute" )
{
if (defined('ENABLE_ENCRYPT')) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
} }
else $classname = $this->Class . "Link";
if (defined('SYS_SYS')) if ($this->Classes[$intPos] != "") {
$classname = $this->Classes[$intPos];
}
$target = $this->Options[$intPos];
if ($this->Types[$intPos] != "absolute") {
if (defined( 'ENABLE_ENCRYPT' )) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target; $target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
else } else if (defined( 'SYS_SYS' )) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
} else {
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target; $target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
} }
}
$label = $this->Labels[$intPos]; $label = $this->Labels[$intPos];
$result = "<a href=\"$target\""; $result = "<a href=\"$target\"";
$result .= " class=\"$classname\">"; $result .= " class=\"$classname\">";
@@ -310,7 +319,8 @@ class Menu
* @param string $G_ID_MENU_SELECTED * @param string $G_ID_MENU_SELECTED
* @return array * @return array
*/ */
function generateArrayForTemplate($G_MAIN_MENU,$classOn,$classOff,$G_MENU_SELECTED, $G_ID_MENU_SELECTED ) { function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
{
$menus = array (); $menus = array ();
if ($G_MAIN_MENU == null) { if ($G_MAIN_MENU == null) {
return $menus; return $menus;
@@ -319,10 +329,8 @@ class Menu
$this->optionOn = $G_MENU_SELECTED; $this->optionOn = $G_MENU_SELECTED;
$this->id_optionOn = $G_ID_MENU_SELECTED; $this->id_optionOn = $G_ID_MENU_SELECTED;
//$this->Class = $G_MENU_CLASS; //$this->Class = $G_MENU_CLASS;
if (is_array($this->Options)) if (is_array( $this->Options )) {
{ for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) {
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++)
{
$target = $this->Options[$ncount]; $target = $this->Options[$ncount];
//$aux = $this->Icons[$ncount]; //$aux = $this->Icons[$ncount];
@@ -334,16 +342,14 @@ class Menu
if ($this->Types[$ncount] != 'absolute') { if ($this->Types[$ncount] != 'absolute') {
if (defined( 'SYS_SYS' )) { if (defined( 'SYS_SYS' )) {
$target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] ); $target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
} } else {
else {
$target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] ); $target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
} }
} }
$label = $this->Labels[$ncount]; $label = $this->Labels[$ncount];
if ($this->id_optionOn != '') { if ($this->id_optionOn != '') {
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false); $onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
} } else {
else {
$onMenu = ($ncount == $this->optionOn ? true : false); $onMenu = ($ncount == $this->optionOn ? true : false);
} }
$classname = ($onMenu ? $classOn : $classOff); $classname = ($onMenu ? $classOn : $classOff);
@@ -354,8 +360,7 @@ class Menu
} }
$icon = ''; $icon = '';
if ($this->Icons[$ncount] !== '') { if ($this->Icons[$ncount] !== '') {
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" . $icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" . "<img src=\"" . $this->Icons[$ncount] . "\" border=\"0\"/></a>";
"<img src=\"". $this->Icons[$ncount] . "\" border=\"0\"/></a>";
$icon = $this->Icons[$ncount]; $icon = $this->Icons[$ncount];
} }
if ($this->Classes[$ncount] != '') { if ($this->Classes[$ncount] != '') {
@@ -369,11 +374,11 @@ class Menu
$elementclass = 'class="' . $this->ElementClass[$ncount] . '"'; $elementclass = 'class="' . $this->ElementClass[$ncount] . '"';
} }
$menus[] = array ( 'id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname, $menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass
'imageLeft' => $imageLeft, 'onclick' => $onclick, );
'icon' => $icon, 'aux' => $aux,'idName' => $idName,'elementclass'=>$elementclass);
} }
} }
return $menus; return $menus;
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.objectTemplate.php * class.objectTemplate.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -26,14 +28,17 @@
/** /**
* Class objectTemplate * Class objectTemplate
*
* @package gulliver.system * @package gulliver.system
* @access public * @access public
*/ */
class objectTemplate extends smarty class objectTemplate extends smarty
{ {
/** /**
* Function objectTemplate * Function objectTemplate
*
* @access public * @access public
* @param object $templateFile * @param object $templateFile
* @return void * @return void
@@ -51,6 +56,7 @@ class objectTemplate extends smarty
/** /**
* Function printObject * Function printObject
*
* @access public * @access public
* @param object $object * @param object $object
* @return string * @return string
@@ -61,3 +67,4 @@ class objectTemplate extends smarty
return $this->fetch( $this->templateFile ); return $this->fetch( $this->templateFile );
} }
} }

View File

@@ -1,11 +1,12 @@
<?php <?php
/** /**
* class.testTools.php * class.testTools.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
*
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -26,11 +27,14 @@
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
**/ *
*/
G::LoadSystem( 'ymlDomain' ); G::LoadSystem( 'ymlDomain' );
G::LoadSystem( 'ymlTestCases' ); G::LoadSystem( 'ymlTestCases' );
G::LoadSystem( 'unitTest' ); G::LoadSystem( 'unitTest' );
class testTools class testTools
{ {
@@ -94,7 +98,9 @@ class testTools
*/ */
function arrayAppend (&$to, $appendFrom) function arrayAppend (&$to, $appendFrom)
{ {
foreach($appendFrom as $appendItem) $to[]=$appendItem; foreach ($appendFrom as $appendItem) {
$to[] = $appendItem;
}
return true; return true;
} }
@@ -107,7 +113,9 @@ class testTools
*/ */
function arrayDelete (&$array) function arrayDelete (&$array)
{ {
foreach($array as $key => $value) unset($array[$key]); foreach ($array as $key => $value) {
unset( $array[$key] );
}
return true; return true;
} }
@@ -146,24 +154,26 @@ class testTools
if (is_array( $obj )) { if (is_array( $obj )) {
foreach ($obj as $key => $val) { foreach ($obj as $key => $val) {
if ($res = self::findValue( $value, $obj[$key] )) { if ($res = self::findValue( $value, $obj[$key] )) {
if ($res==true) return $key; if ($res == true) {
else return $key . '.' . $res;
}
}
return false;
}
elseif (is_object($obj)) {
foreach($obj as $key => $val ) {
if ($res=self::findValue( $value , $obj->$key )) {
if ($res==true)
return $key; return $key;
else } else {
return $key . '.' . $res; return $key . '.' . $res;
} }
} }
return false;
} }
else { return false;
} elseif (is_object( $obj )) {
foreach ($obj as $key => $val) {
if ($res = self::findValue( $value, $obj->$key )) {
if ($res == true) {
return $key;
} else {
return $key . '.' . $res;
}
}
}
return false;
} else {
return $obj == $value; return $obj == $value;
} }
} }
@@ -181,6 +191,9 @@ function domain($location)
{ {
global $testDomain; global $testDomain;
$result = $testDomain->get( $location ); $result = $testDomain->get( $location );
if (count($result)==0) trigger_error("'$location' is an empty domain.", E_USER_WARNING); if (count( $result ) == 0) {
trigger_error( "'$location' is an empty domain.", E_USER_WARNING );
}
return $result; return $result;
} }

View File

@@ -1,11 +1,12 @@
<?php <?php
/** /**
* class.tree.php * class.tree.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
*
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -26,10 +27,13 @@
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
*/ */
G::LoadSystem( 'objectTemplate' ); G::LoadSystem( 'objectTemplate' );
class Tree extends Xml_Node {
class Tree extends Xml_Node
{
var $template = 'tree.html'; var $template = 'tree.html';
var $nodeType = 'base'; var $nodeType = 'base';
var $nodeClass = 'treeNode'; var $nodeClass = 'treeNode';
@@ -50,12 +54,14 @@
* *
* @return none * @return none
*/ */
function Tree( $xmlnode = NULL ) function Tree ($xmlnode = null)
{ {
if (!isset($xmlnode)) if (! isset( $xmlnode )) {
return; return;
if (isset($xmlnode->attributes['nodeType'])) }
if (isset( $xmlnode->attributes['nodeType'] )) {
$this->nodeType = $xmlnode->attributes['nodeType']; $this->nodeType = $xmlnode->attributes['nodeType'];
}
foreach ($xmlnode as $key => $value) { foreach ($xmlnode as $key => $value) {
if ($key === 'children') { if ($key === 'children') {
foreach ($xmlnode->children as $key => $value) { foreach ($xmlnode->children as $key => $value) {
@@ -65,8 +71,7 @@
foreach ($xmlnode->attributes as $key => $value) { foreach ($xmlnode->attributes as $key => $value) {
$this->{$key} = $value; $this->{$key} = $value;
} }
} } else {
else {
$this->{$key} = $value; $this->{$key} = $value;
} }
} }
@@ -108,9 +113,7 @@
$point = ''; $point = '';
} }
} }
return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</span>". return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</span>" . "<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>" . "<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
"<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>".
"<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
} }
/** /**
@@ -133,8 +136,9 @@
$html = ''; $html = '';
$row = 0; $row = 0;
foreach ($this->children as $child) { foreach ($this->children as $child) {
if ($row) if ($row) {
$child->nodeClass = 'treeNodeAlternate'; $child->nodeClass = 'treeNodeAlternate';
}
$html .= $child->render(); $html .= $child->render();
$row = ($row + 1) % 2; $row = ($row + 1) % 2;
} }
@@ -143,11 +147,14 @@
/** /**
* render * render
*
* @return $obj->printObject( array( 'node' => &$this ) ) * @return $obj->printObject( array( 'node' => &$this ) )
*/ */
function render() { function render ()
{
$obj = new objectTemplate( $this->template ); $obj = new objectTemplate( $this->template );
return $obj->printObject( array( 'node' => &$this ) ); return $obj->printObject( array ('node' => &$this
) );
} }
} }

View File

@@ -1,11 +1,13 @@
<?php <?php
/** /**
* class.unitTest.php * class.unitTest.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
*
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -26,6 +28,7 @@
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
*/ */
@@ -36,9 +39,12 @@ class unitTest
var $yml; var $yml;
var $domain; var $domain;
var $testLime; var $testLime;
function unitTest ($ymlFile, &$testLime, &$testDomain) function unitTest ($ymlFile, &$testLime, &$testDomain)
{ {
if (!isset($testDomain)) $testDomain = new ymlDomain(); if (! isset( $testDomain )) {
$testDomain = new ymlDomain();
}
$this->domain = & $testDomain; $this->domain = & $testDomain;
$this->testLime = & $testLime; $this->testLime = & $testLime;
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime ); $this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
@@ -70,3 +76,4 @@ class unitTest
return $result; return $result;
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.webResource.php * class.webResource.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -33,6 +35,7 @@
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
*/ */
class WebResource class WebResource
@@ -56,16 +59,17 @@ class WebResource
//$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC //$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC
$parameters = G::json_decode( ($post['parameters']) ); $parameters = G::json_decode( ($post['parameters']) );
$paramsRef = array (); $paramsRef = array ();
foreach($parameters as $key => $value) foreach ($parameters as $key => $value) {
{ if (is_string( $key )) {
if (is_string($key)) $paramsRef[]="\$parameters['".addcslashes($key,'\\\'')."']"; $paramsRef[] = "\$parameters['" . addcslashes( $key, '\\\'' ) . "']";
else $paramsRef[]='$parameters['.$key.']'; } else {
$paramsRef[] = '$parameters[' . $key . ']';
}
} }
$res = eval( 'return ($this->' . $post['function'] . '(' . implode( ',', $paramsRef ) . '));' ); $res = eval( 'return ($this->' . $post['function'] . '(' . implode( ',', $paramsRef ) . '));' );
$res = G::json_encode( $res ); $res = G::json_encode( $res );
print ($res) ; print ($res) ;
} } else {
else {
/*Print class definition*/ /*Print class definition*/
$this->_encode(); $this->_encode();
} }
@@ -85,27 +89,18 @@ class WebResource
foreach ($methods as $method) { foreach ($methods as $method) {
//To avoid PHP version incompatibilities, put the $method name in lowercase //To avoid PHP version incompatibilities, put the $method name in lowercase
$method = strtolower( $method ); $method = strtolower( $method );
if ((substr($method,0,1)==='_')|| if ((substr( $method, 0, 1 ) === '_') || (strcasecmp( $method, 'WebResource' ) == 0) || (strcasecmp( $method, get_class( $this ) ) == 0)) {
(strcasecmp($method,'WebResource')==0)|| } elseif (strcasecmp( substr( $method, 0, 3 ), 'js_' ) == 0) {
(strcasecmp($method,get_class($this))==0) if (! $first) {
) print (',') ;
{
} }
elseif (strcasecmp(substr($method,0,3),'js_')==0)
{
if (!$first) print(',');
$this->{$method}(); $this->{$method}();
$first = false; $first = false;
} else {
if (! $first) {
print (',') ;
} }
else print ($method . ':function(){return __wrCall("' . addslashes( $this->_uri ) . '","' . $method . '",arguments);}') ;
{
if (!$first) print(',');
print(
$method.
':function(){return __wrCall("'.
addslashes($this->_uri).
'","'.$method.'",arguments);}'
);
$first = false; $first = false;
} }
} }
@@ -116,16 +111,21 @@ class WebResource
if (! function_exists( 'json_encode' )) { if (! function_exists( 'json_encode' )) {
G::LoadThirdParty( 'pear/json', 'class.json' ); G::LoadThirdParty( 'pear/json', 'class.json' );
function json_encode(&$value) {
$json= new Services_JSON; function json_encode (&$value)
{
$json = new Services_JSON();
return $json->encode( $value ); return $json->encode( $value );
} }
} }
if (! function_exists( 'json_decode' )) { if (! function_exists( 'json_decode' )) {
G::LoadThirdParty( 'pear/json', 'class.json' ); G::LoadThirdParty( 'pear/json', 'class.json' );
function json_decode(&$value) {
$json= new Services_JSON; function json_decode (&$value)
{
$json = new Services_JSON();
return $json->decode( $value ); return $json->decode( $value );
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.xmlDocument.php * class.xmlDocument.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -25,6 +27,7 @@
*/ */
/** /**
* Class Xml_Node * Class Xml_Node
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system * @package gulliver.system
* @access public * @access public
@@ -36,8 +39,10 @@ class Xml_Node
var $value = ''; //maybe not necesary var $value = ''; //maybe not necesary
var $attributes = array (); var $attributes = array ();
var $children = array (); var $children = array ();
/** /**
* Function Xml_Node * Function Xml_Node
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string name * @param eter string name
@@ -53,8 +58,10 @@ class Xml_Node
$this->value = $value; $this->value = $value;
$this->attributes = $attributes; $this->attributes = $attributes;
} }
/** /**
* Function addAttribute * Function addAttribute
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string name * @param eter string name
@@ -66,8 +73,10 @@ class Xml_Node
$this->attributes[$name] = $value; $this->attributes[$name] = $value;
return true; return true;
} }
/** /**
* Function addChildNode * Function addChildNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string childNode * @param eter string childNode
@@ -80,13 +89,14 @@ class Xml_Node
$childNode->parent = &$this; $childNode->parent = &$this;
$this->children[] = &$childNode; $this->children[] = &$childNode;
return true; return true;
} } else {
else {
return false; return false;
} }
} }
/** /**
* Function toTree * Function toTree
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -101,9 +111,13 @@ class Xml_Node
} }
return $arr; return $arr;
} }
function toArray( $obj = NULL ) {
function toArray ($obj = null)
{
$arr = array (); $arr = array ();
if ( !isset($obj) ) $obj = $this->toTree(); if (! isset( $obj )) {
$obj = $this->toTree();
}
foreach ($obj as $att => $val) { foreach ($obj as $att => $val) {
if (is_array( $val ) || is_object( $val )) { if (is_array( $val ) || is_object( $val )) {
$arr[$att] = Xml_Node::toArray( $val ); $arr[$att] = Xml_Node::toArray( $val );
@@ -113,8 +127,10 @@ class Xml_Node
} }
return $arr; return $arr;
} }
/** /**
* Function &findNode * Function &findNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string xpath * @param eter string xpath
@@ -122,29 +138,31 @@ class Xml_Node
*/ */
function &findNode ($xpath) function &findNode ($xpath)
{ {
$n = NULL; $n = null;
$p = explode( '/', $xpath ); $p = explode( '/', $xpath );
if ($p[0] === '') { if ($p[0] === '') {
return $this; return $this;
} } elseif (substr( $p[0], 0, 1 ) === '@') {
elseif ( substr($p[0],0 , 1) === '@') {
$p[0] = substr( $p[0], 1 ); $p[0] = substr( $p[0], 1 );
if ( isset($this->attributes[$p[0]])) return $this->attributes[$p[0]]; if (isset( $this->attributes[$p[0]] )) {
return $this->attributes[$p[0]];
} }
elseif ($p[0] === '..' ) { } elseif ($p[0] === '..') {
array_shift( $p ); array_shift( $p );
$n = & $this->parent->findNode( implode( '/', $p ) ); $n = & $this->parent->findNode( implode( '/', $p ) );
if (isset($n) ) return $n; if (isset( $n )) {
return $n;
} }
else { } else {
foreach ($this->children as $k => $v) { foreach ($this->children as $k => $v) {
if (($v->type !== 'cdata') && ($v->name === $p[0])) { if (($v->type !== 'cdata') && ($v->name === $p[0])) {
if (sizeof( $p ) > 1) { if (sizeof( $p ) > 1) {
array_shift( $p ); array_shift( $p );
$n = & $this->children[$k]->findNode( implode( '/', $p ) ); $n = & $this->children[$k]->findNode( implode( '/', $p ) );
if (isset($n)) return $n; if (isset( $n )) {
return $n;
} }
else { } else {
return $this->children[$k]; return $this->children[$k];
} }
} }
@@ -152,9 +170,11 @@ class Xml_Node
} }
return $n; return $n;
} }
/** /**
* Function getXML * Function getXML
* Returns a string of the node in XML notation. * Returns a string of the node in XML notation.
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string xpath * @param eter string xpath
@@ -162,8 +182,7 @@ class Xml_Node
*/ */
function getXML () function getXML ()
{ {
switch($this->type) switch ($this->type) {
{
case 'open': case 'open':
$xml = '<' . $this->name; $xml = '<' . $this->name;
foreach ($this->attributes as $attib => $value) { foreach ($this->attributes as $attib => $value) {
@@ -186,21 +205,18 @@ class Xml_Node
} }
} }
$xml .= '>' . $this->getCDATAValue(); $xml .= '>' . $this->getCDATAValue();
foreach( $this->children as $child ) foreach ($this->children as $child) {
$xml .= $child->getXML(); $xml .= $child->getXML();
}
$xml .= '</' . $this->name . '>'; $xml .= '</' . $this->name . '>';
break; break;
case 'close': case 'close':
$xml = '</' . $this->name . '>'; $xml = '</' . $this->name . '>';
break; break;
case 'cdata': case 'cdata':
$xml = $this->getCDATAValue(); $xml = $this->getCDATAValue();
break; break;
case 'complete': case 'complete':
$xml = '<' . $this->name; $xml = '<' . $this->name;
foreach ($this->attributes as $attib => $value) { foreach ($this->attributes as $attib => $value) {
$xml .= ' ' . $attib . '="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"'; $xml .= ' ' . $attib . '="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"';
@@ -220,17 +236,21 @@ class Xml_Node
} }
return $xml; return $xml;
} }
function getCDATAValue () function getCDATAValue ()
{ {
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' ); $cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
if ($this->value === $cdata) if ($this->value === $cdata) {
return $this->value; return $this->value;
else } else {
return '<![CDATA[' . $this->value . ']]>'; return '<![CDATA[' . $this->value . ']]>';
} }
} }
}
/** /**
* Class Xml_document * Class Xml_document
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system * @package gulliver.system
* @access public * @access public
@@ -238,8 +258,10 @@ class Xml_Node
class Xml_document extends Xml_Node class Xml_document extends Xml_Node
{ {
var $currentNode; var $currentNode;
/** /**
* Function Xml_document * Function Xml_document
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @return string * @return string
@@ -248,8 +270,10 @@ class Xml_document extends Xml_Node
{ {
$this->currentNode = &$this; $this->currentNode = &$this;
} }
/** /**
* Function parseXmlFile * Function parseXmlFile
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string filename * @param eter string filename
@@ -267,7 +291,6 @@ class Xml_document extends Xml_Node
$data = $content; $data = $content;
} }
$parser = xml_parser_create( 'utf-8' ); $parser = xml_parser_create( 'utf-8' );
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 ); xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 );
@@ -282,37 +305,29 @@ class Xml_document extends Xml_Node
$this->type = 'open'; $this->type = 'open';
$this->currentNode = &$this; $this->currentNode = &$this;
$m = &$this; $m = &$this;
foreach($values as $k => $v) foreach ($values as $k => $v) {
{ switch ($v['type']) {
switch ($v['type'])
{
case 'open': case 'open':
$this->currentNode->addChildNode ( new Xml_Node ($v['tag'], $this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
$v['type'], isset($v['value'])?$v['value'] : '',
isset($v['attributes']) ? $v['attributes']:array()));
$this->currentNode = &$this->findNode( $v['tag'] ); $this->currentNode = &$this->findNode( $v['tag'] );
break; break;
case 'close': case 'close':
$this->currentNode = & $this->findNode( '..' ); $this->currentNode = & $this->findNode( '..' );
break; break;
case 'cdata': case 'cdata':
$this->currentNode->addChildNode(new Xml_Node('', $this->currentNode->addChildNode( new Xml_Node( '', $v['type'], isset( $v['value'] ) ? $v['value'] : '' ) );
$v['type'], isset($v['value'])?$v['value']:''));
break; break;
case 'complete': case 'complete':
$this->currentNode->addChildNode( new Xml_Node($v['tag'], $this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
$v['type'], isset($v['value'])?$v['value']:'',
isset($v['attributes'])?$v['attributes']:array()));
break; break;
} }
} }
return true; return true;
} }
/** /**
* Function &findNode * Function &findNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com> * @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public * @access public
* @param eter string xpath * @param eter string xpath
@@ -322,20 +337,20 @@ class Xml_document extends Xml_Node
{ {
if (substr( $xpath, 0, 1 ) == '/') { if (substr( $xpath, 0, 1 ) == '/') {
return parent::findNode( substr( $xpath, 1 ) ); return parent::findNode( substr( $xpath, 1 ) );
} } else {
else {
if (isset( $this->currentNode )) { if (isset( $this->currentNode )) {
if ( $this->currentNode->name === $this->name) if ($this->currentNode->name === $this->name) {
return parent::findNode( $xpath ); return parent::findNode( $xpath );
else } else {
return $this->currentNode->findNode( $xpath ); return $this->currentNode->findNode( $xpath );
} }
else { } else {
return $null; return $null;
} }
} }
} //function findNode } //function findNode
/** /**
* Function getXML * Function getXML
* *
@@ -348,6 +363,7 @@ class Xml_document extends Xml_Node
$xml .= $this->children[0]->getXML(); $xml .= $this->children[0]->getXML();
return $xml; return $xml;
} }
/** /**
* Function save * Function save
* *
@@ -359,6 +375,7 @@ class Xml_document extends Xml_Node
$xml = $this->getXML(); $xml = $this->getXML();
$fp = fopen( $filename, 'w' ); $fp = fopen( $filename, 'w' );
fwrite( $fp, $xml ); fwrite( $fp, $xml );
fclose( $fp );/**/ fclose( $fp );
} }
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* class.xmlformExtension.php * class.xmlformExtension.php
*
* @package gulliver.system * @package gulliver.system
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -25,6 +27,7 @@
*/ */
/** /**
*
* @package gulliver.system * @package gulliver.system
*/ */
@@ -38,6 +41,7 @@ class XmlForm_Field_Label extends XmlForm_Field
* Special class for pagedTable * Special class for pagedTable
* condition: PHP expression whose result defines whether to "mark" * condition: PHP expression whose result defines whether to "mark"
* the following columns (that is if true) * the following columns (that is if true)
*
* @package gulliver.system * @package gulliver.system
*/ */
class XmlForm_Field_cellMark extends XmlForm_Field class XmlForm_Field_cellMark extends XmlForm_Field
@@ -65,8 +69,7 @@ class XmlForm_Field_cellMark extends XmlForm_Field
$value = G::replaceDataField( $this->condition, $owner->values ); $value = G::replaceDataField( $this->condition, $owner->values );
$value = @eval( 'return (' . $value . ');' ); $value = @eval( 'return (' . $value . ');' );
$row = $values['row__']; $row = $values['row__'];
$style=((($row % 2)==0) && ($this->styleAlt!=0)) ? $style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style;
$this->styleAlt : $this->style;
return ($value) ? $style : ''; return ($value) ? $style : '';
} }
@@ -83,17 +86,16 @@ class XmlForm_Field_cellMark extends XmlForm_Field
$value = G::replaceDataField( $this->condition, $owner->values ); $value = G::replaceDataField( $this->condition, $owner->values );
$value = @eval( 'return (' . $value . ');' ); $value = @eval( 'return (' . $value . ');' );
$row = $values['row__']; $row = $values['row__'];
$style=(($row % 2)==0) ? $style = (($row % 2) == 0) ? $this->classNameAlt : $this->className;
$this->classNameAlt : $this->className;
return ($value) ? $style : ''; return ($value) ? $style : '';
} }
} }
/** /**
* XmlForm_Field_DVEditor * XmlForm_Field_DVEditor
* *
* extends XmlForm_Field * extends XmlForm_Field
*
* @package gulliver.system * @package gulliver.system
* *
*/ */
@@ -111,7 +113,7 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
* *
* @return string '<div> ... </div>' * @return string '<div> ... </div>'
*/ */
function render( $value, $owner = NULL ) function render ($value, $owner = null)
{ {
return '<div style="width:' . htmlentities( $this->width, ENT_QUOTES, 'utf-8' ) . ';height:' . htmlentities( $this->height, ENT_QUOTES, 'utf-8' ) . '"><input id="form[' . $this->name . ']" name="form[' . $this->name . ']" type="hidden" value="' . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . '"/></div>'; return '<div style="width:' . htmlentities( $this->width, ENT_QUOTES, 'utf-8' ) . ';height:' . htmlentities( $this->height, ENT_QUOTES, 'utf-8' ) . '"><input id="form[' . $this->name . ']" name="form[' . $this->name . ']" type="hidden" value="' . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . '"/></div>';
} }
@@ -146,6 +148,7 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
* <PAGED_TABLE_FAST_SEARCH type="text" colAlign="right" colWidth="180" onkeypress="if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;"> * <PAGED_TABLE_FAST_SEARCH type="text" colAlign="right" colWidth="180" onkeypress="if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;">
* <en>Search</en> * <en>Search</en>
* </PAGED_TABLE_FAST_SEARCH> * </PAGED_TABLE_FAST_SEARCH>
*
* @package gulliver.system * @package gulliver.system
*/ */
class XmlForm_Field_FastSearch extends XmlForm_Field_Text class XmlForm_Field_FastSearch extends XmlForm_Field_Text
@@ -155,3 +158,4 @@ class XmlForm_Field_FastSearch extends XmlForm_Field_Text
var $colWidth = "180"; var $colWidth = "180";
var $label = "@G::LoadTranslation(ID_SEARCH)"; var $label = "@G::LoadTranslation(ID_SEARCH)";
} }