CODE STYLE Format

Change format
This commit is contained in:
norahmollo
2012-10-19 21:30:26 +00:00
parent 9e9f4be8e6
commit e21cbdbaa6
10 changed files with 4295 additions and 4276 deletions

View File

@@ -1,83 +1,83 @@
<?php
G::LoadSystem( 'dbMaintenance' );
G::LoadClass( "cli" );
G::LoadSystem('dbMaintenance');
G::LoadClass("cli");
/** Class MultipleFilesBackup
* create a backup of this workspace
*
* Exports the database and copies the files to an tar archive o several if the max filesize is reached.
*
*/
class multipleFilesBackup{
/**
* Class MultipleFilesBackup
* create a backup of this workspace
*
* Exports the database and copies the files to an tar archive o several if the max filesize is reached.
*/
class multipleFilesBackup
{
private $dir_to_compress = "";
private $filename = "backUpProcessMaker.tar";
private $fileSize = "1000"; // 1 GB by default.
private $sizeDescriptor = "m"; //megabytes
private $tempDirectories = array();
private $fileSize = "1000";
// 1 GB by default.
private $sizeDescriptor = "m";
//megabytes
private $tempDirectories = array ();
/* Constructor
* @filename contains the path and filename of the comppress file(s).
* @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size.
*/
function multipleFilesBackup($filename,$size)
public function multipleFilesBackup ($filename, $size)
{
if(!empty($filename)){
if (! empty( $filename )) {
$this->filename = $filename;
}
if(!empty($size) && (int)$size > 0){
if (! empty( $size ) && (int) $size > 0) {
$this->fileSize = $size;
}
}
/* Gets workspace information enough to make its backup.
* @workspace contains the workspace to be add to the commpression process.
*/
public function addToBackup($workspace)
public function addToBackup ($workspace)
{
//verifing if workspace exists.
if (!$workspace->workspaceExists()) {
if (! $workspace->workspaceExists()) {
echo "Workspace {$workspace->name} not found\n";
return false;
}
//create destination path
if (!file_exists(PATH_DATA . "upgrade/")){
mkdir(PATH_DATA . "upgrade/");
if (! file_exists( PATH_DATA . "upgrade/" )) {
mkdir( PATH_DATA . "upgrade/" );
}
$tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
mkdir($tempDirectory);
$tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
mkdir( $tempDirectory );
$metadata = $workspace->getMetadata();
CLI::logging("Temporing up database...\n");
$metadata["databases"] = $workspace->exportDatabase($tempDirectory);
$metadata["directories"] = array("{$workspace->name}.files");
CLI::logging( "Temporing up database...\n" );
$metadata["databases"] = $workspace->exportDatabase( $tempDirectory );
$metadata["directories"] = array ("{$workspace->name}.files");
$metadata["version"] = 1;
$metaFilename = "$tempDirectory/{$workspace->name}.meta";
if (!file_put_contents($metaFilename,
str_replace(array(",", "{", "}"), array(",\n ", "{\n ", "\n}\n"),
G::json_encode($metadata)))) {
CLI::logging("Could not create backup metadata");
if (! file_put_contents( $metaFilename, str_replace( array (",","{","}"), array (",\n ","{\n ","\n}\n"), G::json_encode( $metadata ) ) )) {
CLI::logging( "Could not create backup metadata" );
}
CLI::logging("Adding database to backup...\n");
$this->addDirToBackup($tempDirectory);
CLI::logging("Adding files to backup...\n");
$this->addDirToBackup($workspace->path);
CLI::logging( "Adding database to backup...\n" );
$this->addDirToBackup( $tempDirectory );
CLI::logging( "Adding files to backup...\n" );
$this->addDirToBackup( $workspace->path );
$this->tempDirectories[] = $tempDirectory;
}
/* Add a directory containing Db files or info files to be commpressed
* @directory the name and path of the directory to be add to the commpression process.
*/
private function addDirToBackup($directory)
private function addDirToBackup ($directory)
{
if(!empty($directory)){
if (! empty( $directory )) {
$this->dir_to_compress .= $directory . " ";
}
}
/* Commpress the DB and files into a single or several files with numerical series extentions
*/
public function letsBackup()
// Commpress the DB and files into a single or several files with numerical series extentions
public function letsBackup ()
{
// creating command
$CommpressCommand = "tar czv ";
@@ -87,12 +87,11 @@ class multipleFilesBackup{
$CommpressCommand .= "m -d - ";
$CommpressCommand .= $this->filename . ".";
//executing command to create the files
echo exec($CommpressCommand);
echo exec( $CommpressCommand );
//Remove leftovers dirs.
foreach($this->tempDirectories as $tempDirectory)
{
CLI::logging("Deleting: ".$tempDirectory."\n");
G::rm_dir($tempDirectory);
foreach ($this->tempDirectories as $tempDirectory) {
CLI::logging( "Deleting: " . $tempDirectory . "\n" );
G::rm_dir( $tempDirectory );
}
}
/* Restore from file(s) commpressed by letsBackup function, into a temporary directory
@@ -101,127 +100,119 @@ class multipleFilesBackup{
* @ dstWorkspace contains the workspace to be overwriting.
* @ overwrite got the option true if the workspace will be overwrite.
*/
static public function letsRestore($filename, $srcWorkspace, $dstWorkspace = NULL, $overwrite = true)
static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
{
// Needed info:
// TEMPDIR /shared/workflow_data/upgrade/
// BACKUPS /shared/workflow_data/backups/
// Creating command cat myfiles_split.tgz_* | tar xz
$DecommpressCommand = "cat " . $filename . ".* ";
$DecommpressCommand .= " | tar xzv";
$tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
$tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
$parentDirectory = PATH_DATA . "upgrade";
if (is_writable($parentDirectory)) {
mkdir($tempDirectory);
if (is_writable( $parentDirectory )) {
mkdir( $tempDirectory );
} else {
throw new Exception("Could not create directory:" . $parentDirectory);
throw new Exception( "Could not create directory:" . $parentDirectory );
}
//Extract all backup files, including database scripts and workspace files
CLI::logging("Restoring into ".$tempDirectory."\n");
chdir($tempDirectory);
echo exec($DecommpressCommand);
CLI::logging("\nUncompressed into: ".$tempDirectory."\n");
CLI::logging( "Restoring into " . $tempDirectory . "\n" );
chdir( $tempDirectory );
echo exec( $DecommpressCommand );
CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" );
//Search for metafiles in the new standard (the old standard would contain meta files.
$metaFiles = glob($tempDirectory . "/*.meta");
if (empty($metaFiles)) {
$metaFiles = glob($tempDirectory . "/*.txt");
if (!empty($metaFiles)){
return workspaceTools::restoreLegacy($tempDirectory);
$metaFiles = glob( $tempDirectory . "/*.meta" );
if (empty( $metaFiles )) {
$metaFiles = glob( $tempDirectory . "/*.txt" );
if (! empty( $metaFiles )) {
return workspaceTools::restoreLegacy( $tempDirectory );
} else {
throw new Exception( "No metadata found in backup" );
}
else{
throw new Exception("No metadata found in backup");
} else {
CLI::logging( "Found " . count( $metaFiles ) . " workspaces in backup:\n" );
foreach ($metaFiles as $metafile) {
CLI::logging( "-> " . basename( $metafile ) . "\n" );
}
}
else {
CLI::logging("Found " . count($metaFiles) . " workspaces in backup:\n");
foreach ($metaFiles as $metafile){
CLI::logging("-> " . basename($metafile) . "\n");
if (count( $metaFiles ) > 1 && (! isset( $srcWorkspace ))) {
throw new Exception( "Multiple workspaces in backup but no workspace specified to restore" );
}
}
if (count($metaFiles) > 1 && (!isset($srcWorkspace))){
throw new Exception("Multiple workspaces in backup but no workspace specified to restore");
}
if (isset($srcWorkspace) && !in_array("$srcWorkspace.meta", array_map(basename, $metaFiles))){
throw new Exception("Workspace $srcWorkspace not found in backup");
if (isset( $srcWorkspace ) && ! in_array( "$srcWorkspace.meta", array_map( basename, $metaFiles ) )) {
throw new Exception( "Workspace $srcWorkspace not found in backup" );
}
foreach ($metaFiles as $metaFile) {
$metadata = G::json_decode(file_get_contents($metaFile));
if ($metadata->version != 1){
throw new Exception("Backup version {$metadata->version} not supported");
$metadata = G::json_decode( file_get_contents( $metaFile ) );
if ($metadata->version != 1) {
throw new Exception( "Backup version {$metadata->version} not supported" );
}
$backupWorkspace = $metadata->WORKSPACE_NAME;
if (isset($dstWorkspace)) {
if (isset( $dstWorkspace )) {
$workspaceName = $dstWorkspace;
$createWorkspace = true;
}
else {
} else {
$workspaceName = $metadata->WORKSPACE_NAME;
$createWorkspace = false;
}
if (isset($srcWorkspace) && strcmp($metadata->WORKSPACE_NAME, $srcWorkspace) != 0) {
CLI::logging(CLI::warning("> Workspace $backupWorkspace found, but not restoring.") . "\n");
if (isset( $srcWorkspace ) && strcmp( $metadata->WORKSPACE_NAME, $srcWorkspace ) != 0) {
CLI::logging( CLI::warning( "> Workspace $backupWorkspace found, but not restoring." ) . "\n" );
continue;
} else {
CLI::logging( "> Restoring " . CLI::info( $backupWorkspace ) . " to " . CLI::info( $workspaceName ) . "\n" );
}
else {
CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");
}
$workspace = new workspaceTools($workspaceName);
if ($workspace->workspaceExists()){
if ($overwrite){
CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");
}
else{
throw new Exception("Destination workspace already exist (use -o to overwrite)");
$workspace = new workspaceTools( $workspaceName );
if ($workspace->workspaceExists()) {
if ($overwrite) {
CLI::logging( CLI::warning( "> Workspace $workspaceName already exist, overwriting!" ) . "\n" );
} else {
throw new Exception( "Destination workspace already exist (use -o to overwrite)" );
}
}
if (file_exists($workspace->path)) {
G::rm_dir($workspace->path);
if (file_exists( $workspace->path )) {
G::rm_dir( $workspace->path );
}
foreach ($metadata->directories as $dir) {
CLI::logging("+> Restoring directory '$dir'\n");
if (!rename("$tempDirectory/$dir", $workspace->path)) {
throw new Exception("There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}.");
CLI::logging( "+> Restoring directory '$dir'\n" );
if (! rename( "$tempDirectory/$dir", $workspace->path )) {
throw new Exception( "There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}." );
}
}
CLI::logging("> Changing file permissions\n");
$shared_stat = stat(PATH_DATA);
if ($shared_stat !== false){
workspaceTools::dirPerms($workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']);
}
else{
CLI::logging(CLI::error ("Could not get the shared folder permissions, not changing workspace permissions") . "\n");
CLI::logging( "> Changing file permissions\n" );
$shared_stat = stat( PATH_DATA );
if ($shared_stat !== false) {
workspaceTools::dirPerms( $workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode'] );
} else {
CLI::logging( CLI::error( "Could not get the shared folder permissions, not changing workspace permissions" ) . "\n" );
}
list($dbHost, $dbUser, $dbPass) = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
list ($dbHost, $dbUser, $dbPass) = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) );
CLI::logging("> Connecting to system database in '$dbHost'\n");
$link = mysql_connect($dbHost, $dbUser, $dbPass);
@mysql_query("SET NAMES 'utf8';");
if (!$link){
throw new Exception('Could not connect to system database: ' . mysql_error());
CLI::logging( "> Connecting to system database in '$dbHost'\n" );
$link = mysql_connect( $dbHost, $dbUser, $dbPass );
@mysql_query( "SET NAMES 'utf8';" );
if (! $link) {
throw new Exception( 'Could not connect to system database: ' . mysql_error() );
}
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
$newDBNames = $workspace->resetDBInfo( $dbHost, $createWorkspace );
foreach ($metadata->databases as $db) {
$dbName = $newDBNames[$db->name];
CLI::logging("+> Restoring database {$db->name} to $dbName\n");
$workspace->executeSQLScript($dbName, "$tempDirectory/{$db->name}.sql");
$workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
$workspace->createDBUser($dbName, $db->pass, "%", $dbName);
CLI::logging( "+> Restoring database {$db->name} to $dbName\n" );
$workspace->executeSQLScript( $dbName, "$tempDirectory/{$db->name}.sql" );
$workspace->createDBUser( $dbName, $db->pass, "localhost", $dbName );
$workspace->createDBUser( $dbName, $db->pass, "%", $dbName );
}
$workspace->upgradeCacheView(false);
mysql_close($link);
$workspace->upgradeCacheView( false );
mysql_close( $link );
}
CLI::logging("Removing temporary files\n");
G::rm_dir($tempDirectory);
CLI::logging(CLI::info("Done restoring") . "\n");
CLI::logging( "Removing temporary files\n" );
G::rm_dir( $tempDirectory );
CLI::logging( CLI::info( "Done restoring" ) . "\n" );
}
}
?>

View File

@@ -32,18 +32,18 @@
class pluginDetail
{
var $sNamespace;
var $sClassName;
var $sFriendlyName = null;
var $sDescription = null;
var $sSetupPage = null;
var $sFilename;
var $sPluginFolder = '';
var $sCompanyLogo = '';
var $iVersion = 0;
var $enabled = false;
var $aWorkspaces = null;
var $bPrivate = false;
public $sNamespace;
public $sClassName;
public $sFriendlyName = null;
public $sDescription = null;
public $sSetupPage = null;
public $sFilename;
public $sPluginFolder = '';
public $sCompanyLogo = '';
public $iVersion = 0;
public $enabled = false;
public $aWorkspaces = null;
public $bPrivate = false;
/**
* This function is the constructor of the pluginDetail class
@@ -58,7 +58,7 @@ class pluginDetail
* @param integer $iVersion
* @return void
*/
function __construct ($sNamespace, $sClassName, $sFilename, $sFriendlyName = '', $sPluginFolder = '', $sDescription = '', $sSetupPage = '', $iVersion = 0)
public function __construct ($sNamespace, $sClassName, $sFilename, $sFriendlyName = '', $sPluginFolder = '', $sDescription = '', $sSetupPage = '', $iVersion = 0)
{
$this->sNamespace = $sNamespace;
$this->sClassName = $sClassName;
@@ -67,11 +67,12 @@ class pluginDetail
$this->sSetupPage = $sSetupPage;
$this->iVersion = $iVersion;
$this->sFilename = $sFilename;
if ($sPluginFolder == '')
if ($sPluginFolder == '') {
$this->sPluginFolder = $sNamespace;
else
} else {
$this->sPluginFolder = $sPluginFolder;
}
}
}
/**
@@ -107,7 +108,7 @@ class PMPluginRegistry
*/
private $_restServices = array ();
private static $instance = NULL;
private static $instance = null;
/**
* This function is the constructor of the PMPluginRegistry class
@@ -127,7 +128,7 @@ class PMPluginRegistry
*/
function &getSingleton ()
{
if (self::$instance == NULL) {
if (self::$instance == null) {
self::$instance = new PMPluginRegistry();
}
return self::$instance;
@@ -139,7 +140,7 @@ class PMPluginRegistry
*
* @return void
*/
function serializeInstance ()
public function serializeInstance ()
{
return serialize( self::$instance );
}
@@ -150,9 +151,9 @@ class PMPluginRegistry
* @param string $serialized
* @return void
*/
function unSerializeInstance ($serialized)
public function unSerializeInstance ($serialized)
{
if (self::$instance == NULL) {
if (self::$instance == null) {
self::$instance = new PMPluginRegistry();
}
@@ -163,7 +164,7 @@ class PMPluginRegistry
/**
* Save the current instance to the plugin singleton
*/
function save ()
public function save ()
{
file_put_contents( PATH_DATA_SITE . 'plugin.singleton', $this->serializeInstance() );
}
@@ -175,35 +176,27 @@ class PMPluginRegistry
* @param unknown_type $sNamespace
* @param unknown_type $sFilename
*/
public function registerPlugin($sNamespace, $sFilename=null)
public function registerPlugin ($sNamespace, $sFilename = null)
{
//require_once ($sFilename);
$sClassName = $sNamespace . "plugin";
$plugin = new $sClassName($sNamespace, $sFilename);
if (isset($this->_aPluginDetails[$sNamespace])) {
$sClassName = $sNamespace . "plugin";
$plugin = new $sClassName( $sNamespace, $sFilename );
if (isset( $this->_aPluginDetails[$sNamespace] )) {
$this->_aPluginDetails[$sNamespace]->iVersion = $plugin->iVersion;
return;
}
$detail = new pluginDetail(
$sNamespace,
$sClassName,
$sFilename,
$plugin->sFriendlyName,
$plugin->sPluginFolder,
$plugin->sDescription,
$plugin->sSetupPage,
$plugin->iVersion
);
$detail = new pluginDetail( $sNamespace, $sClassName, $sFilename, $plugin->sFriendlyName, $plugin->sPluginFolder, $plugin->sDescription, $plugin->sSetupPage, $plugin->iVersion );
if (isset($plugin->aWorkspaces)) {
if (isset( $plugin->aWorkspaces )) {
$detail->aWorkspaces = $plugin->aWorkspaces;
}
if (isset($plugin->bPrivate)) {
if (isset( $plugin->bPrivate )) {
$detail->bPrivate = $plugin->bPrivate;
}
@@ -211,6 +204,7 @@ class PMPluginRegistry
// $detail->enabled = $this->_aPluginDetails[$sNamespace]->enabled;
//}
$this->_aPluginDetails[$sNamespace] = $detail;
}
@@ -219,13 +213,14 @@ class PMPluginRegistry
*
* @param unknown_type $sFilename
*/
function getPluginDetails ($sFilename)
public function getPluginDetails ($sFilename)
{
foreach ($this->_aPluginDetails as $key => $row) {
if ($sFilename == baseName( $row->sFilename ))
if ($sFilename == baseName( $row->sFilename )) {
return $row;
}
return NULL;
}
return null;
}
/**
@@ -233,11 +228,12 @@ class PMPluginRegistry
*
* @param unknown_type $sNamespace
*/
function enablePlugin ($sNamespace)
public function enablePlugin ($sNamespace)
{
foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($sNamespace == $namespace) {
$this->registerFolder( $sNamespace, $sNamespace, $detail->sPluginFolder ); //register the default directory, later we can have more
$this->registerFolder( $sNamespace, $sNamespace, $detail->sPluginFolder );
//register the default directory, later we can have more
$this->_aPluginDetails[$sNamespace]->enabled = true;
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
$this->_aPlugins[$detail->sNamespace] = $oPlugin;
@@ -255,7 +251,7 @@ class PMPluginRegistry
*
* @param unknown_type $sNamespace
*/
function disablePlugin ($sNamespace, $eventPlugin = 1)
public function disablePlugin ($sNamespace, $eventPlugin = 1)
{
$sw = false;
@@ -280,58 +276,70 @@ class PMPluginRegistry
}
foreach ($this->_aMenus as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aMenus[$key] );
}
}
foreach ($this->_aFolders as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aFolders[$key] );
}
}
foreach ($this->_aTriggers as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aTriggers[$key] );
}
}
foreach ($this->_aDashlets as $key => $detail) {
if ($detail == $sNamespace) {
unset( $this->_aDashlets[$key] );
}
}
foreach ($this->_aReports as $key => $detail) {
if ($detail == $sNamespace)
if ($detail == $sNamespace) {
unset( $this->_aReports[$key] );
}
}
foreach ($this->_aPmFunctions as $key => $detail) {
if ($detail == $sNamespace)
if ($detail == $sNamespace) {
unset( $this->_aPmFunctions[$key] );
}
}
foreach ($this->_aRedirectLogin as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aRedirectLogin[$key] );
}
}
foreach ($this->_aSteps as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aSteps[$key] );
}
}
foreach ($this->_aToolbarFiles as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aToolbarFiles[$key] );
}
}
foreach ($this->_aCSSStyleSheets as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aCSSStyleSheets[$key] );
}
}
foreach ($this->_aCaseSchedulerPlugin as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aCaseSchedulerPlugin[$key] );
}
}
foreach ($this->_aTaskExtendedProperties as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aTaskExtendedProperties[$key] );
}
}
foreach ($this->_aDashboardPages as $key => $detail) {
if ($detail->sNamespace == $sNamespace)
if ($detail->sNamespace == $sNamespace) {
unset( $this->_aDashboardPages[$key] );
}
}
//unregistering javascripts from this plugin
$this->unregisterJavascripts( $sNamespace );
@@ -344,15 +352,17 @@ class PMPluginRegistry
*
* @param unknown_type $sNamespace
*/
function getStatusPlugin ($sNamespace)
public function getStatusPlugin ($sNamespace)
{
foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($sNamespace == $namespace)
if ($this->_aPluginDetails[$sNamespace]->enabled)
if ($sNamespace == $namespace) {
if ($this->_aPluginDetails[$sNamespace]->enabled) {
return 'enabled';
else
} else {
return 'disabled';
}
}
}
return 0;
}
@@ -363,13 +373,11 @@ class PMPluginRegistry
*
* @return bool true if enabled, false otherwise
*/
function installPluginArchive ($filename, $pluginName)
public function installPluginArchive ($filename, $pluginName)
{
G::LoadThirdParty( "pear/Archive", "Tar" );
$tar = new Archive_Tar( $filename );
$files = $tar->listContent();
$plugins = array ();
$namePlugin = array ();
foreach ($files as $f) {
@@ -408,8 +416,6 @@ class PMPluginRegistry
//$pluginIni = $tar->extractInString("$pluginName.ini");
//$pluginConfig = parse_ini_string($pluginIni);
/*
if (!empty($oClass->aDependences)) {
foreach ($oClass->aDependences as $aDependence) {
@@ -446,7 +452,7 @@ class PMPluginRegistry
$this->save();
}
function uninstallPlugin ($sNamespace)
public function uninstallPlugin ($sNamespace)
{
$pluginFile = $sNamespace . ".php";
@@ -472,7 +478,6 @@ class PMPluginRegistry
///////
$this->save();
///////
$pluginDir = PATH_PLUGINS . $detail->sPluginFolder;
@@ -485,16 +490,14 @@ class PMPluginRegistry
}
///////
$this->uninstallPluginWorkspaces( array ($sNamespace
) );
$this->uninstallPluginWorkspaces( array ($sNamespace) );
///////
break;
}
}
}
function uninstallPluginWorkspaces ($arrayPlugin)
public function uninstallPluginWorkspaces ($arrayPlugin)
{
G::LoadClass( "system" );
G::LoadClass( "wsTools" );
@@ -509,7 +512,6 @@ class PMPluginRegistry
//Here we are loading all plug-ins registered
//The singleton has a list of enabled plug-ins
$pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginRegistry->unSerializeInstance( file_get_contents( $wsPathDataSite . "plugin.singleton" ) );
@@ -533,7 +535,7 @@ class PMPluginRegistry
*
* @param unknown_type $sNamespace
*/
function installPlugin ($sNamespace)
public function installPlugin ($sNamespace)
{
try {
foreach ($this->_aPluginDetails as $namespace => $detail) {
@@ -561,13 +563,14 @@ class PMPluginRegistry
* @param unknown_type $sMenuId
* @param unknown_type $sFilename
*/
function registerMenu ($sNamespace, $sMenuId, $sFilename)
public function registerMenu ($sNamespace, $sMenuId, $sFilename)
{
$found = false;
foreach ($this->_aMenus as $row => $detail) {
if ($sMenuId == $detail->sMenuId && $sNamespace == $detail->sNamespace)
if ($sMenuId == $detail->sMenuId && $sNamespace == $detail->sNamespace) {
$found = true;
}
}
if (! $found) {
$menuDetail = new menuDetail( $sNamespace, $sMenuId, $sFilename );
$this->_aMenus[] = $menuDetail;
@@ -579,7 +582,7 @@ class PMPluginRegistry
*
* @param unknown_type $className
*/
function registerDashlets ($namespace)
public function registerDashlets ($namespace)
{
$found = false;
foreach ($this->_aDashlets as $row => $detail) {
@@ -598,7 +601,7 @@ class PMPluginRegistry
* @param unknown_type $sNamespace
* @param unknown_type $sPage
*/
function registerCss ($sNamespace, $sCssFile)
public function registerCss ($sNamespace, $sCssFile)
{
$found = false;
foreach ($this->_aCSSStyleSheets as $row => $detail) {
@@ -618,7 +621,7 @@ class PMPluginRegistry
*
* @return array
*/
function getRegisteredCss ()
public function getRegisteredCss ()
{
return $this->_aCSSStyleSheets;
}
@@ -630,7 +633,7 @@ class PMPluginRegistry
* @param string $coreJsFile
* @param array/string $pluginJsFile
*/
function registerJavascript ($sNamespace, $sCoreJsFile, $pluginJsFile)
public function registerJavascript ($sNamespace, $sCoreJsFile, $pluginJsFile)
{
foreach ($this->_aJavascripts as $i => $js) {
@@ -639,7 +642,7 @@ class PMPluginRegistry
if (! in_array( $pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile )) {
$this->_aJavascripts[$i]->pluginJsFile[] = $pluginJsFile;
}
} else if (is_array( $pluginJsFile )) {
} elseif (is_array( $pluginJsFile )) {
$this->_aJavascripts[$i]->pluginJsFile = array_unique( array_merge( $pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile ) );
} else {
throw new Exception( 'Invalid third param, $pluginJsFile should be a string or array - ' . gettype( $pluginJsFile ) . ' given.' );
@@ -655,7 +658,7 @@ class PMPluginRegistry
if (is_string( $pluginJsFile )) {
$js->pluginJsFile[] = $pluginJsFile;
} else if (is_array( $pluginJsFile )) {
} elseif (is_array( $pluginJsFile )) {
$js->pluginJsFile = array_merge( $js->pluginJsFile, $pluginJsFile );
} else {
throw new Exception( 'Invalid third param, $pluginJsFile should be a string or array - ' . gettype( $pluginJsFile ) . ' given.' );
@@ -669,7 +672,7 @@ class PMPluginRegistry
*
* @return array
*/
function getRegisteredJavascript ()
public function getRegisteredJavascript ()
{
return $this->_aJavascripts;
}
@@ -681,7 +684,7 @@ class PMPluginRegistry
* @param string $sNamespace
* @return array
*/
function getRegisteredJavascriptBy ($sCoreJsFile, $sNamespace = '')
public function getRegisteredJavascriptBy ($sCoreJsFile, $sNamespace = '')
{
$scripts = array ();
@@ -708,9 +711,10 @@ class PMPluginRegistry
* @param string $sCoreJsFile
* @return array
*/
function unregisterJavascripts ($sNamespace, $sCoreJsFile = '')
public function unregisterJavascripts ($sNamespace, $sCoreJsFile = '')
{
if ($sCoreJsFile == '') { // if $sCoreJsFile=='' unregister all js from this namespace
if ($sCoreJsFile == '') {
// if $sCoreJsFile=='' unregister all js from this namespace
foreach ($this->_aJavascripts as $i => $js) {
if ($sNamespace == $js->sNamespace) {
unset( $this->_aJavascripts[$i] );
@@ -736,13 +740,14 @@ class PMPluginRegistry
* @param unknown_type $sMenuId
* @param unknown_type $sFilename
*/
function registerReport ($sNamespace)
public function registerReport ($sNamespace)
{
$found = false;
foreach ($this->_aReports as $row => $detail) {
if ($sNamespace == $detail)
if ($sNamespace == $detail) {
$found = true;
}
}
if (! $found) {
$this->_aReports[] = $sNamespace;
}
@@ -755,13 +760,14 @@ class PMPluginRegistry
* @param unknown_type $sMenuId
* @param unknown_type $sFilename
*/
function registerPmFunction ($sNamespace)
public function registerPmFunction ($sNamespace)
{
$found = false;
foreach ($this->_aPmFunctions as $row => $detail) {
if ($sNamespace == $detail)
if ($sNamespace == $detail) {
$found = true;
}
}
if (! $found) {
$this->_aPmFunctions[] = $sNamespace;
}
@@ -774,13 +780,15 @@ class PMPluginRegistry
* @param unknown_type $sRole
* @param unknown_type $sPath
*/
function registerRedirectLogin ($sNamespace, $sRole, $sPathMethod)
public function registerRedirectLogin ($sNamespace, $sRole, $sPathMethod)
{
$found = false;
foreach ($this->_aRedirectLogin as $row => $detail) {
if (($sNamespace == $detail->sNamespace) && ($sRole == $detail->sRoleCode)) //Filters based on Workspace and Role Code
if (($sNamespace == $detail->sNamespace) && ($sRole == $detail->sRoleCode)) {
//Filters based on Workspace and Role Code
$found = true;
}
}
if (! $found) {
$this->_aRedirectLogin[] = new redirectDetail( $sNamespace, $sRole, $sPathMethod );
}
@@ -791,12 +799,14 @@ class PMPluginRegistry
*
* @param unknown_type $sFolderName
*/
function registerFolder ($sNamespace, $sFolderId, $sFolderName)
public function registerFolder ($sNamespace, $sFolderId, $sFolderName)
{
$found = false;
foreach ($this->_aFolders as $row => $detail)
if ($sFolderId == $detail->sFolderId && $sNamespace == $detail->sNamespace)
foreach ($this->_aFolders as $row => $detail) {
if ($sFolderId == $detail->sFolderId && $sNamespace == $detail->sNamespace) {
$found = true;
}
}
if (! $found) {
$this->_aFolders[] = new folderDetail( $sNamespace, $sFolderId, $sFolderName );
@@ -808,12 +818,14 @@ class PMPluginRegistry
*
* @param unknown_type $sFolderName
*/
function registerStep ($sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage = '')
public function registerStep ($sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage = '')
{
$found = false;
foreach ($this->_aSteps as $row => $detail)
if ($sStepId == $detail->sStepId && $sNamespace == $detail->sNamespace)
foreach ($this->_aSteps as $row => $detail) {
if ($sStepId == $detail->sStepId && $sNamespace == $detail->sNamespace) {
$found = true;
}
}
if (! $found) {
$this->_aSteps[] = new stepDetail( $sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage );
@@ -825,7 +837,7 @@ class PMPluginRegistry
*
* @param unknown_type $sFolderName
*/
function isRegisteredFolder ($sFolderName)
public function isRegisteredFolder ($sFolderName)
{
foreach ($this->_aFolders as $row => $folder) {
if ($sFolderName == $folder->sFolderName && is_dir( PATH_PLUGINS . $folder->sFolderName )) {
@@ -842,7 +854,7 @@ class PMPluginRegistry
*
* @param unknown_type $menuId
*/
function getMenus ($menuId)
public function getMenus ($menuId)
{
foreach ($this->_aMenus as $row => $detail) {
if ($menuId == $detail->sMenuId && file_exists( $detail->sFilename )) {
@@ -856,7 +868,7 @@ class PMPluginRegistry
*
* @return array
*/
function getDashlets ()
public function getDashlets ()
{
return $this->_aDashlets;
}
@@ -866,7 +878,7 @@ class PMPluginRegistry
*
* @return array
*/
function getReports ()
public function getReports ()
{
return $this->_aReports;
$report = array ();
@@ -881,7 +893,7 @@ class PMPluginRegistry
* This function returns all pmFunctions registered
* @ array
*/
function getPmFunctions ()
public function getPmFunctions ()
{
return $this->_aPmFunctions;
$pmf = array ();
@@ -897,7 +909,7 @@ class PMPluginRegistry
*
* @return string
*/
function getSteps ()
public function getSteps ()
{
return $this->_aSteps;
}
@@ -907,7 +919,7 @@ class PMPluginRegistry
*
* @return string
*/
function getRedirectLogins ()
public function getRedirectLogins ()
{
return $this->_aRedirectLogin;
}
@@ -918,11 +930,10 @@ class PMPluginRegistry
* @param unknown_type $menuId
* @return object
*/
function executeTriggers ($triggerId, $oData)
public function executeTriggers ($triggerId, $oData)
{
foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace
$found = false;
$classFile = '';
@@ -945,23 +956,23 @@ class PMPluginRegistry
return;
}
return $response;
} else
} else {
print "error in call method " . $detail->sTriggerName;
}
}
}
}
/**
* verify if exists triggers related to a triggerId
*
* @param unknown_type $triggerId
*/
function existsTrigger ($triggerId)
public function existsTrigger ($triggerId)
{
$found = false;
foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace
foreach ($this->_aFolders as $row => $folder) {
$fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php';
@@ -980,12 +991,11 @@ class PMPluginRegistry
* @param unknown_type $triggerId
* @return object
*/
function getTriggerInfo ($triggerId)
public function getTriggerInfo ($triggerId)
{
$found = null;
foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace
foreach ($this->_aFolders as $row => $folder) {
$fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php';
@@ -1005,13 +1015,14 @@ class PMPluginRegistry
* @param unknown_type $sMethodFunction
* @return void
*/
function registerTrigger ($sNamespace, $sTriggerId, $sTriggerName)
public function registerTrigger ($sNamespace, $sTriggerId, $sTriggerName)
{
$found = false;
foreach ($this->_aTriggers as $row => $detail) {
if ($sTriggerId == $detail->sTriggerId && $sNamespace == $detail->sNamespace)
if ($sTriggerId == $detail->sTriggerId && $sNamespace == $detail->sNamespace) {
$found = true;
}
}
if (! $found) {
$triggerDetail = new triggerDetail( $sNamespace, $sTriggerId, $sTriggerName );
$this->_aTriggers[] = $triggerDetail;
@@ -1024,7 +1035,7 @@ class PMPluginRegistry
* @param unknown_type $sNamespace
* @return void
*/
function &getPlugin ($sNamespace)
public function &getPlugin ($sNamespace)
{
if (array_key_exists( $sNamespace, $this->_aPlugins )) {
return $this->_aPlugins[$sNamespace];
@@ -1052,14 +1063,15 @@ class PMPluginRegistry
* @param unknown_type $filename
* @return void
*/
function setCompanyLogo ($sNamespace, $filename)
public function setCompanyLogo ($sNamespace, $filename)
{
$found = false;
foreach ($this->_aPluginDetails as $row => $detail) {
if ($sNamespace == $detail->sNamespace)
if ($sNamespace == $detail->sNamespace) {
$this->_aPluginDetails[$sNamespace]->sCompanyLogo = $filename;
}
}
}
/**
* get company logo
@@ -1067,13 +1079,14 @@ class PMPluginRegistry
* @param unknown_type $default
* @return void
*/
function getCompanyLogo ($default)
public function getCompanyLogo ($default)
{
$sCompanyLogo = $default;
foreach ($this->_aPluginDetails as $row => $detail) {
if (trim( $detail->sCompanyLogo ) != '')
if (trim( $detail->sCompanyLogo ) != '') {
$sCompanyLogo = $detail->sCompanyLogo;
}
}
return $sCompanyLogo;
}
@@ -1083,7 +1096,7 @@ class PMPluginRegistry
* @param unknown_type $default
* @return void
*/
function setupPlugins ()
public function setupPlugins ()
{
try {
$iPlugins = 0;
@@ -1099,8 +1112,9 @@ class PMPluginRegistry
$aux = explode( chr( 92 ), $detail->sFilename );
}
$sFilename = PATH_PLUGINS . $aux[count( $aux ) - 1];
if (! file_exists( $sFilename ))
if (! file_exists( $sFilename )) {
continue;
}
require_once $sFilename;
if (class_exists( $detail->sClassName )) {
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
@@ -1132,7 +1146,7 @@ class PMPluginRegistry
* @param object $oData
* @return object
*/
function executeMethod ($sNamespace, $methodName, $oData)
public function executeMethod ($sNamespace, $methodName, $oData)
{
$response = null;
try {
@@ -1170,32 +1184,32 @@ class PMPluginRegistry
* @param string $sNamespace
* @return object
*/
function getFieldsForPageSetup ($sNamespace)
public function getFieldsForPageSetup ($sNamespace)
{
$oData = NULL;
$oData = null;
return $this->executeMethod( $sNamespace, 'getFieldsForPageSetup', $oData );
}
/**
* this function updates Fields For Page on Setup
*
* @param string $sNamespace
* @return void
*/
function updateFieldsForPageSetup ($sNamespace, $oData)
public function updateFieldsForPageSetup ($sNamespace, $oData)
{
if (! isset( $this->_aPluginDetails[$sNamespace] )) {
throw (new Exception( "The namespace '$sNamespace' doesn't exist in plugins folder." ));
}
;
return $this->executeMethod( $sNamespace, 'updateFieldsForPageSetup', $oData );
}
function eevalidate ()
public function eevalidate ()
{
$fileL = PATH_DATA_SITE . 'license.dat';
$fileS = PATH_DATA . 'license.dat';
if ((file_exists( $fileL )) || (file_exists( $fileS ))) { //Found a License
if ((file_exists( $fileL )) || (file_exists( $fileS ))) {
//Found a License
if (class_exists( 'pmLicenseManager' )) {
$sSerializedFile = PATH_DATA_SITE . 'lmn.singleton';
$pmLicenseManagerO = & pmLicenseManager::getSingleton();
@@ -1213,13 +1227,14 @@ class PMPluginRegistry
* @param unknown_type $sToolbarId
* @param unknown_type $sFilename
*/
function registerToolbarFile ($sNamespace, $sToolbarId, $sFilename)
public function registerToolbarFile ($sNamespace, $sToolbarId, $sFilename)
{
$found = false;
foreach ($this->_aToolbarFiles as $row => $detail) {
if ($sToolbarId == $detail->sToolbarId && $sNamespace == $detail->sNamespace)
if ($sToolbarId == $detail->sToolbarId && $sNamespace == $detail->sNamespace) {
$found = true;
}
}
if (! $found) {
$toolbarDetail = new toolbarDetail( $sNamespace, $sToolbarId, $sFilename );
$this->_aToolbarFiles[] = $toolbarDetail;
@@ -1231,7 +1246,7 @@ class PMPluginRegistry
*
* @param unknown_type $sToolbarId (NORMAL, GRID)
*/
function getToolbarOptions ($sToolbarId)
public function getToolbarOptions ($sToolbarId)
{
foreach ($this->_aToolbarFiles as $row => $detail) {
if ($sToolbarId == $detail->sToolbarId && file_exists( $detail->sFilename )) {
@@ -1243,12 +1258,13 @@ class PMPluginRegistry
/**
* Register a Case Scheduler Plugin
*/
function registerCaseSchedulerPlugin ($sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields)
public function registerCaseSchedulerPlugin ($sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields)
{
$found = false;
foreach ($this->_aCaseSchedulerPlugin as $row => $detail)
if ($sActionId == $detail->sActionId && $sNamespace == $detail->sNamespace)
if ($sActionId == $detail->sActionId && $sNamespace == $detail->sNamespace) {
$found = true;
}
if (! $found) {
$this->_aCaseSchedulerPlugin[] = new caseSchedulerPlugin( $sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields );
@@ -1260,7 +1276,7 @@ class PMPluginRegistry
*
* @return string
*/
function getCaseSchedulerPlugins ()
public function getCaseSchedulerPlugins ()
{
return $this->_aCaseSchedulerPlugin;
}
@@ -1272,7 +1288,7 @@ class PMPluginRegistry
* @param unknown_type $sPage
*/
function registerTaskExtendedProperty ($sNamespace, $sPage, $sName, $sIcon)
public function registerTaskExtendedProperty ($sNamespace, $sPage, $sName, $sIcon)
{
$found = false;
foreach ($this->_aTaskExtendedProperties as $row => $detail) {
@@ -1296,7 +1312,7 @@ class PMPluginRegistry
* @param unknown_type $sName
* @param unknown_type $sIcon
*/
function registerDashboardPage ($sNamespace, $sPage, $sName, $sIcon)
public function registerDashboardPage ($sNamespace, $sPage, $sName, $sIcon)
{
foreach ($this->_aDashboardPages as $row => $detail) {
if ($sPage == $detail->sPage && $sNamespace == $detail->sNamespace) {
@@ -1355,7 +1371,6 @@ class PMPluginRegistry
unset( $this->_restServices[$i] );
}
}
// Re-index when all js were unregistered
$this->_restServices = array_values( $this->_restServices );
}
@@ -1381,7 +1396,7 @@ class PMPluginRegistry
*
* @return array
*/
function getDashboardPages ()
public function getDashboardPages ()
{
return $this->_aDashboardPages;
}
@@ -1391,18 +1406,19 @@ class PMPluginRegistry
*
* @return array
*/
function getTaskExtendedProperties ()
public function getTaskExtendedProperties ()
{
return $this->_aTaskExtendedProperties;
}
function registerDashboard ()
public function registerDashboard ()
{
// Dummy function for backwards compatibility
}
function getAttributes ()
public function getAttributes ()
{
return get_object_vars( $this );
}
}

View File

@@ -13,58 +13,59 @@ require_once 'classes/model/om/BaseAppNotes.php';
*
* @package classes.model
*/
class AppNotes extends BaseAppNotes {
class AppNotes extends BaseAppNotes
{
function getNotesList($appUid, $usrUid='', $start='', $limit='')
public function getNotesList ($appUid, $usrUid = '', $start = '', $limit = '')
{
require_once ("classes/model/Users.php");
G::LoadClass('ArrayPeer');
G::LoadClass( 'ArrayPeer' );
$Criteria = new Criteria('workflow');
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn(AppNotesPeer::APP_UID);
$Criteria->addSelectColumn(AppNotesPeer::USR_UID);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_DATE);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS);
$Criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$Criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
$Criteria->addSelectColumn(UsersPeer::USR_EMAIL);
$Criteria->addSelectColumn( AppNotesPeer::APP_UID );
$Criteria->addSelectColumn( AppNotesPeer::USR_UID );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS );
$Criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_EMAIL );
$Criteria->addJoin(AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
$Criteria->add(appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL);
$Criteria->add( appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL );
if ($usrUid != '') {
$Criteria->add(appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL);
$Criteria->add( appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL );
}
$Criteria->addDescendingOrderByColumn(AppNotesPeer::NOTE_DATE);
$Criteria->addDescendingOrderByColumn( AppNotesPeer::NOTE_DATE );
$response = array();
$totalCount = AppNotesPeer::doCount($Criteria);
$response = array ();
$totalCount = AppNotesPeer::doCount( $Criteria );
$response['totalCount'] = $totalCount;
$response['notes'] = array();
$response['notes'] = array ();
if ($start != '') {
$Criteria->setLimit($limit);
$Criteria->setOffset($start);
$Criteria->setLimit( $limit );
$Criteria->setOffset( $start );
}
$oDataset = appNotesPeer::doSelectRS($Criteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset = appNotesPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aRow['NOTE_CONTENT'] = stripslashes($aRow['NOTE_CONTENT']);
$aRow['NOTE_CONTENT'] = stripslashes( $aRow['NOTE_CONTENT'] );
$response['notes'][] = $aRow;
$oDataset->next();
}
@@ -75,19 +76,18 @@ class AppNotes extends BaseAppNotes {
return $result;
}
function postNewNote($appUid, $usrUid, $noteContent, $notify=true, $noteAvalibility="PUBLIC", $noteRecipients="", $noteType="USER", $noteDate="now") {
$this->setAppUid($appUid);
$this->setUsrUid($usrUid);
$this->setNoteDate($noteDate);
$this->setNoteContent($noteContent);
$this->setNoteType($noteType);
$this->setNoteAvailability($noteAvalibility);
$this->setNoteOriginObj('');
$this->setNoteAffectedObj1('');
$this->setNoteAffectedObj2('');
$this->setNoteRecipients($noteRecipients);
public function postNewNote ($appUid, $usrUid, $noteContent, $notify = true, $noteAvalibility = "PUBLIC", $noteRecipients = "", $noteType = "USER", $noteDate = "now")
{
$this->setAppUid( $appUid );
$this->setUsrUid( $usrUid );
$this->setNoteDate( $noteDate );
$this->setNoteContent( $noteContent );
$this->setNoteType( $noteType );
$this->setNoteAvailability( $noteAvalibility );
$this->setNoteOriginObj( '' );
$this->setNoteAffectedObj1( '' );
$this->setNoteAffectedObj2( '' );
$this->setNoteRecipients( $noteRecipients );
if ($this->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
@@ -112,87 +112,87 @@ class AppNotes extends BaseAppNotes {
if ($notify) {
if ($noteRecipients == "") {
$noteRecipientsA = array();
G::LoadClass('case');
$oCase = new Cases ();
$p = $oCase->getUsersParticipatedInCase($appUid);
foreach($p['array'] as $key => $userParticipated){
$noteRecipientsA[]=$key;
$noteRecipientsA = array ();
G::LoadClass( 'case' );
$oCase = new Cases();
$p = $oCase->getUsersParticipatedInCase( $appUid );
foreach ($p['array'] as $key => $userParticipated) {
$noteRecipientsA[] = $key;
}
$noteRecipients = implode(",", $noteRecipientsA);
$noteRecipients = implode( ",", $noteRecipientsA );
}
$this->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
$this->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients );
}
return $response;
}
public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom="") {
public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
{
try {
require_once ('classes/model/Configuration.php');
$oConfiguration = new Configuration();
$sDelimiter = DBAdapter::getStringDelimiter();
$oCriteria = new Criteria('workflow');
$oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
$oCriteria->add(ConfigurationPeer::OBJ_UID, '');
$oCriteria->add(ConfigurationPeer::PRO_UID, '');
$oCriteria->add(ConfigurationPeer::USR_UID, '');
$oCriteria->add(ConfigurationPeer::APP_UID, '');
if (ConfigurationPeer::doCount($oCriteria) == 0) {
$oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
$aConfiguration = array();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' );
$oCriteria->add( ConfigurationPeer::OBJ_UID, '' );
$oCriteria->add( ConfigurationPeer::PRO_UID, '' );
$oCriteria->add( ConfigurationPeer::USR_UID, '' );
$oCriteria->add( ConfigurationPeer::APP_UID, '' );
if (ConfigurationPeer::doCount( $oCriteria ) == 0) {
$oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '') );
$aConfiguration = array ();
} else {
$aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
$aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' );
if ($aConfiguration['CFG_VALUE'] != '') {
$aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
$aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] );
$passwd = $aConfiguration['MESS_PASSWORD'];
$passwdDec = G::decrypt($passwd,'EMAILENCRYPT');
$auxPass = explode('hash:', $passwdDec);
if (count($auxPass) > 1) {
if (count($auxPass) == 2) {
$passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' );
$auxPass = explode( 'hash:', $passwdDec );
if (count( $auxPass ) > 1) {
if (count( $auxPass ) == 2) {
$passwd = $auxPass[1];
} else {
array_shift($auxPass);
$passwd = implode('', $auxPass);
array_shift( $auxPass );
$passwd = implode( '', $auxPass );
}
}
$aConfiguration['MESS_PASSWORD'] = $passwd;
} else {
$aConfiguration = array();
$aConfiguration = array ();
}
}
if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
if (! isset( $aConfiguration['MESS_ENABLED'] ) || $aConfiguration['MESS_ENABLED'] != '1') {
return false;
}
$oUser = new Users();
$aUser = $oUser->load($usrUid);
$aUser = $oUser->load( $usrUid );
$authorName = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
G::LoadClass('case');
$oCase = new Cases ();
G::LoadClass( 'case' );
$oCase = new Cases();
$aFields = $oCase->loadCase( $appUid );
$configNoteNotification['subject']= G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION')." @#APP_TITLE ";
$configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR').": $authorName<br /><br />$noteContent";
$configNoteNotification['subject'] = G::LoadTranslation( 'ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION' ) . " @#APP_TITLE ";
$configNoteNotification['body'] = G::LoadTranslation( 'ID_CASE' ) . ": @#APP_TITLE<br />" . G::LoadTranslation( 'ID_AUTHOR' ) . ": $authorName<br /><br />$noteContent";
if ($sFrom == '') {
$sFrom = '"ProcessMaker"';
}
$hasEmailFrom = preg_match('/(.+)@(.+)\.(.+)/', $sFrom, $match);
$hasEmailFrom = preg_match( '/(.+)@(.+)\.(.+)/', $sFrom, $match );
if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
if (! $hasEmailFrom || strpos( $sFrom, $aConfiguration['MESS_ACCOUNT'] ) === false) {
if (($aConfiguration['MESS_ENGINE'] != 'MAIL') && ($aConfiguration['MESS_ACCOUNT'] != '')) {
$sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
} else {
if (($aConfiguration['MESS_ENGINE'] == 'MAIL')) {
$sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
$sFrom .= ' <info@' . gethostbyaddr( '127.0.0.1' ) . '>';
} else {
if ($aConfiguration['MESS_SERVER'] != '') {
if (($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER']))) {
if (($sAux = @gethostbyaddr( $aConfiguration['MESS_SERVER'] ))) {
$sFrom .= ' <info@' . $sAux . '>';
} else {
$sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
@@ -204,15 +204,14 @@ class AppNotes extends BaseAppNotes {
}
}
$sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
$sSubject = G::replaceDataField( $configNoteNotification['subject'], $aFields );
//erik: new behaviour for messages
//G::loadClass('configuration');
//$oConf = new Configurations;
//$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
//$conf = $oConf->aConfig;
/*
/*
if( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE'])
&& $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') {
@@ -222,56 +221,31 @@ class AppNotes extends BaseAppNotes {
if ( ! file_exists ( $fileTemplate ) ) {
throw new Exception("Template file '$fileTemplate' does not exist.");
}
$sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
} else {*/
$sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
$sBody = nl2br( G::replaceDataField( $configNoteNotification['body'], $aFields ) );
/*}*/
G::LoadClass('spool');
G::LoadClass( 'spool' );
$oUser = new Users();
$recipientsArray = explode( ",", $noteRecipients );
$recipientsArray=explode(",",$noteRecipients);
foreach ($recipientsArray as $recipientUid) {
foreach($recipientsArray as $recipientUid){
$aUser = $oUser->load($recipientUid);
$aUser = $oUser->load( $recipientUid );
$sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
$oSpool = new spoolRun();
$oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],
'MESS_SERVER' => $aConfiguration['MESS_SERVER'],
'MESS_PORT' => $aConfiguration['MESS_PORT'],
'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],
'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],
'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,
'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''
));
$oSpool->create(array('msg_uid' => '',
'app_uid' => $appUid,
'del_index' => 1,
'app_msg_type' => 'DERIVATION',
'app_msg_subject' => $sSubject,
'app_msg_from' => $sFrom,
'app_msg_to' => $sTo,
'app_msg_body' => $sBody,
'app_msg_cc' => '',
'app_msg_bcc' => '',
'app_msg_attach' => '',
'app_msg_template' => '',
'app_msg_status' => 'pending'
));
$oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') );
$oSpool->create( array ('msg_uid' => '','app_uid' => $appUid,'del_index' => 1,'app_msg_type' => 'DERIVATION','app_msg_subject' => $sSubject,'app_msg_from' => $sFrom,'app_msg_to' => $sTo,'app_msg_body' => $sBody,'app_msg_cc' => '','app_msg_bcc' => '','app_msg_attach' => '','app_msg_template' => '','app_msg_status' => 'pending') );
if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
$oSpool->sendMail();
}
}
//Send derivation notification - End
} catch (Exception $oException) {
throw $oException;
}
}
}

View File

@@ -1,13 +1,13 @@
<?php
/**
* FieldCondition.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseFieldCondition.php';
require_once 'classes/model/Dynaform.php';
/**
* Skeleton subclass for representing a row from the 'FIELD_CONDITION' table.
*
@@ -19,22 +19,25 @@ require_once 'classes/model/Dynaform.php';
*
* @package workflow.engine.classes.model
*/
class FieldCondition extends BaseFieldCondition {
class FieldCondition extends BaseFieldCondition
{
public $oDynaformHandler;
var $oDynaformHandler;
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function get( $UID ) {
public function get ($UID)
{
$obj = FieldConditionPeer::retrieveByPk($UID);
if( !isset($obj) ) {
throw new Exception("the record with UID: $UID doesn't exits!");
$obj = FieldConditionPeer::retrieveByPk( $UID );
if (! isset( $obj )) {
throw new Exception( "the record with UID: $UID doesn't exits!" );
}
//TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
return $obj->toArray(BasePeer::TYPE_FIELDNAME);
return $obj->toArray( BasePeer::TYPE_FIELDNAME );
}
/**
@@ -42,21 +45,22 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllCriteriaByDynUid( $DYN_UID, $filter='all' ) {
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_UID);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FUNCTION);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FIELDS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_CONDITION);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENTS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENT_OWNERS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_STATUS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_DYN_UID);
public function getAllCriteriaByDynUid ($DYN_UID, $filter = 'all')
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_UID );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_FUNCTION );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_FIELDS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_CONDITION );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_EVENTS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_EVENT_OWNERS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_STATUS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_DYN_UID );
$oCriteria->add(FieldConditionPeer::FCD_DYN_UID, $DYN_UID);
switch( $filter ) {
$oCriteria->add( FieldConditionPeer::FCD_DYN_UID, $DYN_UID );
switch ($filter) {
case 'active':
$oCriteria->add(FieldConditionPeer::FCD_STATUS, '1', Criteria::EQUAL);
$oCriteria->add( FieldConditionPeer::FCD_STATUS, '1', Criteria::EQUAL );
break;
}
@@ -68,16 +72,17 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllByDynUid( $DYN_UID, $filter='all' ) {
$aRows = Array();
public function getAllByDynUid ($DYN_UID, $filter = 'all')
{
$aRows = Array ();
$oCriteria = $this->getAllCriteriaByDynUid($DYN_UID, $filter);
$oCriteria = $this->getAllCriteriaByDynUid( $DYN_UID, $filter );
$oDataset = FieldConditionPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset = FieldConditionPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while( $aRow = $oDataset->getRow() ) {
while ($aRow = $oDataset->getRow()) {
$aRows[] = $aRow;
$oDataset->next();
}
@@ -90,29 +95,30 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function quickSave($aData) {
$con = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
public function quickSave ($aData)
{
$con = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$obj = null;
if( isset($aData['FCD_UID']) && trim($aData['FCD_UID']) != '' ) {
$obj = FieldConditionPeer::retrieveByPk($aData['FCD_UID']);
if (isset( $aData['FCD_UID'] ) && trim( $aData['FCD_UID'] ) != '') {
$obj = FieldConditionPeer::retrieveByPk( $aData['FCD_UID'] );
} else {
$aData['FCD_UID'] = G::generateUniqueID();
}
if (!is_object($obj)) {
if (! is_object( $obj )) {
$obj = new FieldCondition();
}
$obj->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$obj->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($obj->validate()) {
$result = $obj->save();
$con->commit();
return $result;
} else {
$e = new Exception("Failed Validation in class " . get_class($this) . ".");
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $obj->getValidationFailures();
throw ($e);
}
@@ -123,92 +129,86 @@ class FieldCondition extends BaseFieldCondition {
}
}
function getConditionScript($DYN_UID) {
public function getConditionScript ($DYN_UID)
{
require_once 'classes/model/Dynaform.php';
G::LoadSystem('dynaformhandler');
G::LoadSystem( 'dynaformhandler' );
$oDynaform = DynaformPeer::retrieveByPk($DYN_UID);
$oDynaform = DynaformPeer::retrieveByPk( $DYN_UID );
$PRO_UID = $oDynaform->getProUid();
$this->oDynaformHandler = new dynaFormHandler(PATH_DYNAFORM . "$PRO_UID/$DYN_UID" . '.xml');
$this->oDynaformHandler = new dynaFormHandler( PATH_DYNAFORM . "$PRO_UID/$DYN_UID" . '.xml' );
$aDynaformFields = $this->oDynaformHandler->getFieldNames();
for ( $i = 0; $i < count($aDynaformFields); $i++ ) {
for ($i = 0; $i < count( $aDynaformFields ); $i ++) {
$aDynaformFields[$i] = "'$aDynaformFields[$i]'";
}
$sDynaformFieldsAsStrings = implode(',', $aDynaformFields);
$sDynaformFieldsAsStrings = implode( ',', $aDynaformFields );
$aRows = $this->getAllByDynUid($DYN_UID, 'active');
$aRows = $this->getAllByDynUid( $DYN_UID, 'active' );
$sCode = '';
if( sizeof($aRows) != 0 ) {
foreach ( $aRows as $aRow ) {
$hashCond = md5($aRow['FCD_UID']);
$sCondition = $this->parseCondition($aRow['FCD_CONDITION']);
$sCondition = addslashes($sCondition);
if (sizeof( $aRows ) != 0) {
foreach ($aRows as $aRow) {
$hashCond = md5( $aRow['FCD_UID'] );
$sCondition = $this->parseCondition( $aRow['FCD_CONDITION'] );
$sCondition = addslashes( $sCondition );
$sCode .= "function __condition__$hashCond() { ";
$sCode .= "if( eval(\"{$sCondition}\") ) { ";
$aFields = explode(',', $aRow['FCD_FIELDS']);
$aFields = explode( ',', $aRow['FCD_FIELDS'] );
switch( $aRow['FCD_FUNCTION'] ) {
switch ($aRow['FCD_FUNCTION']) {
case 'show':
foreach ( $aFields as $aField ) {
foreach ($aFields as $aField) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showOnly':
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
foreach ( $aFields as $aField ) {
foreach ($aFields as $aField) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showAll':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
break;
case 'hide':
foreach ( $aFields as $aField ) {
foreach ($aFields as $aField) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideOnly':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
foreach ( $aFields as $aField ) {
foreach ($aFields as $aField) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideAll':
$aDynaFields = array();
$aEventOwner = explode(',', $aRow['FCD_EVENT_OWNERS'] );
foreach($aDynaformFields as $sDynaformFields){
if(! in_array(str_replace("'", "", $sDynaformFields), $aEventOwner) ) {
$aDynaFields = array ();
$aEventOwner = explode( ',', $aRow['FCD_EVENT_OWNERS'] );
foreach ($aDynaformFields as $sDynaformFields) {
if (! in_array( str_replace( "'", "", $sDynaformFields ), $aEventOwner )) {
$aDynaFields[] = $sDynaformFields;
}
}
$sDynaformFieldsAsStrings = implode(',', $aDynaFields);
$sDynaformFieldsAsStrings = implode( ',', $aDynaFields );
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
break;
}
$sCode .= " } ";
$sCode .= "} ";
$aFieldOwners = explode(',', $aRow['FCD_EVENT_OWNERS']);
$aEvents = explode(',', $aRow['FCD_EVENTS']);
if( in_array('onchange', $aEvents) ) {
foreach ( $aFieldOwners as $aField ) {
$aFieldOwners = explode( ',', $aRow['FCD_EVENT_OWNERS'] );
$aEvents = explode( ',', $aRow['FCD_EVENTS'] );
if (in_array( 'onchange', $aEvents )) {
foreach ($aFieldOwners as $aField) {
//verify the field type
$node = $this->oDynaformHandler->getNode($aField);
$nodeType = $node->getAttribute('type');
$node = $this->oDynaformHandler->getNode( $aField );
$nodeType = $node->getAttribute( 'type' );
switch($nodeType){
switch ($nodeType) {
case 'checkbox':
$sJSEvent = 'click';
break;
@@ -218,7 +218,6 @@ class FieldCondition extends BaseFieldCondition {
case 'percentage':
$sJSEvent = 'blur';
break;
default:
$sJSEvent = 'change';
break;
@@ -229,33 +228,33 @@ class FieldCondition extends BaseFieldCondition {
}
}
if( in_array('onload', $aEvents) ) {
foreach ( $aFieldOwners as $aField ) {
if (in_array( 'onload', $aEvents )) {
foreach ($aFieldOwners as $aField) {
$sCode .= " __condition__$hashCond(); ";
}
}
}
return $sCode;
} else {
return NULL;
return null;
}
}
function parseCondition($sCondition) {
preg_match_all('/@#[a-zA-Z0-9_.]+/', $sCondition, $result);
if ( sizeof($result[0]) > 0 ) {
foreach( $result[0] as $fname ) {
preg_match_all('/(@#[a-zA-Z0-9_]+)\.([@#[a-zA-Z0-9_]+)/', $fname, $result2);
if( isset($result2[2][0]) && $result2[1][0]){
$sCondition = str_replace($fname, "getField('".str_replace('@#', '', $result2[1][0])."').".$result2[2][0], $sCondition);
public function parseCondition ($sCondition)
{
preg_match_all( '/@#[a-zA-Z0-9_.]+/', $sCondition, $result );
if (sizeof( $result[0] ) > 0) {
foreach ($result[0] as $fname) {
preg_match_all( '/(@#[a-zA-Z0-9_]+)\.([@#[a-zA-Z0-9_]+)/', $fname, $result2 );
if (isset( $result2[2][0] ) && $result2[1][0]) {
$sCondition = str_replace( $fname, "getField('" . str_replace( '@#', '', $result2[1][0] ) . "')." . $result2[2][0], $sCondition );
} else {
$field = str_replace('@#', '', $fname);
$node = $this->oDynaformHandler->getNode($field);
if(isset($node)) {
$nodeType = $node->getAttribute('type');
switch($nodeType){
$field = str_replace( '@#', '', $fname );
$node = $this->oDynaformHandler->getNode( $field );
if (isset( $node )) {
$nodeType = $node->getAttribute( 'type' );
switch ($nodeType) {
case 'checkbox':
$sAtt = 'checked';
break;
@@ -265,24 +264,25 @@ class FieldCondition extends BaseFieldCondition {
} else {
$sAtt = 'value';
}
$sCondition = str_replace($fname, "getField('".$field."').$sAtt", $sCondition);
$sCondition = str_replace( $fname, "getField('" . $field . "').$sAtt", $sCondition );
}
}
}
return $sCondition;
}
public function create($aData) {
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
public function create ($aData)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
// $aData['FCD_UID'] = '';
if ( isset ( $aData['FCD_UID'] ) && $aData['FCD_UID']== '' )
unset ( $aData['FCD_UID'] );
if ( !isset ( $aData['FCD_UID'] ) )
if (isset( $aData['FCD_UID'] ) && $aData['FCD_UID'] == '') {
unset( $aData['FCD_UID'] );
}
if (! isset( $aData['FCD_UID'] )) {
$aData['FCD_UID'] = G::generateUniqueID();
}
$oFieldCondition = new FieldCondition();
$oFieldCondition->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oFieldCondition->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oFieldCondition->validate()) {
$oConnection->begin();
$iResult = $oFieldCondition->save();
@@ -291,59 +291,61 @@ class FieldCondition extends BaseFieldCondition {
} else {
$sMessage = '';
$aValidationFailures = $oFieldCondition->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
public function remove($sUID) {
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
public function remove ($sUID)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$oConnection->begin();
$this->setFcdUid($sUID);
$this->setFcdUid( $sUID );
$iResult = $this->delete();
$oConnection->commit();
return $iResult;
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
function fieldConditionExists ( $sUid, $aDynaform ) {
public function fieldConditionExists ($sUid, $aDynaform)
{
try {
$found = false;
$obj = FieldConditionPeer::retrieveByPk( $sUid );
if( isset($obj) ) {
$aFields = $obj->toArray(BasePeer::TYPE_FIELDNAME);
foreach($aDynaform as $key => $row){
if($row['DYN_UID'] == $aFields['FCD_DYN_UID'])
if (isset( $obj )) {
$aFields = $obj->toArray( BasePeer::TYPE_FIELDNAME );
foreach ($aDynaform as $key => $row) {
if ($row['DYN_UID'] == $aFields['FCD_DYN_UID']) {
$found = true;
}
}
// return( get_class($obj) == 'FieldCondition') ;
return($found);
}
catch (Exception $oError) {
throw($oError);
// return( get_class($obj) == 'FieldCondition') ;
return ($found);
} catch (Exception $oError) {
throw ($oError);
}
}
function Exists ( $sUid ) {
public function Exists ($sUid)
{
try {
$obj = FieldConditionPeer::retrieveByPk( $sUid );
return(is_object($obj) && get_class($obj) == 'FieldCondition') ;
}
catch (Exception $oError) {
throw($oError);
return (is_object( $obj ) && get_class( $obj ) == 'FieldCondition');
} catch (Exception $oError) {
throw ($oError);
}
}
}
// FieldCondition
} // FieldCondition

View File

@@ -1,12 +1,12 @@
<?php
/**
* Gateway.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseGateway.php';
/**
* Skeleton subclass for representing a row from the 'GATEWAY' table.
*
@@ -18,104 +18,91 @@ require_once 'classes/model/om/BaseGateway.php';
*
* @package workflow.engine.classes.model
*/
class Gateway extends BaseGateway {
class Gateway extends BaseGateway
{
public function create ($aData)
{
$oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$sGatewayUID = G::generateUniqueID();
$aData['GAT_UID'] = $sGatewayUID;
$oGateway = new Gateway();
$oGateway->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oGateway->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oGateway->validate()) {
$oConnection->begin();
$iResult = $oGateway->save();
$oConnection->commit();
return $sGatewayUID;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oGateway->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
public function load($GatewayUid)
public function load ($GatewayUid)
{
try {
$oRow = GatewayPeer::retrieveByPK( $GatewayUid );
if (!is_null($oRow))
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
} else {
throw (new Exception( "The row '" . $GatewayUid . "' in table Gateway doesn't exist!" ));
}
else {
throw(new Exception( "The row '" . $GatewayUid . "' in table Gateway doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
public function update($fields)
{
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try
public function update ($fields)
{
$con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$con->begin();
$this->load($fields['GAT_UID']);
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$result=$this->save();
$this->load( $fields['GAT_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw($e);
throw ($e);
}
}
public function remove($GatewayUid)
public function remove ($GatewayUid)
{
$oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$oGateWay = GatewayPeer::retrieveByPK($GatewayUid);
if (!is_null($oGateWay))
{
$oGateWay = GatewayPeer::retrieveByPK( $GatewayUid );
if (! is_null( $oGateWay )) {
$oConnection->begin();
$iResult = $oGateWay->delete();
$oConnection->commit();
//return $iResult;
return true;
} else {
throw (new Exception( 'This row does not exist!' ));
}
else {
throw(new Exception('This row does not exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
@@ -125,19 +112,18 @@ class Gateway extends BaseGateway {
* @param string $sProUid the uid of the Prolication
*/
function gatewayExists ( $GatUid ) {
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
public function gatewayExists ($GatUid)
{
$con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$oPro = GatewayPeer::retrieveByPk( $GatUid );
if ( is_object($oPro) && get_class ($oPro) == 'Gateway' ) {
if (is_object( $oPro ) && get_class( $oPro ) == 'Gateway') {
return true;
}
else {
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
@@ -147,39 +133,34 @@ class Gateway extends BaseGateway {
* @param array $aData with new values
* @return void
*/
function createRow($aData)
{
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try
public function createRow ($aData)
{
$con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$con->begin();
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$this->setGatUid((isset($aData['GAT_UID']) ? $aData['GAT_UID']: ''));
$this->setProUid((isset($aData['PRO_UID']) ? $aData['PRO_UID']: ''));
$this->setTasUid((isset($aData['TAS_UID']) ? $aData['TAS_UID']: ''));
$this->setGatNextTask((isset($aData['GAT_NEXT_TASK']) ? $aData['GAT_NEXT_TASK']: ''));
$this->setGatX((isset($aData['GAT_X']) ? $aData['GAT_X']: ''));
$this->setGatY((isset($aData['GAT_Y']) ? $aData['GAT_Y']: ''));
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$this->setGatUid( (isset( $aData['GAT_UID'] ) ? $aData['GAT_UID'] : '') );
$this->setProUid( (isset( $aData['PRO_UID'] ) ? $aData['PRO_UID'] : '') );
$this->setTasUid( (isset( $aData['TAS_UID'] ) ? $aData['TAS_UID'] : '') );
$this->setGatNextTask( (isset( $aData['GAT_NEXT_TASK'] ) ? $aData['GAT_NEXT_TASK'] : '') );
$this->setGatX( (isset( $aData['GAT_X'] ) ? $aData['GAT_X'] : '') );
$this->setGatY( (isset( $aData['GAT_Y'] ) ? $aData['GAT_Y'] : '') );
$this->save();
$con->commit();
return;
}
else
{
} else {
$con->rollback();
$e=new Exception("Failed Validation in class ".get_class($this).".");
$e->aValidationFailures=$this->getValidationFailures();
throw($e);
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $this->getValidationFailures();
throw ($e);
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw($e);
throw ($e);
}
}
}
// Gateway
} // Gateway

View File

@@ -1,12 +1,12 @@
<?php
/**
* ReportVar.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseReportVar.php';
/**
* Skeleton subclass for representing a row from the 'REPORT_VAR' table.
*
@@ -18,145 +18,143 @@ require_once 'classes/model/om/BaseReportVar.php';
*
* @package workflow.engine.classes.model
*/
class ReportVar extends BaseReportVar {
class ReportVar extends BaseReportVar
{
/*
* Load the report var registry
* @param string $sRepVarUid
* @return variant
*/
public function load($sRepVarUid)
public function load ($sRepVarUid)
{
try {
$oReportVar = ReportVarPeer::retrieveByPK( $sRepVarUid );
if (!is_null($oReportVar))
{
$aFields = $oReportVar->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
if (! is_null( $oReportVar )) {
$aFields = $oReportVar->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the report var registry
*
* @param array $aData
* @return string
**/
public function create($aData)
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( ReportVarPeer::DATABASE_NAME );
try {
if ( isset ( $aData['REP_VAR_UID'] ) && $aData['REP_VAR_UID']== '' )
unset ( $aData['REP_VAR_UID'] );
if ( !isset ( $aData['REP_VAR_UID'] ) )
if (isset( $aData['REP_VAR_UID'] ) && $aData['REP_VAR_UID'] == '') {
unset( $aData['REP_VAR_UID'] );
}
if (! isset( $aData['REP_VAR_UID'] )) {
$aData['REP_VAR_UID'] = G::generateUniqueID();
}
$oReportVar = new ReportVar();
$oReportVar->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oReportVar->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oReportVar->validate()) {
$oConnection->begin();
$iResult = $oReportVar->save();
$oConnection->commit();
return $aData['REP_VAR_UID'];
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oReportVar->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
/**
* Update the report var registry
*
* @param array $aData
* @return string
**/
public function update($aData)
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( ReportVarPeer::DATABASE_NAME );
try {
$oReportVar = ReportVarPeer::retrieveByPK($aData['REP_VAR_UID']);
if (!is_null($oReportVar))
{
$oReportVar->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oReportVar = ReportVarPeer::retrieveByPK( $aData['REP_VAR_UID'] );
if (! is_null( $oReportVar )) {
$oReportVar->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oReportVar->validate()) {
$oConnection->begin();
$iResult = $oReportVar->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oReportVar->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
/**
* Remove the report var registry
*
* @param array $aData
* @return string
**/
public function remove($sRepVarUid)
*
*/
public function remove ($sRepVarUid)
{
$oConnection = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( ReportVarPeer::DATABASE_NAME );
try {
$oReportVar = ReportVarPeer::retrieveByPK($sRepVarUid);
if (!is_null($oReportVar))
{
$oReportVar = ReportVarPeer::retrieveByPK( $sRepVarUid );
if (! is_null( $oReportVar )) {
$oConnection->begin();
$iResult = $oReportVar->delete();
$oConnection->commit();
return $iResult;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
function reportVarExists ( $sRepVarUid ) {
$con = Propel::getConnection(ReportVarPeer::DATABASE_NAME);
public function reportVarExists ($sRepVarUid)
{
$con = Propel::getConnection( ReportVarPeer::DATABASE_NAME );
try {
$oRepVarUid = ReportVarPeer::retrieveByPk( $sRepVarUid );
if (is_object($oRepVarUid) && get_class ($oRepVarUid) == 'ReportVar' ) {
if (is_object( $oRepVarUid ) && get_class( $oRepVarUid ) == 'ReportVar') {
return true;
}
else {
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
} // ReportVar
}
// ReportVar

View File

@@ -1,12 +1,12 @@
<?php
/**
* SubProcess.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseSubProcess.php';
/**
* Skeleton subclass for representing a row from the 'SUB_PROCESS' table.
*
@@ -18,126 +18,113 @@ require_once 'classes/model/om/BaseSubProcess.php';
*
* @package workflow.engine.classes.model
*/
class SubProcess extends BaseSubProcess {
class SubProcess extends BaseSubProcess
{
public function load($SP_UID)
public function load ($SP_UID)
{
try {
$oRow = SubProcessPeer::retrieveByPK( $SP_UID );
if (!is_null($oRow))
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
} else {
throw (new Exception( "The row '$SP_UID' in table SubProcess doesn't exist!" ));
}
else {
throw( new Exception( "The row '$SP_UID' in table SubProcess doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
public function create($aData)
{
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try
public function create ($aData)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$con->begin();
if ( isset ( $aData['SP_UID'] ) && $aData['SP_UID']== '' )
unset ( $aData['SP_UID'] );
if ( !isset ( $aData['SP_UID'] ) )
$this->setSpUid(G::generateUniqueID());
else
$this->setSpUid($aData['SP_UID'] );
if (isset( $aData['SP_UID'] ) && $aData['SP_UID'] == '') {
unset( $aData['SP_UID'] );
}
if (! isset( $aData['SP_UID'] )) {
$this->setSpUid( G::generateUniqueID() );
} else {
$this->setSpUid( $aData['SP_UID'] );
}
$this->setProUid($aData['PRO_UID']);
$this->setProUid( $aData['PRO_UID'] );
$this->setTasUid($aData['TAS_UID']);
$this->setTasUid( $aData['TAS_UID'] );
$this->setProParent($aData['PRO_PARENT']);
$this->setProParent( $aData['PRO_PARENT'] );
$this->setTasParent($aData['TAS_PARENT']);
$this->setTasParent( $aData['TAS_PARENT'] );
$this->setSpType($aData['SP_TYPE']);
$this->setSpType( $aData['SP_TYPE'] );
$this->setSpSynchronous($aData['SP_SYNCHRONOUS']);
$this->setSpSynchronous( $aData['SP_SYNCHRONOUS'] );
$this->setSpSynchronousType($aData['SP_SYNCHRONOUS_TYPE']);
$this->setSpSynchronousType( $aData['SP_SYNCHRONOUS_TYPE'] );
$this->setSpSynchronousWait($aData['SP_SYNCHRONOUS_WAIT']);
$this->setSpSynchronousWait( $aData['SP_SYNCHRONOUS_WAIT'] );
$this->setSpVariablesOut($aData['SP_VARIABLES_OUT']);
$this->setSpVariablesOut( $aData['SP_VARIABLES_OUT'] );
$this->setSpVariablesIn($aData['SP_VARIABLES_IN']);
$this->setSpVariablesIn( $aData['SP_VARIABLES_IN'] );
$this->setSpGridIn($aData['SP_GRID_IN']);
$this->setSpGridIn( $aData['SP_GRID_IN'] );
if($this->validate())
{
$result=$this->save();
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw($e);
throw ($e);
}
}
public function update($fields)
{
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try
public function update ($fields)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$con->begin();
$this->load($fields['SP_UID']);
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$result=$this->save();
$this->load( $fields['SP_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE->aValidationFailures = $this->getValidationFailures();
throw($validationE);
throw ($validationE);
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw($e);
throw ($e);
}
}
public function remove($SP_UID)
{
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try
public function remove ($SP_UID)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$con->begin();
$oRepTab = SubProcessPeer::retrieveByPK( $SP_UID );
if (!is_null($oRepTab)) {
if (! is_null( $oRepTab )) {
$result = $oRepTab->delete();
$con->commit();
}
return $result;
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw($e);
throw ($e);
}
}
@@ -147,20 +134,20 @@ class SubProcess extends BaseSubProcess {
* @param string $sUid the uid of the Prolication
*/
function subProcessExists ( $sUid ) {
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
public function subProcessExists ($sUid)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$oObj = SubProcessPeer::retrieveByPk( $sUid );
if (is_object($oObj) && get_class ($oObj) == 'SubProcess' ) {
if (is_object( $oObj ) && get_class( $oObj ) == 'SubProcess') {
return true;
}
else {
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
}
// SubProcess
} // SubProcess

View File

@@ -1,6 +1,7 @@
<?php
/**
* SwimlanesElements.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
@@ -38,10 +39,12 @@ require_once 'classes/model/Content.php';
*
* @package workflow.engine.classes.model
*/
class SwimlanesElements extends BaseSwimlanesElements {
class SwimlanesElements extends BaseSwimlanesElements
{
/**
* This value goes in the content table
*
* @var string
*/
protected $swi_text = '';
@@ -51,160 +54,152 @@ class SwimlanesElements extends BaseSwimlanesElements {
* @param string $sAppDocUid
* @return variant
*/
public function load($sSwiEleUid)
public function load ($sSwiEleUid)
{
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($sSwiEleUid);
if (!is_null($oSwimlanesElements))
{
$aFields = $oSwimlanesElements->toArray(BasePeer::TYPE_FIELDNAME);
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (! is_null( $oSwimlanesElements )) {
$aFields = $oSwimlanesElements->toArray( BasePeer::TYPE_FIELDNAME );
$aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText();
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the application document registry
*
* @param array $aData
* @return string
**/
public function create($aData)
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$aData['SWI_UID'] = G::generateUniqueID();
$oSwimlanesElements = new SwimlanesElements();
$oSwimlanesElements->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset($aData['SWI_TEXT'])) {
$oSwimlanesElements->setSwiEleText($aData['SWI_TEXT']);
if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
return $aData['SWI_UID'];
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
/**
* Update the application document registry
*
* @param array $aData
* @return string
**/
public function update($aData)
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($aData['SWI_UID']);
if (!is_null($oSwimlanesElements))
{
$oSwimlanesElements->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $aData['SWI_UID'] );
if (! is_null( $oSwimlanesElements )) {
$oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset($aData['SWI_TEXT']))
{
$oSwimlanesElements->setSwiEleText($aData['SWI_TEXT']);
if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
/**
* Remove the application document registry
*
* @param array $aData
* @return string
**/
public function remove($sSwiEleUid)
*
*/
public function remove ($sSwiEleUid)
{
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($sSwiEleUid);
if (!is_null($oSwimlanesElements))
{
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (! is_null( $oSwimlanesElements )) {
$oConnection->begin();
Content::removeContent('SWI_TEXT', '', $oSwimlanesElements->getSwiUid());
Content::removeContent( 'SWI_TEXT', '', $oSwimlanesElements->getSwiUid() );
$iResult = $oSwimlanesElements->delete();
$oConnection->commit();
return $iResult;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
function swimlanesElementsExists ( $sSwiEleUid ) {
$con = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
public function swimlanesElementsExists ($sSwiEleUid)
{
$con = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwiEleUid = SwimlanesElementsPeer::retrieveByPk( $sSwiEleUid );
if (is_object($oSwiEleUid) && get_class ($oSwiEleUid) == 'SwimlanesElements' ) {
if (is_object( $oSwiEleUid ) && get_class( $oSwiEleUid ) == 'SwimlanesElements') {
return true;
}
else {
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Get the [swi_text] column value.
*
* @return string
*/
public function getSwiEleText()
public function getSwiEleText ()
{
if ($this->swi_text == '') {
try {
$this->swi_text = Content::load('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
}
catch (Exception $oError) {
throw($oError);
$this->swi_text = Content::load( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->swi_text;
@@ -216,22 +211,22 @@ function swimlanesElementsExists ( $sSwiEleUid ) {
* @param string $sValue new value
* @return void
*/
public function setSwiEleText($sValue)
public function setSwiEleText ($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
if ($sValue !== null && ! is_string( $sValue )) {
$sValue = (string) $sValue;
}
if ($this->swi_text !== $sValue || $sValue === '') {
try {
$this->swi_text = $sValue;
$iResult = Content::addContent('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->swi_text);
}
catch (Exception $oError) {
$iResult = Content::addContent( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->swi_text );
} catch (Exception $oError) {
$this->swi_text = '';
throw($oError);
throw ($oError);
}
}
}
}
// SwimlanesElements
} // SwimlanesElements

View File

@@ -1,6 +1,7 @@
<?php
/**
* TaskUser.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
@@ -38,161 +39,160 @@ require_once 'classes/model/Content.php';
*
* @package workflow.engine.classes.model
*/
class TaskUser extends BaseTaskUser {
class TaskUser extends BaseTaskUser
{
/**
* Create the application document registry
*
* @param array $aData
* @return string
**/
public function create($aData)
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$taskUser = TaskUserPeer::retrieveByPK($aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION']);
if( is_object($taskUser) )
return -1;
$taskUser = TaskUserPeer::retrieveByPK( $aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION'] );
if (is_object( $taskUser )) {
return - 1;
}
$oTaskUser = new TaskUser();
$oTaskUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oTaskUser->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oTaskUser->validate()) {
$oConnection->begin();
$iResult = $oTaskUser->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oTaskUser->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
/**
* Remove the application document registry
*
* @param string $sTasUid
* @param string $sUserUid
* @return string
**/
public function remove($sTasUid, $sUserUid, $iType, $iRelation)
*
*/
public function remove ($sTasUid, $sUserUid, $iType, $iRelation)
{
$oConnection = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$oTaskUser = TaskUserPeer::retrieveByPK($sTasUid, $sUserUid, $iType, $iRelation);
if (!is_null($oTaskUser))
{
$oTaskUser = TaskUserPeer::retrieveByPK( $sTasUid, $sUserUid, $iType, $iRelation );
if (! is_null( $oTaskUser )) {
$oConnection->begin();
$iResult = $oTaskUser->delete();
$oConnection->commit();
return $iResult;
} else {
throw (new Exception( 'This row does not exist!' ));
}
else {
throw(new Exception('This row does not exist!'));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
throw ($oError);
}
}
function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation) {
$con = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
public function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation)
{
$con = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$oTaskUser = TaskUserPeer::retrieveByPk($sTasUid, $sUserUid, $iType, $iRelation);
if ( is_object($oTaskUser) && get_class ($oTaskUser) == 'TaskUser' ) {
$oTaskUser = TaskUserPeer::retrieveByPk( $sTasUid, $sUserUid, $iType, $iRelation );
if (is_object( $oTaskUser ) && get_class( $oTaskUser ) == 'TaskUser') {
return true;
}
else {
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
} catch (Exception $oError) {
throw ($oError);
}
}
function getCountAllTaksByGroups(){
$oCriteria = new Criteria('workflow');
$oCriteria->addAsColumn('GRP_UID', TaskUserPeer::USR_UID);
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->add(TaskUserPeer::TU_TYPE,1);
$oCriteria->add(TaskUserPeer::TU_RELATION,2);
$oCriteria->addGroupByColumn(TaskUserPeer::USR_UID);
$oDataset = TaskUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode (ResultSet::FETCHMODE_ASSOC);
$aRows = Array();
while ($oDataset->next()){
public function getCountAllTaksByGroups ()
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addAsColumn( 'GRP_UID', TaskUserPeer::USR_UID );
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
$oCriteria->add( TaskUserPeer::TU_TYPE, 1 );
$oCriteria->add( TaskUserPeer::TU_RELATION, 2 );
$oCriteria->addGroupByColumn( TaskUserPeer::USR_UID );
$oDataset = TaskUserPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aRows = Array ();
while ($oDataset->next()) {
$row = $oDataset->getRow();
$aRows[$row['GRP_UID']] = $row['CNT'];
}
return $aRows;
}
//erik: new functions
function getUsersTask($TAS_UID, $TU_TYPE=1){
public function getUsersTask ($TAS_UID, $TU_TYPE = 1)
{
require_once 'classes/model/Users.php';
$groupsTask = array();
$usersTask = array();
$groupsTask = array ();
$usersTask = array ();
//getting task's users
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$criteria->addSelectColumn(TaskUserPeer::TAS_UID);
$criteria->addSelectColumn(TaskUserPeer::USR_UID);
$criteria->addSelectColumn(TaskUserPeer::TU_TYPE);
$criteria->addSelectColumn(TaskUserPeer::TU_RELATION);
$criteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$criteria->add(TaskUserPeer::TAS_UID, $TAS_UID);
$criteria->add(TaskUserPeer::TU_TYPE, $TU_TYPE);
$criteria->add(TaskUserPeer::TU_RELATION, 1);
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
$criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$criteria->addSelectColumn( TaskUserPeer::TAS_UID );
$criteria->addSelectColumn( TaskUserPeer::USR_UID );
$criteria->addSelectColumn( TaskUserPeer::TU_TYPE );
$criteria->addSelectColumn( TaskUserPeer::TU_RELATION );
$criteria->addJoin( TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
$criteria->add( TaskUserPeer::TAS_UID, $TAS_UID );
$criteria->add( TaskUserPeer::TU_TYPE, $TU_TYPE );
$criteria->add( TaskUserPeer::TU_RELATION, 1 );
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset = TaskUserPeer::doSelectRS( $criteria );
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while ($dataset->next())
while ($dataset->next()) {
$usersTask[] = $dataset->getRow();
}
//getting task's groups
$delimiter = DBAdapter::getStringDelimiter ();
$criteria = new Criteria('workflow');
$criteria->addAsColumn('GRP_TITLE', 'CONTENT.CON_VALUE');
$criteria->addSelectColumn(TaskUserPeer::TAS_UID);
$criteria->addSelectColumn(TaskUserPeer::USR_UID);
$criteria->addSelectColumn(TaskUserPeer::TU_TYPE);
$criteria->addSelectColumn(TaskUserPeer::TU_RELATION);
$aConditions[] = array(TaskUserPeer::USR_UID, 'CONTENT.CON_ID');
$aConditions[] = array('CONTENT.CON_CATEGORY', $delimiter . 'GRP_TITLE' . $delimiter);
$aConditions[] = array('CONTENT.CON_LANG', $delimiter . SYS_LANG . $delimiter);
$criteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
$criteria->add(TaskUserPeer::TAS_UID, $TAS_UID);
$criteria->add(TaskUserPeer::TU_TYPE, $TU_TYPE);
$criteria->add(TaskUserPeer::TU_RELATION, 2);
$dataset = TaskUserPeer::doSelectRS($criteria);
$delimiter = DBAdapter::getStringDelimiter();
$criteria = new Criteria( 'workflow' );
$criteria->addAsColumn( 'GRP_TITLE', 'CONTENT.CON_VALUE' );
$criteria->addSelectColumn( TaskUserPeer::TAS_UID );
$criteria->addSelectColumn( TaskUserPeer::USR_UID );
$criteria->addSelectColumn( TaskUserPeer::TU_TYPE );
$criteria->addSelectColumn( TaskUserPeer::TU_RELATION );
$aConditions[] = array (TaskUserPeer::USR_UID,'CONTENT.CON_ID');
$aConditions[] = array ('CONTENT.CON_CATEGORY',$delimiter . 'GRP_TITLE' . $delimiter);
$aConditions[] = array ('CONTENT.CON_LANG',$delimiter . SYS_LANG . $delimiter);
$criteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
$criteria->add( TaskUserPeer::TAS_UID, $TAS_UID );
$criteria->add( TaskUserPeer::TU_TYPE, $TU_TYPE );
$criteria->add( TaskUserPeer::TU_RELATION, 2 );
$dataset = TaskUserPeer::doSelectRS( $criteria );
$dataset = TaskUserPeer::doSelectRS( $criteria );
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while( $dataset->next() )
while ($dataset->next()) {
$usersTask[] = $dataset->getRow();
}
$result->data = $usersTask;
$result->totalCount = sizeof($usersTask);
$result->totalCount = sizeof( $usersTask );
return $result;
}
}
// TaskUser
} // TaskUser

File diff suppressed because it is too large Load Diff