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,227 +1,218 @@
<?php <?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
{
private $dir_to_compress = "";
private $filename = "backUpProcessMaker.tar";
private $fileSize = "1000";
// 1 GB by default.
private $sizeDescriptor = "m";
//megabytes
private $tempDirectories = array ();
/** Class MultipleFilesBackup /* Constructor
* create a backup of this workspace * @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.
* Exports the database and copies the files to an tar archive o several if the max filesize is reached. */
* public function multipleFilesBackup ($filename, $size)
*/
class multipleFilesBackup{
private $dir_to_compress = "";
private $filename = "backUpProcessMaker.tar";
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)
{
if(!empty($filename)){
$this->filename = $filename;
}
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)
{
//verifing if workspace exists.
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/");
}
$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");
$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");
}
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)
{
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()
{
// creating command
$CommpressCommand = "tar czv ";
$CommpressCommand .= $this->dir_to_compress;
$CommpressCommand .= "| split -b ";
$CommpressCommand .= $this->fileSize;
$CommpressCommand .= "m -d - ";
$CommpressCommand .= $this->filename . ".";
//executing command to create the files
echo exec($CommpressCommand);
//Remove leftovers dirs.
foreach($this->tempDirectories as $tempDirectory)
{ {
CLI::logging("Deleting: ".$tempDirectory."\n"); if (! empty( $filename )) {
G::rm_dir($tempDirectory); $this->filename = $filename;
}
}
/* Restore from file(s) commpressed by letsBackup function, into a temporary directory
* @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated.
* @ srcWorkspace contains the workspace to be restored.
* @ 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)
{
// 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__, ''));
$parentDirectory = PATH_DATA . "upgrade";
if (is_writable($parentDirectory)) {
mkdir($tempDirectory);
} else {
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");
//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);
}
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");
}
}
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");
}
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");
}
$backupWorkspace = $metadata->WORKSPACE_NAME;
if (isset($dstWorkspace)) {
$workspaceName = $dstWorkspace;
$createWorkspace = true;
}
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");
continue;
}
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{ if (! empty( $size ) && (int) $size > 0) {
throw new Exception("Destination workspace already exist (use -o to overwrite)"); $this->fileSize = $size;
} }
}
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("> 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));
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);
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);
}
$workspace->upgradeCacheView(false);
mysql_close($link);
} }
CLI::logging("Removing temporary files\n");
G::rm_dir($tempDirectory); /* Gets workspace information enough to make its backup.
CLI::logging(CLI::info("Done restoring") . "\n"); * @workspace contains the workspace to be add to the commpression process.
} */
public function addToBackup ($workspace)
{
//verifing if workspace exists.
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/" );
}
$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");
$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" );
}
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)
{
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 ()
{
// creating command
$CommpressCommand = "tar czv ";
$CommpressCommand .= $this->dir_to_compress;
$CommpressCommand .= "| split -b ";
$CommpressCommand .= $this->fileSize;
$CommpressCommand .= "m -d - ";
$CommpressCommand .= $this->filename . ".";
//executing command to create the files
echo exec( $CommpressCommand );
//Remove leftovers dirs.
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
* @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated.
* @ srcWorkspace contains the workspace to be restored.
* @ 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)
{
// 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__, '' ) );
$parentDirectory = PATH_DATA . "upgrade";
if (is_writable( $parentDirectory )) {
mkdir( $tempDirectory );
} else {
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" );
//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 );
} 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" );
}
}
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" );
}
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" );
}
$backupWorkspace = $metadata->WORKSPACE_NAME;
if (isset( $dstWorkspace )) {
$workspaceName = $dstWorkspace;
$createWorkspace = true;
} 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" );
continue;
} 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)" );
}
}
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( "> 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 ) );
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 );
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 );
}
$workspace->upgradeCacheView( false );
mysql_close( $link );
}
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 class pluginDetail
{ {
var $sNamespace; public $sNamespace;
var $sClassName; public $sClassName;
var $sFriendlyName = null; public $sFriendlyName = null;
var $sDescription = null; public $sDescription = null;
var $sSetupPage = null; public $sSetupPage = null;
var $sFilename; public $sFilename;
var $sPluginFolder = ''; public $sPluginFolder = '';
var $sCompanyLogo = ''; public $sCompanyLogo = '';
var $iVersion = 0; public $iVersion = 0;
var $enabled = false; public $enabled = false;
var $aWorkspaces = null; public $aWorkspaces = null;
var $bPrivate = false; public $bPrivate = false;
/** /**
* This function is the constructor of the pluginDetail class * This function is the constructor of the pluginDetail class
@@ -58,7 +58,7 @@ class pluginDetail
* @param integer $iVersion * @param integer $iVersion
* @return void * @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->sNamespace = $sNamespace;
$this->sClassName = $sClassName; $this->sClassName = $sClassName;
@@ -67,10 +67,11 @@ class pluginDetail
$this->sSetupPage = $sSetupPage; $this->sSetupPage = $sSetupPage;
$this->iVersion = $iVersion; $this->iVersion = $iVersion;
$this->sFilename = $sFilename; $this->sFilename = $sFilename;
if ($sPluginFolder == '') if ($sPluginFolder == '') {
$this->sPluginFolder = $sNamespace; $this->sPluginFolder = $sNamespace;
else } else {
$this->sPluginFolder = $sPluginFolder; $this->sPluginFolder = $sPluginFolder;
}
} }
} }
@@ -107,7 +108,7 @@ class PMPluginRegistry
*/ */
private $_restServices = array (); private $_restServices = array ();
private static $instance = NULL; private static $instance = null;
/** /**
* This function is the constructor of the PMPluginRegistry class * This function is the constructor of the PMPluginRegistry class
@@ -127,7 +128,7 @@ class PMPluginRegistry
*/ */
function &getSingleton () function &getSingleton ()
{ {
if (self::$instance == NULL) { if (self::$instance == null) {
self::$instance = new PMPluginRegistry(); self::$instance = new PMPluginRegistry();
} }
return self::$instance; return self::$instance;
@@ -139,7 +140,7 @@ class PMPluginRegistry
* *
* @return void * @return void
*/ */
function serializeInstance () public function serializeInstance ()
{ {
return serialize( self::$instance ); return serialize( self::$instance );
} }
@@ -150,9 +151,9 @@ class PMPluginRegistry
* @param string $serialized * @param string $serialized
* @return void * @return void
*/ */
function unSerializeInstance ($serialized) public function unSerializeInstance ($serialized)
{ {
if (self::$instance == NULL) { if (self::$instance == null) {
self::$instance = new PMPluginRegistry(); self::$instance = new PMPluginRegistry();
} }
@@ -163,7 +164,7 @@ class PMPluginRegistry
/** /**
* Save the current instance to the plugin singleton * Save the current instance to the plugin singleton
*/ */
function save () public function save ()
{ {
file_put_contents( PATH_DATA_SITE . 'plugin.singleton', $this->serializeInstance() ); file_put_contents( PATH_DATA_SITE . 'plugin.singleton', $this->serializeInstance() );
} }
@@ -175,35 +176,27 @@ class PMPluginRegistry
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
public function registerPlugin($sNamespace, $sFilename=null) public function registerPlugin ($sNamespace, $sFilename = null)
{ {
//require_once ($sFilename); //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; $this->_aPluginDetails[$sNamespace]->iVersion = $plugin->iVersion;
return; return;
} }
$detail = new pluginDetail( $detail = new pluginDetail( $sNamespace, $sClassName, $sFilename, $plugin->sFriendlyName, $plugin->sPluginFolder, $plugin->sDescription, $plugin->sSetupPage, $plugin->iVersion );
$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; $detail->aWorkspaces = $plugin->aWorkspaces;
} }
if (isset($plugin->bPrivate)) { if (isset( $plugin->bPrivate )) {
$detail->bPrivate = $plugin->bPrivate; $detail->bPrivate = $plugin->bPrivate;
} }
@@ -211,6 +204,7 @@ class PMPluginRegistry
// $detail->enabled = $this->_aPluginDetails[$sNamespace]->enabled; // $detail->enabled = $this->_aPluginDetails[$sNamespace]->enabled;
//} //}
$this->_aPluginDetails[$sNamespace] = $detail; $this->_aPluginDetails[$sNamespace] = $detail;
} }
@@ -219,13 +213,14 @@ class PMPluginRegistry
* *
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
function getPluginDetails ($sFilename) public function getPluginDetails ($sFilename)
{ {
foreach ($this->_aPluginDetails as $key => $row) { foreach ($this->_aPluginDetails as $key => $row) {
if ($sFilename == baseName( $row->sFilename )) if ($sFilename == baseName( $row->sFilename )) {
return $row; return $row;
}
} }
return NULL; return null;
} }
/** /**
@@ -233,11 +228,12 @@ class PMPluginRegistry
* *
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
*/ */
function enablePlugin ($sNamespace) public function enablePlugin ($sNamespace)
{ {
foreach ($this->_aPluginDetails as $namespace => $detail) { foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($sNamespace == $namespace) { 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; $this->_aPluginDetails[$sNamespace]->enabled = true;
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename ); $oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
$this->_aPlugins[$detail->sNamespace] = $oPlugin; $this->_aPlugins[$detail->sNamespace] = $oPlugin;
@@ -255,7 +251,7 @@ class PMPluginRegistry
* *
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
*/ */
function disablePlugin ($sNamespace, $eventPlugin = 1) public function disablePlugin ($sNamespace, $eventPlugin = 1)
{ {
$sw = false; $sw = false;
@@ -280,16 +276,19 @@ class PMPluginRegistry
} }
foreach ($this->_aMenus as $key => $detail) { foreach ($this->_aMenus as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aMenus[$key] ); unset( $this->_aMenus[$key] );
}
} }
foreach ($this->_aFolders as $key => $detail) { foreach ($this->_aFolders as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aFolders[$key] ); unset( $this->_aFolders[$key] );
}
} }
foreach ($this->_aTriggers as $key => $detail) { foreach ($this->_aTriggers as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aTriggers[$key] ); unset( $this->_aTriggers[$key] );
}
} }
foreach ($this->_aDashlets as $key => $detail) { foreach ($this->_aDashlets as $key => $detail) {
if ($detail == $sNamespace) { if ($detail == $sNamespace) {
@@ -297,40 +296,49 @@ class PMPluginRegistry
} }
} }
foreach ($this->_aReports as $key => $detail) { foreach ($this->_aReports as $key => $detail) {
if ($detail == $sNamespace) if ($detail == $sNamespace) {
unset( $this->_aReports[$key] ); unset( $this->_aReports[$key] );
}
} }
foreach ($this->_aPmFunctions as $key => $detail) { foreach ($this->_aPmFunctions as $key => $detail) {
if ($detail == $sNamespace) if ($detail == $sNamespace) {
unset( $this->_aPmFunctions[$key] ); unset( $this->_aPmFunctions[$key] );
}
} }
foreach ($this->_aRedirectLogin as $key => $detail) { foreach ($this->_aRedirectLogin as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aRedirectLogin[$key] ); unset( $this->_aRedirectLogin[$key] );
}
} }
foreach ($this->_aSteps as $key => $detail) { foreach ($this->_aSteps as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aSteps[$key] ); unset( $this->_aSteps[$key] );
}
} }
foreach ($this->_aToolbarFiles as $key => $detail) { foreach ($this->_aToolbarFiles as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aToolbarFiles[$key] ); unset( $this->_aToolbarFiles[$key] );
}
} }
foreach ($this->_aCSSStyleSheets as $key => $detail) { foreach ($this->_aCSSStyleSheets as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aCSSStyleSheets[$key] ); unset( $this->_aCSSStyleSheets[$key] );
}
} }
foreach ($this->_aCaseSchedulerPlugin as $key => $detail) { foreach ($this->_aCaseSchedulerPlugin as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aCaseSchedulerPlugin[$key] ); unset( $this->_aCaseSchedulerPlugin[$key] );
}
} }
foreach ($this->_aTaskExtendedProperties as $key => $detail) { foreach ($this->_aTaskExtendedProperties as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aTaskExtendedProperties[$key] ); unset( $this->_aTaskExtendedProperties[$key] );
}
} }
foreach ($this->_aDashboardPages as $key => $detail) { foreach ($this->_aDashboardPages as $key => $detail) {
if ($detail->sNamespace == $sNamespace) if ($detail->sNamespace == $sNamespace) {
unset( $this->_aDashboardPages[$key] ); unset( $this->_aDashboardPages[$key] );
}
} }
//unregistering javascripts from this plugin //unregistering javascripts from this plugin
@@ -344,14 +352,16 @@ class PMPluginRegistry
* *
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
*/ */
function getStatusPlugin ($sNamespace) public function getStatusPlugin ($sNamespace)
{ {
foreach ($this->_aPluginDetails as $namespace => $detail) { foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($sNamespace == $namespace) if ($sNamespace == $namespace) {
if ($this->_aPluginDetails[$sNamespace]->enabled) if ($this->_aPluginDetails[$sNamespace]->enabled) {
return 'enabled'; return 'enabled';
else } else {
return 'disabled'; return 'disabled';
}
}
} }
return 0; return 0;
} }
@@ -363,13 +373,11 @@ class PMPluginRegistry
* *
* @return bool true if enabled, false otherwise * @return bool true if enabled, false otherwise
*/ */
function installPluginArchive ($filename, $pluginName) public function installPluginArchive ($filename, $pluginName)
{ {
G::LoadThirdParty( "pear/Archive", "Tar" ); G::LoadThirdParty( "pear/Archive", "Tar" );
$tar = new Archive_Tar( $filename ); $tar = new Archive_Tar( $filename );
$files = $tar->listContent(); $files = $tar->listContent();
$plugins = array (); $plugins = array ();
$namePlugin = array (); $namePlugin = array ();
foreach ($files as $f) { foreach ($files as $f) {
@@ -395,40 +403,38 @@ class PMPluginRegistry
$pluginFile = "$pluginName.php"; $pluginFile = "$pluginName.php";
/* /*
$oldPluginStatus = $this->getStatusPlugin($pluginFile); $oldPluginStatus = $this->getStatusPlugin($pluginFile);
if ($pluginStatus != 0) { if ($pluginStatus != 0) {
$oldDetails = $this->getPluginDetails($pluginFile); $oldDetails = $this->getPluginDetails($pluginFile);
$oldVersion = $oldDetails->iVersion; $oldVersion = $oldDetails->iVersion;
} else { } else {
$oldDetails = NULL; $oldDetails = NULL;
$oldVersion = NULL; $oldVersion = NULL;
} }
*/ */
//$pluginIni = $tar->extractInString("$pluginName.ini"); //$pluginIni = $tar->extractInString("$pluginName.ini");
//$pluginConfig = parse_ini_string($pluginIni); //$pluginConfig = parse_ini_string($pluginIni);
/* /*
if (!empty($oClass->aDependences)) { if (!empty($oClass->aDependences)) {
foreach ($oClass->aDependences as $aDependence) { foreach ($oClass->aDependences as $aDependence) {
if (file_exists(PATH_PLUGINS . $aDependence['sClassName'] . '.php')) { if (file_exists(PATH_PLUGINS . $aDependence['sClassName'] . '.php')) {
require_once PATH_PLUGINS . $aDependence['sClassName'] . '.php'; require_once PATH_PLUGINS . $aDependence['sClassName'] . '.php';
if (!$oPluginRegistry->getPluginDetails($aDependence['sClassName'] . '.php')) { if (!$oPluginRegistry->getPluginDetails($aDependence['sClassName'] . '.php')) {
throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin'); throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin');
}
}
else {
throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin');
}
} }
} }
else { unset($oClass);
throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin'); if ($fVersionOld > $fVersionNew) {
throw new Exception('A recent version of this plugin was already installed.');
} }
} */
}
unset($oClass);
if ($fVersionOld > $fVersionNew) {
throw new Exception('A recent version of this plugin was already installed.');
}
*/
$res = $tar->extract( PATH_PLUGINS ); $res = $tar->extract( PATH_PLUGINS );
@@ -446,7 +452,7 @@ class PMPluginRegistry
$this->save(); $this->save();
} }
function uninstallPlugin ($sNamespace) public function uninstallPlugin ($sNamespace)
{ {
$pluginFile = $sNamespace . ".php"; $pluginFile = $sNamespace . ".php";
@@ -472,7 +478,6 @@ class PMPluginRegistry
/////// ///////
$this->save(); $this->save();
/////// ///////
$pluginDir = PATH_PLUGINS . $detail->sPluginFolder; $pluginDir = PATH_PLUGINS . $detail->sPluginFolder;
@@ -485,16 +490,14 @@ class PMPluginRegistry
} }
/////// ///////
$this->uninstallPluginWorkspaces( array ($sNamespace $this->uninstallPluginWorkspaces( array ($sNamespace) );
) );
/////// ///////
break; break;
} }
} }
} }
function uninstallPluginWorkspaces ($arrayPlugin) public function uninstallPluginWorkspaces ($arrayPlugin)
{ {
G::LoadClass( "system" ); G::LoadClass( "system" );
G::LoadClass( "wsTools" ); G::LoadClass( "wsTools" );
@@ -509,7 +512,6 @@ class PMPluginRegistry
//Here we are loading all plug-ins registered //Here we are loading all plug-ins registered
//The singleton has a list of enabled plug-ins //The singleton has a list of enabled plug-ins
$pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginRegistry->unSerializeInstance( file_get_contents( $wsPathDataSite . "plugin.singleton" ) ); $pluginRegistry->unSerializeInstance( file_get_contents( $wsPathDataSite . "plugin.singleton" ) );
@@ -533,7 +535,7 @@ class PMPluginRegistry
* *
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
*/ */
function installPlugin ($sNamespace) public function installPlugin ($sNamespace)
{ {
try { try {
foreach ($this->_aPluginDetails as $namespace => $detail) { foreach ($this->_aPluginDetails as $namespace => $detail) {
@@ -561,12 +563,13 @@ class PMPluginRegistry
* @param unknown_type $sMenuId * @param unknown_type $sMenuId
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
function registerMenu ($sNamespace, $sMenuId, $sFilename) public function registerMenu ($sNamespace, $sMenuId, $sFilename)
{ {
$found = false; $found = false;
foreach ($this->_aMenus as $row => $detail) { foreach ($this->_aMenus as $row => $detail) {
if ($sMenuId == $detail->sMenuId && $sNamespace == $detail->sNamespace) if ($sMenuId == $detail->sMenuId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
} }
if (! $found) { if (! $found) {
$menuDetail = new menuDetail( $sNamespace, $sMenuId, $sFilename ); $menuDetail = new menuDetail( $sNamespace, $sMenuId, $sFilename );
@@ -579,7 +582,7 @@ class PMPluginRegistry
* *
* @param unknown_type $className * @param unknown_type $className
*/ */
function registerDashlets ($namespace) public function registerDashlets ($namespace)
{ {
$found = false; $found = false;
foreach ($this->_aDashlets as $row => $detail) { foreach ($this->_aDashlets as $row => $detail) {
@@ -598,7 +601,7 @@ class PMPluginRegistry
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
* @param unknown_type $sPage * @param unknown_type $sPage
*/ */
function registerCss ($sNamespace, $sCssFile) public function registerCss ($sNamespace, $sCssFile)
{ {
$found = false; $found = false;
foreach ($this->_aCSSStyleSheets as $row => $detail) { foreach ($this->_aCSSStyleSheets as $row => $detail) {
@@ -618,7 +621,7 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getRegisteredCss () public function getRegisteredCss ()
{ {
return $this->_aCSSStyleSheets; return $this->_aCSSStyleSheets;
} }
@@ -630,7 +633,7 @@ class PMPluginRegistry
* @param string $coreJsFile * @param string $coreJsFile
* @param array/string $pluginJsFile * @param array/string $pluginJsFile
*/ */
function registerJavascript ($sNamespace, $sCoreJsFile, $pluginJsFile) public function registerJavascript ($sNamespace, $sCoreJsFile, $pluginJsFile)
{ {
foreach ($this->_aJavascripts as $i => $js) { foreach ($this->_aJavascripts as $i => $js) {
@@ -639,7 +642,7 @@ class PMPluginRegistry
if (! in_array( $pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile )) { if (! in_array( $pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile )) {
$this->_aJavascripts[$i]->pluginJsFile[] = $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 ) ); $this->_aJavascripts[$i]->pluginJsFile = array_unique( array_merge( $pluginJsFile, $this->_aJavascripts[$i]->pluginJsFile ) );
} else { } else {
throw new Exception( 'Invalid third param, $pluginJsFile should be a string or array - ' . gettype( $pluginJsFile ) . ' given.' ); 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 )) { if (is_string( $pluginJsFile )) {
$js->pluginJsFile[] = $pluginJsFile; $js->pluginJsFile[] = $pluginJsFile;
} else if (is_array( $pluginJsFile )) { } elseif (is_array( $pluginJsFile )) {
$js->pluginJsFile = array_merge( $js->pluginJsFile, $pluginJsFile ); $js->pluginJsFile = array_merge( $js->pluginJsFile, $pluginJsFile );
} else { } else {
throw new Exception( 'Invalid third param, $pluginJsFile should be a string or array - ' . gettype( $pluginJsFile ) . ' given.' ); throw new Exception( 'Invalid third param, $pluginJsFile should be a string or array - ' . gettype( $pluginJsFile ) . ' given.' );
@@ -669,7 +672,7 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getRegisteredJavascript () public function getRegisteredJavascript ()
{ {
return $this->_aJavascripts; return $this->_aJavascripts;
} }
@@ -681,7 +684,7 @@ class PMPluginRegistry
* @param string $sNamespace * @param string $sNamespace
* @return array * @return array
*/ */
function getRegisteredJavascriptBy ($sCoreJsFile, $sNamespace = '') public function getRegisteredJavascriptBy ($sCoreJsFile, $sNamespace = '')
{ {
$scripts = array (); $scripts = array ();
@@ -708,9 +711,10 @@ class PMPluginRegistry
* @param string $sCoreJsFile * @param string $sCoreJsFile
* @return array * @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) { foreach ($this->_aJavascripts as $i => $js) {
if ($sNamespace == $js->sNamespace) { if ($sNamespace == $js->sNamespace) {
unset( $this->_aJavascripts[$i] ); unset( $this->_aJavascripts[$i] );
@@ -736,12 +740,13 @@ class PMPluginRegistry
* @param unknown_type $sMenuId * @param unknown_type $sMenuId
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
function registerReport ($sNamespace) public function registerReport ($sNamespace)
{ {
$found = false; $found = false;
foreach ($this->_aReports as $row => $detail) { foreach ($this->_aReports as $row => $detail) {
if ($sNamespace == $detail) if ($sNamespace == $detail) {
$found = true; $found = true;
}
} }
if (! $found) { if (! $found) {
$this->_aReports[] = $sNamespace; $this->_aReports[] = $sNamespace;
@@ -755,12 +760,13 @@ class PMPluginRegistry
* @param unknown_type $sMenuId * @param unknown_type $sMenuId
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
function registerPmFunction ($sNamespace) public function registerPmFunction ($sNamespace)
{ {
$found = false; $found = false;
foreach ($this->_aPmFunctions as $row => $detail) { foreach ($this->_aPmFunctions as $row => $detail) {
if ($sNamespace == $detail) if ($sNamespace == $detail) {
$found = true; $found = true;
}
} }
if (! $found) { if (! $found) {
$this->_aPmFunctions[] = $sNamespace; $this->_aPmFunctions[] = $sNamespace;
@@ -774,12 +780,14 @@ class PMPluginRegistry
* @param unknown_type $sRole * @param unknown_type $sRole
* @param unknown_type $sPath * @param unknown_type $sPath
*/ */
function registerRedirectLogin ($sNamespace, $sRole, $sPathMethod) public function registerRedirectLogin ($sNamespace, $sRole, $sPathMethod)
{ {
$found = false; $found = false;
foreach ($this->_aRedirectLogin as $row => $detail) { 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; $found = true;
}
} }
if (! $found) { if (! $found) {
$this->_aRedirectLogin[] = new redirectDetail( $sNamespace, $sRole, $sPathMethod ); $this->_aRedirectLogin[] = new redirectDetail( $sNamespace, $sRole, $sPathMethod );
@@ -791,12 +799,14 @@ class PMPluginRegistry
* *
* @param unknown_type $sFolderName * @param unknown_type $sFolderName
*/ */
function registerFolder ($sNamespace, $sFolderId, $sFolderName) public function registerFolder ($sNamespace, $sFolderId, $sFolderName)
{ {
$found = false; $found = false;
foreach ($this->_aFolders as $row => $detail) foreach ($this->_aFolders as $row => $detail) {
if ($sFolderId == $detail->sFolderId && $sNamespace == $detail->sNamespace) if ($sFolderId == $detail->sFolderId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
}
if (! $found) { if (! $found) {
$this->_aFolders[] = new folderDetail( $sNamespace, $sFolderId, $sFolderName ); $this->_aFolders[] = new folderDetail( $sNamespace, $sFolderId, $sFolderName );
@@ -808,12 +818,14 @@ class PMPluginRegistry
* *
* @param unknown_type $sFolderName * @param unknown_type $sFolderName
*/ */
function registerStep ($sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage = '') public function registerStep ($sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage = '')
{ {
$found = false; $found = false;
foreach ($this->_aSteps as $row => $detail) foreach ($this->_aSteps as $row => $detail) {
if ($sStepId == $detail->sStepId && $sNamespace == $detail->sNamespace) if ($sStepId == $detail->sStepId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
}
if (! $found) { if (! $found) {
$this->_aSteps[] = new stepDetail( $sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage ); $this->_aSteps[] = new stepDetail( $sNamespace, $sStepId, $sStepName, $sStepTitle, $setupStepPage );
@@ -825,7 +837,7 @@ class PMPluginRegistry
* *
* @param unknown_type $sFolderName * @param unknown_type $sFolderName
*/ */
function isRegisteredFolder ($sFolderName) public function isRegisteredFolder ($sFolderName)
{ {
foreach ($this->_aFolders as $row => $folder) { foreach ($this->_aFolders as $row => $folder) {
if ($sFolderName == $folder->sFolderName && is_dir( PATH_PLUGINS . $folder->sFolderName )) { if ($sFolderName == $folder->sFolderName && is_dir( PATH_PLUGINS . $folder->sFolderName )) {
@@ -842,7 +854,7 @@ class PMPluginRegistry
* *
* @param unknown_type $menuId * @param unknown_type $menuId
*/ */
function getMenus ($menuId) public function getMenus ($menuId)
{ {
foreach ($this->_aMenus as $row => $detail) { foreach ($this->_aMenus as $row => $detail) {
if ($menuId == $detail->sMenuId && file_exists( $detail->sFilename )) { if ($menuId == $detail->sMenuId && file_exists( $detail->sFilename )) {
@@ -856,7 +868,7 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getDashlets () public function getDashlets ()
{ {
return $this->_aDashlets; return $this->_aDashlets;
} }
@@ -866,7 +878,7 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getReports () public function getReports ()
{ {
return $this->_aReports; return $this->_aReports;
$report = array (); $report = array ();
@@ -881,7 +893,7 @@ class PMPluginRegistry
* This function returns all pmFunctions registered * This function returns all pmFunctions registered
* @ array * @ array
*/ */
function getPmFunctions () public function getPmFunctions ()
{ {
return $this->_aPmFunctions; return $this->_aPmFunctions;
$pmf = array (); $pmf = array ();
@@ -897,7 +909,7 @@ class PMPluginRegistry
* *
* @return string * @return string
*/ */
function getSteps () public function getSteps ()
{ {
return $this->_aSteps; return $this->_aSteps;
} }
@@ -907,7 +919,7 @@ class PMPluginRegistry
* *
* @return string * @return string
*/ */
function getRedirectLogins () public function getRedirectLogins ()
{ {
return $this->_aRedirectLogin; return $this->_aRedirectLogin;
} }
@@ -918,11 +930,10 @@ class PMPluginRegistry
* @param unknown_type $menuId * @param unknown_type $menuId
* @return object * @return object
*/ */
function executeTriggers ($triggerId, $oData) public function executeTriggers ($triggerId, $oData)
{ {
foreach ($this->_aTriggers as $row => $detail) { foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) { if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace //review all folders registered for this namespace
$found = false; $found = false;
$classFile = ''; $classFile = '';
@@ -945,8 +956,9 @@ class PMPluginRegistry
return; return;
} }
return $response; return $response;
} else } else {
print "error in call method " . $detail->sTriggerName; print "error in call method " . $detail->sTriggerName;
}
} }
} }
} }
@@ -956,12 +968,11 @@ class PMPluginRegistry
* *
* @param unknown_type $triggerId * @param unknown_type $triggerId
*/ */
function existsTrigger ($triggerId) public function existsTrigger ($triggerId)
{ {
$found = false; $found = false;
foreach ($this->_aTriggers as $row => $detail) { foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) { if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace //review all folders registered for this namespace
foreach ($this->_aFolders as $row => $folder) { foreach ($this->_aFolders as $row => $folder) {
$fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php'; $fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php';
@@ -980,12 +991,11 @@ class PMPluginRegistry
* @param unknown_type $triggerId * @param unknown_type $triggerId
* @return object * @return object
*/ */
function getTriggerInfo ($triggerId) public function getTriggerInfo ($triggerId)
{ {
$found = null; $found = null;
foreach ($this->_aTriggers as $row => $detail) { foreach ($this->_aTriggers as $row => $detail) {
if ($triggerId == $detail->sTriggerId) { if ($triggerId == $detail->sTriggerId) {
//review all folders registered for this namespace //review all folders registered for this namespace
foreach ($this->_aFolders as $row => $folder) { foreach ($this->_aFolders as $row => $folder) {
$fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php'; $fname = PATH_PLUGINS . $folder->sFolderName . PATH_SEP . 'class.' . $folder->sFolderName . '.php';
@@ -1005,12 +1015,13 @@ class PMPluginRegistry
* @param unknown_type $sMethodFunction * @param unknown_type $sMethodFunction
* @return void * @return void
*/ */
function registerTrigger ($sNamespace, $sTriggerId, $sTriggerName) public function registerTrigger ($sNamespace, $sTriggerId, $sTriggerName)
{ {
$found = false; $found = false;
foreach ($this->_aTriggers as $row => $detail) { foreach ($this->_aTriggers as $row => $detail) {
if ($sTriggerId == $detail->sTriggerId && $sNamespace == $detail->sNamespace) if ($sTriggerId == $detail->sTriggerId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
} }
if (! $found) { if (! $found) {
$triggerDetail = new triggerDetail( $sNamespace, $sTriggerId, $sTriggerName ); $triggerDetail = new triggerDetail( $sNamespace, $sTriggerId, $sTriggerName );
@@ -1024,25 +1035,25 @@ class PMPluginRegistry
* @param unknown_type $sNamespace * @param unknown_type $sNamespace
* @return void * @return void
*/ */
function &getPlugin ($sNamespace) public function &getPlugin ($sNamespace)
{ {
if (array_key_exists( $sNamespace, $this->_aPlugins )) { if (array_key_exists( $sNamespace, $this->_aPlugins )) {
return $this->_aPlugins[$sNamespace]; return $this->_aPlugins[$sNamespace];
} }
/* /*
$aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace); $aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace);
if (empty($aDetails)) { if (empty($aDetails)) {
return null; return null;
} }
$sFilename = $aDetails[2]; $sFilename = $aDetails[2];
if (!empty($sFilename)) { if (!empty($sFilename)) {
require_once($sFilename); require_once($sFilename);
} }
$sClassName = $aDetails[0]; $sClassName = $aDetails[0];
$oPlugin =& new $sClassName($sFilename); $oPlugin =& new $sClassName($sFilename);
$this->_aPlugins[$sNamespace] =& $oPlugin; $this->_aPlugins[$sNamespace] =& $oPlugin;
return $oPlugin; return $oPlugin;
*/ */
} }
/** /**
@@ -1052,12 +1063,13 @@ class PMPluginRegistry
* @param unknown_type $filename * @param unknown_type $filename
* @return void * @return void
*/ */
function setCompanyLogo ($sNamespace, $filename) public function setCompanyLogo ($sNamespace, $filename)
{ {
$found = false; $found = false;
foreach ($this->_aPluginDetails as $row => $detail) { foreach ($this->_aPluginDetails as $row => $detail) {
if ($sNamespace == $detail->sNamespace) if ($sNamespace == $detail->sNamespace) {
$this->_aPluginDetails[$sNamespace]->sCompanyLogo = $filename; $this->_aPluginDetails[$sNamespace]->sCompanyLogo = $filename;
}
} }
} }
@@ -1067,12 +1079,13 @@ class PMPluginRegistry
* @param unknown_type $default * @param unknown_type $default
* @return void * @return void
*/ */
function getCompanyLogo ($default) public function getCompanyLogo ($default)
{ {
$sCompanyLogo = $default; $sCompanyLogo = $default;
foreach ($this->_aPluginDetails as $row => $detail) { foreach ($this->_aPluginDetails as $row => $detail) {
if (trim( $detail->sCompanyLogo ) != '') if (trim( $detail->sCompanyLogo ) != '') {
$sCompanyLogo = $detail->sCompanyLogo; $sCompanyLogo = $detail->sCompanyLogo;
}
} }
return $sCompanyLogo; return $sCompanyLogo;
} }
@@ -1083,7 +1096,7 @@ class PMPluginRegistry
* @param unknown_type $default * @param unknown_type $default
* @return void * @return void
*/ */
function setupPlugins () public function setupPlugins ()
{ {
try { try {
$iPlugins = 0; $iPlugins = 0;
@@ -1099,8 +1112,9 @@ class PMPluginRegistry
$aux = explode( chr( 92 ), $detail->sFilename ); $aux = explode( chr( 92 ), $detail->sFilename );
} }
$sFilename = PATH_PLUGINS . $aux[count( $aux ) - 1]; $sFilename = PATH_PLUGINS . $aux[count( $aux ) - 1];
if (! file_exists( $sFilename )) if (! file_exists( $sFilename )) {
continue; continue;
}
require_once $sFilename; require_once $sFilename;
if (class_exists( $detail->sClassName )) { if (class_exists( $detail->sClassName )) {
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename ); $oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
@@ -1132,7 +1146,7 @@ class PMPluginRegistry
* @param object $oData * @param object $oData
* @return object * @return object
*/ */
function executeMethod ($sNamespace, $methodName, $oData) public function executeMethod ($sNamespace, $methodName, $oData)
{ {
$response = null; $response = null;
try { try {
@@ -1170,32 +1184,32 @@ class PMPluginRegistry
* @param string $sNamespace * @param string $sNamespace
* @return object * @return object
*/ */
function getFieldsForPageSetup ($sNamespace) public function getFieldsForPageSetup ($sNamespace)
{ {
$oData = NULL; $oData = null;
return $this->executeMethod( $sNamespace, 'getFieldsForPageSetup', $oData ); return $this->executeMethod( $sNamespace, 'getFieldsForPageSetup', $oData );
} }
/** /**
* this function updates Fields For Page on Setup * this function updates Fields For Page on Setup
* *
* @param string $sNamespace * @param string $sNamespace
* @return void * @return void
*/ */
function updateFieldsForPageSetup ($sNamespace, $oData) public function updateFieldsForPageSetup ($sNamespace, $oData)
{ {
if (! isset( $this->_aPluginDetails[$sNamespace] )) { if (! isset( $this->_aPluginDetails[$sNamespace] )) {
throw (new Exception( "The namespace '$sNamespace' doesn't exist in plugins folder." )); throw (new Exception( "The namespace '$sNamespace' doesn't exist in plugins folder." ));
} }
;
return $this->executeMethod( $sNamespace, 'updateFieldsForPageSetup', $oData ); return $this->executeMethod( $sNamespace, 'updateFieldsForPageSetup', $oData );
} }
function eevalidate () public function eevalidate ()
{ {
$fileL = PATH_DATA_SITE . 'license.dat'; $fileL = PATH_DATA_SITE . 'license.dat';
$fileS = PATH_DATA . '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' )) { if (class_exists( 'pmLicenseManager' )) {
$sSerializedFile = PATH_DATA_SITE . 'lmn.singleton'; $sSerializedFile = PATH_DATA_SITE . 'lmn.singleton';
$pmLicenseManagerO = & pmLicenseManager::getSingleton(); $pmLicenseManagerO = & pmLicenseManager::getSingleton();
@@ -1213,12 +1227,13 @@ class PMPluginRegistry
* @param unknown_type $sToolbarId * @param unknown_type $sToolbarId
* @param unknown_type $sFilename * @param unknown_type $sFilename
*/ */
function registerToolbarFile ($sNamespace, $sToolbarId, $sFilename) public function registerToolbarFile ($sNamespace, $sToolbarId, $sFilename)
{ {
$found = false; $found = false;
foreach ($this->_aToolbarFiles as $row => $detail) { foreach ($this->_aToolbarFiles as $row => $detail) {
if ($sToolbarId == $detail->sToolbarId && $sNamespace == $detail->sNamespace) if ($sToolbarId == $detail->sToolbarId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
} }
if (! $found) { if (! $found) {
$toolbarDetail = new toolbarDetail( $sNamespace, $sToolbarId, $sFilename ); $toolbarDetail = new toolbarDetail( $sNamespace, $sToolbarId, $sFilename );
@@ -1231,7 +1246,7 @@ class PMPluginRegistry
* *
* @param unknown_type $sToolbarId (NORMAL, GRID) * @param unknown_type $sToolbarId (NORMAL, GRID)
*/ */
function getToolbarOptions ($sToolbarId) public function getToolbarOptions ($sToolbarId)
{ {
foreach ($this->_aToolbarFiles as $row => $detail) { foreach ($this->_aToolbarFiles as $row => $detail) {
if ($sToolbarId == $detail->sToolbarId && file_exists( $detail->sFilename )) { if ($sToolbarId == $detail->sToolbarId && file_exists( $detail->sFilename )) {
@@ -1243,12 +1258,13 @@ class PMPluginRegistry
/** /**
* Register a Case Scheduler Plugin * Register a Case Scheduler Plugin
*/ */
function registerCaseSchedulerPlugin ($sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields) public function registerCaseSchedulerPlugin ($sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields)
{ {
$found = false; $found = false;
foreach ($this->_aCaseSchedulerPlugin as $row => $detail) foreach ($this->_aCaseSchedulerPlugin as $row => $detail)
if ($sActionId == $detail->sActionId && $sNamespace == $detail->sNamespace) if ($sActionId == $detail->sActionId && $sNamespace == $detail->sNamespace) {
$found = true; $found = true;
}
if (! $found) { if (! $found) {
$this->_aCaseSchedulerPlugin[] = new caseSchedulerPlugin( $sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields ); $this->_aCaseSchedulerPlugin[] = new caseSchedulerPlugin( $sNamespace, $sActionId, $sActionForm, $sActionSave, $sActionExecute, $sActionGetFields );
@@ -1260,7 +1276,7 @@ class PMPluginRegistry
* *
* @return string * @return string
*/ */
function getCaseSchedulerPlugins () public function getCaseSchedulerPlugins ()
{ {
return $this->_aCaseSchedulerPlugin; return $this->_aCaseSchedulerPlugin;
} }
@@ -1272,7 +1288,7 @@ class PMPluginRegistry
* @param unknown_type $sPage * @param unknown_type $sPage
*/ */
function registerTaskExtendedProperty ($sNamespace, $sPage, $sName, $sIcon) public function registerTaskExtendedProperty ($sNamespace, $sPage, $sName, $sIcon)
{ {
$found = false; $found = false;
foreach ($this->_aTaskExtendedProperties as $row => $detail) { foreach ($this->_aTaskExtendedProperties as $row => $detail) {
@@ -1296,7 +1312,7 @@ class PMPluginRegistry
* @param unknown_type $sName * @param unknown_type $sName
* @param unknown_type $sIcon * @param unknown_type $sIcon
*/ */
function registerDashboardPage ($sNamespace, $sPage, $sName, $sIcon) public function registerDashboardPage ($sNamespace, $sPage, $sName, $sIcon)
{ {
foreach ($this->_aDashboardPages as $row => $detail) { foreach ($this->_aDashboardPages as $row => $detail) {
if ($sPage == $detail->sPage && $sNamespace == $detail->sNamespace) { if ($sPage == $detail->sPage && $sNamespace == $detail->sNamespace) {
@@ -1355,7 +1371,6 @@ class PMPluginRegistry
unset( $this->_restServices[$i] ); unset( $this->_restServices[$i] );
} }
} }
// Re-index when all js were unregistered // Re-index when all js were unregistered
$this->_restServices = array_values( $this->_restServices ); $this->_restServices = array_values( $this->_restServices );
} }
@@ -1381,7 +1396,7 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getDashboardPages () public function getDashboardPages ()
{ {
return $this->_aDashboardPages; return $this->_aDashboardPages;
} }
@@ -1391,18 +1406,19 @@ class PMPluginRegistry
* *
* @return array * @return array
*/ */
function getTaskExtendedProperties () public function getTaskExtendedProperties ()
{ {
return $this->_aTaskExtendedProperties; return $this->_aTaskExtendedProperties;
} }
function registerDashboard () public function registerDashboard ()
{ {
// Dummy function for backwards compatibility // Dummy function for backwards compatibility
} }
function getAttributes () public function getAttributes ()
{ {
return get_object_vars( $this ); return get_object_vars( $this );
} }
} }

View File

@@ -8,63 +8,64 @@ require_once 'classes/model/om/BaseAppNotes.php';
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package classes.model * @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"); require_once ("classes/model/Users.php");
G::LoadClass('ArrayPeer'); G::LoadClass( 'ArrayPeer' );
$Criteria = new Criteria('workflow'); $Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns(); $Criteria->clearSelectColumns();
$Criteria->addSelectColumn(AppNotesPeer::APP_UID); $Criteria->addSelectColumn( AppNotesPeer::APP_UID );
$Criteria->addSelectColumn(AppNotesPeer::USR_UID); $Criteria->addSelectColumn( AppNotesPeer::USR_UID );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_DATE); $Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT); $Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE); $Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY); $Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ); $Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1); $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2); $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 );
$Criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS); $Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS );
$Criteria->addSelectColumn(UsersPeer::USR_USERNAME); $Criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$Criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $Criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
$Criteria->addSelectColumn(UsersPeer::USR_EMAIL); $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 != '') { 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(); $response = array ();
$totalCount = AppNotesPeer::doCount($Criteria); $totalCount = AppNotesPeer::doCount( $Criteria );
$response['totalCount'] = $totalCount; $response['totalCount'] = $totalCount;
$response['notes'] = array(); $response['notes'] = array ();
if ($start != '') { if ($start != '') {
$Criteria->setLimit($limit); $Criteria->setLimit( $limit );
$Criteria->setOffset($start); $Criteria->setOffset( $start );
} }
$oDataset = appNotesPeer::doSelectRS($Criteria); $oDataset = appNotesPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
while ($aRow = $oDataset->getRow()) { while ($aRow = $oDataset->getRow()) {
$aRow['NOTE_CONTENT'] = stripslashes($aRow['NOTE_CONTENT']); $aRow['NOTE_CONTENT'] = stripslashes( $aRow['NOTE_CONTENT'] );
$response['notes'][] = $aRow; $response['notes'][] = $aRow;
$oDataset->next(); $oDataset->next();
} }
@@ -75,203 +76,176 @@ class AppNotes extends BaseAppNotes {
return $result; return $result;
} }
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 );
function postNewNote($appUid, $usrUid, $noteContent, $notify=true, $noteAvalibility="PUBLIC", $noteRecipients="", $noteType="USER", $noteDate="now") { if ($this->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$this->setAppUid($appUid); $res = $this->save();
$this->setUsrUid($usrUid); $msg = '';
$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.
$res = $this->save();
$msg = '';
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $this->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
if ($msg != "") {
$response['success'] = 'failure';
$response['message'] = $msg;
} else {
$response['success'] = 'success';
$response['message'] = 'Saved...';
}
if ($notify) {
if ($noteRecipients == "") {
$noteRecipientsA = array();
G::LoadClass('case');
$oCase = new Cases ();
$p = $oCase->getUsersParticipatedInCase($appUid);
foreach($p['array'] as $key => $userParticipated){
$noteRecipientsA[]=$key;
}
$noteRecipients = implode(",", $noteRecipientsA);
}
$this->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
}
return $response;
}
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();
} else {
$aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
if ($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) {
$passwd = $auxPass[1];
} else {
array_shift($auxPass);
$passwd = implode('', $auxPass);
}
}
$aConfiguration['MESS_PASSWORD'] = $passwd;
} else { } else {
$aConfiguration = array(); // Something went wrong. We can now get the validationFailures and handle them.
} $msg = '';
} $validationFailuresArray = $this->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msg .= $objValidationFailure->getMessage() . "<br/>";
return false;
}
$oUser = new Users();
$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 ();
$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";
if ($sFrom == '') {
$sFrom = '"ProcessMaker"';
}
$hasEmailFrom = preg_match('/(.+)@(.+)\.(.+)/', $sFrom, $match);
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') . '>';
} else {
if ($aConfiguration['MESS_SERVER'] != '') {
if (($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER']))) {
$sFrom .= ' <info@' . $sAux . '>';
} else {
$sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
}
} else {
$sFrom .= ' <info@processmaker.com>';
} }
} //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
} }
} if ($msg != "") {
$response['success'] = 'failure';
$sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields); $response['message'] = $msg;
} else {
$response['success'] = 'success';
//erik: new behaviour for messages $response['message'] = 'Saved...';
//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'] != '') {
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
$fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
if ( ! file_exists ( $fileTemplate ) ) {
throw new Exception("Template file '$fileTemplate' does not exist.");
} }
$sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); if ($notify) {
} else {*/ if ($noteRecipients == "") {
$sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields)); $noteRecipientsA = array ();
/*}*/ G::LoadClass( 'case' );
$oCase = new Cases();
G::LoadClass('spool'); $p = $oCase->getUsersParticipatedInCase( $appUid );
$oUser = new Users(); foreach ($p['array'] as $key => $userParticipated) {
$noteRecipientsA[] = $key;
$recipientsArray=explode(",",$noteRecipients); }
$noteRecipients = implode( ",", $noteRecipientsA );
foreach($recipientsArray as $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'
));
if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
$oSpool->sendMail();
}
$this->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients );
} }
//Send derivation notification - End return $response;
}
} catch (Exception $oException) {
throw $oException; 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 ();
} else {
$aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' );
if ($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) {
$passwd = $auxPass[1];
} else {
array_shift( $auxPass );
$passwd = implode( '', $auxPass );
}
}
$aConfiguration['MESS_PASSWORD'] = $passwd;
} else {
$aConfiguration = array ();
}
}
if (! isset( $aConfiguration['MESS_ENABLED'] ) || $aConfiguration['MESS_ENABLED'] != '1') {
return false;
}
$oUser = new Users();
$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();
$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";
if ($sFrom == '') {
$sFrom = '"ProcessMaker"';
}
$hasEmailFrom = preg_match( '/(.+)@(.+)\.(.+)/', $sFrom, $match );
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' ) . '>';
} else {
if ($aConfiguration['MESS_SERVER'] != '') {
if (($sAux = @gethostbyaddr( $aConfiguration['MESS_SERVER'] ))) {
$sFrom .= ' <info@' . $sAux . '>';
} else {
$sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
}
} else {
$sFrom .= ' <info@processmaker.com>';
}
}
}
}
$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'] != '') {
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
$fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
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 ) );
/*}*/
G::LoadClass( 'spool' );
$oUser = new Users();
$recipientsArray = explode( ",", $noteRecipients );
foreach ($recipientsArray as $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') );
if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
$oSpool->sendMail();
}
}
//Send derivation notification - End
} catch (Exception $oException) {
throw $oException;
}
} }
}
} }

View File

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

View File

@@ -1,185 +1,166 @@
<?php <?php
/** /**
* Gateway.php * Gateway.php
* @package workflow.engine.classes.model *
* @package workflow.engine.classes.model
*/ */
require_once 'classes/model/om/BaseGateway.php'; require_once 'classes/model/om/BaseGateway.php';
/** /**
* Skeleton subclass for representing a row from the 'GATEWAY' table. * Skeleton subclass for representing a row from the 'GATEWAY' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Gateway extends BaseGateway { class Gateway extends BaseGateway
{
public function create ($aData) public function create ($aData)
{ {
$oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME); $oConnection = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try { try {
$sGatewayUID = G::generateUniqueID(); $sGatewayUID = G::generateUniqueID();
$aData['GAT_UID'] = $sGatewayUID; $aData['GAT_UID'] = $sGatewayUID;
$oGateway = new Gateway(); $oGateway = new Gateway();
$oGateway->fromArray($aData, BasePeer::TYPE_FIELDNAME); $oGateway->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oGateway->validate()) { if ($oGateway->validate()) {
$oConnection->begin(); $oConnection->begin();
$iResult = $oGateway->save(); $iResult = $oGateway->save();
$oConnection->commit(); $oConnection->commit();
return $sGatewayUID; return $sGatewayUID;
} } else {
else { $sMessage = '';
$sMessage = ''; $aValidationFailures = $oGateway->getValidationFailures();
$aValidationFailures = $oGateway->getValidationFailures(); foreach ($aValidationFailures as $oValidationFailure) {
foreach($aValidationFailures as $oValidationFailure) { $sMessage .= $oValidationFailure->getMessage() . '<br />';
$sMessage .= $oValidationFailure->getMessage() . '<br />'; }
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
} }
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
} }
catch (Exception $oError) {
$oConnection->rollback();
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);
return $aFields;
}
else {
throw(new Exception( "The row '" . $GatewayUid . "' in table Gateway doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
public function update($fields)
{
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try
{ {
$con->begin(); try {
$this->load($fields['GAT_UID']); $oRow = GatewayPeer::retrieveByPK( $GatewayUid );
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME); if (! is_null( $oRow )) {
if($this->validate()) $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
{ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$result=$this->save(); $this->setNew( false );
$con->commit(); return $aFields;
return $result; } else {
} throw (new Exception( "The row '" . $GatewayUid . "' in table Gateway doesn't exist!" ));
else }
{ } catch (Exception $oError) {
$con->rollback(); throw ($oError);
throw(new Exception("Failed Validation in class ".get_class($this).".")); }
}
} }
catch(Exception $e)
public function update ($fields)
{ {
$con->rollback(); $con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
throw($e); try {
$con->begin();
$this->load( $fields['GAT_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
} }
}
public function remove($GatewayUid) public function remove ($GatewayUid)
{
$oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try {
$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!'));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* verify if Gateway row specified in [GatUid] exists.
*
* @param string $sProUid the uid of the Prolication
*/
function gatewayExists ( $GatUid ) {
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try {
$oPro = GatewayPeer::retrieveByPk( $GatUid );
if ( is_object($oPro) && get_class ($oPro) == 'Gateway' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* create a new Gateway
*
* @param array $aData with new values
* @return void
*/
function createRow($aData)
{
$con = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try
{ {
$con->begin(); $oConnection = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME); $oGateWay = GatewayPeer::retrieveByPK( $GatewayUid );
if($this->validate()) if (! is_null( $oGateWay )) {
{ $oConnection->begin();
$this->setGatUid((isset($aData['GAT_UID']) ? $aData['GAT_UID']: '')); $iResult = $oGateWay->delete();
$this->setProUid((isset($aData['PRO_UID']) ? $aData['PRO_UID']: '')); $oConnection->commit();
$this->setTasUid((isset($aData['TAS_UID']) ? $aData['TAS_UID']: '')); //return $iResult;
$this->setGatNextTask((isset($aData['GAT_NEXT_TASK']) ? $aData['GAT_NEXT_TASK']: '')); return true;
$this->setGatX((isset($aData['GAT_X']) ? $aData['GAT_X']: '')); } else {
$this->setGatY((isset($aData['GAT_Y']) ? $aData['GAT_Y']: '')); throw (new Exception( 'This row does not exist!' ));
$this->save(); }
$con->commit(); } catch (Exception $oError) {
return; $oConnection->rollback();
} throw ($oError);
else }
{
$con->rollback();
$e=new Exception("Failed Validation in class ".get_class($this).".");
$e->aValidationFailures=$this->getValidationFailures();
throw($e);
}
} }
catch(Exception $e)
/**
* verify if Gateway row specified in [GatUid] exists.
*
* @param string $sProUid the uid of the Prolication
*/
public function gatewayExists ($GatUid)
{ {
$con->rollback(); $con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
throw($e); try {
$oPro = GatewayPeer::retrieveByPk( $GatUid );
if (is_object( $oPro ) && get_class( $oPro ) == 'Gateway') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
} }
}
} // Gateway /**
* create a new Gateway
*
* @param array $aData with new values
* @return void
*/
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->save();
$con->commit();
return;
} else {
$con->rollback();
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $this->getValidationFailures();
throw ($e);
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
}
// Gateway

View File

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

View File

@@ -1,166 +1,153 @@
<?php <?php
/** /**
* SubProcess.php * SubProcess.php
* @package workflow.engine.classes.model *
* @package workflow.engine.classes.model
*/ */
require_once 'classes/model/om/BaseSubProcess.php'; require_once 'classes/model/om/BaseSubProcess.php';
/** /**
* Skeleton subclass for representing a row from the 'SUB_PROCESS' table. * Skeleton subclass for representing a row from the 'SUB_PROCESS' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @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);
return $aFields;
}
else {
throw( new Exception( "The row '$SP_UID' in table SubProcess doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
public function create($aData)
{
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try
{ {
$con->begin(); try {
if ( isset ( $aData['SP_UID'] ) && $aData['SP_UID']== '' ) $oRow = SubProcessPeer::retrieveByPK( $SP_UID );
unset ( $aData['SP_UID'] ); if (! is_null( $oRow )) {
if ( !isset ( $aData['SP_UID'] ) ) $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->setSpUid(G::generateUniqueID()); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
else $this->setNew( false );
$this->setSpUid($aData['SP_UID'] ); return $aFields;
} else {
$this->setProUid($aData['PRO_UID']); throw (new Exception( "The row '$SP_UID' in table SubProcess doesn't exist!" ));
}
$this->setTasUid($aData['TAS_UID']); } catch (Exception $oError) {
throw ($oError);
$this->setProParent($aData['PRO_PARENT']); }
$this->setTasParent($aData['TAS_PARENT']);
$this->setSpType($aData['SP_TYPE']);
$this->setSpSynchronous($aData['SP_SYNCHRONOUS']);
$this->setSpSynchronousType($aData['SP_SYNCHRONOUS_TYPE']);
$this->setSpSynchronousWait($aData['SP_SYNCHRONOUS_WAIT']);
$this->setSpVariablesOut($aData['SP_VARIABLES_OUT']);
$this->setSpVariablesIn($aData['SP_VARIABLES_IN']);
$this->setSpGridIn($aData['SP_GRID_IN']);
if($this->validate())
{
$result=$this->save();
$con->commit();
return $result;
}
else
{
$con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
}
} }
catch(Exception $e)
public function create ($aData)
{ {
$con->rollback(); $con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
throw($e); try {
} $con->begin();
} if (isset( $aData['SP_UID'] ) && $aData['SP_UID'] == '') {
public function update($fields) unset( $aData['SP_UID'] );
{ }
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME); if (! isset( $aData['SP_UID'] )) {
try $this->setSpUid( G::generateUniqueID() );
{ } else {
$con->begin(); $this->setSpUid( $aData['SP_UID'] );
$this->load($fields['SP_UID']); }
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$result=$this->save();
$con->commit();
return $result;
}
else
{
$con->rollback();
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
$validationE->aValidationFailures = $this->getValidationFailures();
throw($validationE);
}
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
public function remove($SP_UID)
{
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try
{
$con->begin();
$oRepTab = SubProcessPeer::retrieveByPK( $SP_UID );
if (!is_null($oRepTab)) {
$result = $oRepTab->delete();
$con->commit();
}
return $result;
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
/** $this->setProUid( $aData['PRO_UID'] );
* verify if Trigger row specified in [sUid] exists.
*
* @param string $sUid the uid of the Prolication
*/
function subProcessExists ( $sUid ) { $this->setTasUid( $aData['TAS_UID'] );
$con = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
try { $this->setProParent( $aData['PRO_PARENT'] );
$oObj = SubProcessPeer::retrieveByPk( $sUid );
if (is_object($oObj) && get_class ($oObj) == 'SubProcess' ) { $this->setTasParent( $aData['TAS_PARENT'] );
return true;
} $this->setSpType( $aData['SP_TYPE'] );
else {
return false; $this->setSpSynchronous( $aData['SP_SYNCHRONOUS'] );
}
} $this->setSpSynchronousType( $aData['SP_SYNCHRONOUS_TYPE'] );
catch (Exception $oError) {
throw($oError); $this->setSpSynchronousWait( $aData['SP_SYNCHRONOUS_WAIT'] );
}
} $this->setSpVariablesOut( $aData['SP_VARIABLES_OUT'] );
$this->setSpVariablesIn( $aData['SP_VARIABLES_IN'] );
$this->setSpGridIn( $aData['SP_GRID_IN'] );
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
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();
$con->commit();
return $result;
} else {
$con->rollback();
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE->aValidationFailures = $this->getValidationFailures();
throw ($validationE);
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function remove ($SP_UID)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$con->begin();
$oRepTab = SubProcessPeer::retrieveByPK( $SP_UID );
if (! is_null( $oRepTab )) {
$result = $oRepTab->delete();
$con->commit();
}
return $result;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
/**
* verify if Trigger row specified in [sUid] exists.
*
* @param string $sUid the uid of the Prolication
*/
public function subProcessExists ($sUid)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try {
$oObj = SubProcessPeer::retrieveByPk( $sUid );
if (is_object( $oObj ) && get_class( $oObj ) == 'SubProcess') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
}
// SubProcess
} // SubProcess

View File

@@ -1,7 +1,8 @@
<?php <?php
/** /**
* SwimlanesElements.php * SwimlanesElements.php
* @package workflow.engine.classes.model *
* @package workflow.engine.classes.model
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
@@ -13,11 +14,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -33,205 +34,199 @@ require_once 'classes/model/Content.php';
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the input directory. * long as it does not already exist in the input directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class SwimlanesElements extends BaseSwimlanesElements { class SwimlanesElements extends BaseSwimlanesElements
{
/** /**
* This value goes in the content table * This value goes in the content table
* @var string *
*/ * @var string
protected $swi_text = ''; */
protected $swi_text = '';
/* /*
* Load the application document registry * Load the application document registry
* @param string $sAppDocUid * @param string $sAppDocUid
* @return variant * @return variant
*/ */
public function load($sSwiEleUid) public function load ($sSwiEleUid)
{ {
try { try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($sSwiEleUid); $oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (!is_null($oSwimlanesElements)) if (! is_null( $oSwimlanesElements )) {
{ $aFields = $oSwimlanesElements->toArray( BasePeer::TYPE_FIELDNAME );
$aFields = $oSwimlanesElements->toArray(BasePeer::TYPE_FIELDNAME); $aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText();
$aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText(); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); return $aFields;
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)
{
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
try {
$aData['SWI_UID'] = G::generateUniqueID();
$oSwimlanesElements = new SwimlanesElements();
$oSwimlanesElements->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset($aData['SWI_TEXT'])) {
$oSwimlanesElements->setSwiEleText($aData['SWI_TEXT']);
} }
$iResult = $oSwimlanesElements->save(); }
$oConnection->commit();
return $aData['SWI_UID']; /**
} * Create the application document registry
else { *
$sMessage = ''; * @param array $aData
$aValidationFailures = $oSwimlanesElements->getValidationFailures(); * @return string
foreach($aValidationFailures as $oValidationFailure) { *
$sMessage .= $oValidationFailure->getMessage() . '<br />'; */
public function create ($aData)
{
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$aData['SWI_UID'] = G::generateUniqueID();
$oSwimlanesElements = new SwimlanesElements();
$oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
return $aData['SWI_UID'];
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
} }
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
} }
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/** /**
* Update the application document registry * Update the application document registry
* @param array $aData *
* @return string * @param array $aData
**/ * @return string
public function update($aData) *
{ */
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME); public function update ($aData)
try { {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($aData['SWI_UID']); $oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
if (!is_null($oSwimlanesElements)) try {
{ $oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $aData['SWI_UID'] );
$oSwimlanesElements->fromArray($aData, BasePeer::TYPE_FIELDNAME); if (! is_null( $oSwimlanesElements )) {
if ($oSwimlanesElements->validate()) { $oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oConnection->begin(); if ($oSwimlanesElements->validate()) {
if (isset($aData['SWI_TEXT'])) $oConnection->begin();
{ if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText($aData['SWI_TEXT']); $oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
} }
$iResult = $oSwimlanesElements->save(); $iResult = $oSwimlanesElements->save();
$oConnection->commit(); $oConnection->commit();
return $iResult; return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
} }
else { }
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures(); /**
foreach($aValidationFailures as $oValidationFailure) { * Remove the application document registry
$sMessage .= $oValidationFailure->getMessage() . '<br />'; *
} * @param array $aData
throw(new Exception('The registry cannot be updated!<br />'.$sMessage)); * @return string
*
*/
public function remove ($sSwiEleUid)
{
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (! is_null( $oSwimlanesElements )) {
$oConnection->begin();
Content::removeContent( 'SWI_TEXT', '', $oSwimlanesElements->getSwiUid() );
$iResult = $oSwimlanesElements->delete();
$oConnection->commit();
return $iResult;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
} }
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
} }
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/** public function swimlanesElementsExists ($sSwiEleUid)
* Remove the application document registry {
* @param array $aData $con = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
* @return string try {
**/ $oSwiEleUid = SwimlanesElementsPeer::retrieveByPk( $sSwiEleUid );
public function remove($sSwiEleUid) if (is_object( $oSwiEleUid ) && get_class( $oSwiEleUid ) == 'SwimlanesElements') {
{ return true;
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME); } else {
try { return false;
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($sSwiEleUid); }
if (!is_null($oSwimlanesElements)) } catch (Exception $oError) {
{ throw ($oError);
$oConnection->begin(); }
Content::removeContent('SWI_TEXT', '', $oSwimlanesElements->getSwiUid());
$iResult = $oSwimlanesElements->delete();
$oConnection->commit();
return $iResult;
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
} }
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
function swimlanesElementsExists ( $sSwiEleUid ) { /**
$con = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME); * Get the [swi_text] column value.
try { *
$oSwiEleUid = SwimlanesElementsPeer::retrieveByPk( $sSwiEleUid ); * @return string
if (is_object($oSwiEleUid) && get_class ($oSwiEleUid) == 'SwimlanesElements' ) { */
return true; public function getSwiEleText ()
} {
else { if ($this->swi_text == '') {
return false; try {
} $this->swi_text = Content::load( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->swi_text;
} }
catch (Exception $oError) {
throw($oError);
}
}
/** /**
* Get the [swi_text] column value. * Set the [swi_text] column value.
* @return string *
*/ * @param string $sValue new value
public function getSwiEleText() * @return void
{ */
if ($this->swi_text == '') { public function setSwiEleText ($sValue)
try { {
$this->swi_text = Content::load('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en')); if ($sValue !== null && ! is_string( $sValue )) {
} $sValue = (string) $sValue;
catch (Exception $oError) { }
throw($oError); if ($this->swi_text !== $sValue || $sValue === '') {
} try {
} $this->swi_text = $sValue;
return $this->swi_text;
}
/** $iResult = Content::addContent( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->swi_text );
* Set the [swi_text] column value. } catch (Exception $oError) {
* $this->swi_text = '';
* @param string $sValue new value throw ($oError);
* @return void }
*/ }
public function setSwiEleText($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
} }
if ($this->swi_text !== $sValue || $sValue === '') { }
try { // SwimlanesElements
$this->swi_text = $sValue;
$iResult = Content::addContent('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->swi_text);
}
catch (Exception $oError) {
$this->swi_text = '';
throw($oError);
}
}
}
} // SwimlanesElements

View File

@@ -1,7 +1,8 @@
<?php <?php
/** /**
* TaskUser.php * TaskUser.php
* @package workflow.engine.classes.model *
* @package workflow.engine.classes.model
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc. * Copyright (C) 2004 - 2011 Colosa Inc.
@@ -13,11 +14,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -33,166 +34,165 @@ require_once 'classes/model/Content.php';
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the input directory. * long as it does not already exist in the input directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class TaskUser extends BaseTaskUser { class TaskUser extends BaseTaskUser
{
/** /**
* Create the application document registry * Create the application document registry
* @param array $aData *
* @return string * @param array $aData
**/ * @return string
public function create($aData) *
{ */
$oConnection = Propel::getConnection(TaskUserPeer::DATABASE_NAME); public function create ($aData)
try { {
$taskUser = TaskUserPeer::retrieveByPK($aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION']); $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) ) if (is_object( $taskUser )) {
return -1; return - 1;
}
$oTaskUser = new TaskUser(); $oTaskUser = new TaskUser();
$oTaskUser->fromArray($aData, BasePeer::TYPE_FIELDNAME); $oTaskUser->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oTaskUser->validate()) { if ($oTaskUser->validate()) {
$oConnection->begin(); $oConnection->begin();
$iResult = $oTaskUser->save(); $iResult = $oTaskUser->save();
$oConnection->commit(); $oConnection->commit();
return $iResult; return $iResult;
} } else {
else { $sMessage = '';
$sMessage = ''; $aValidationFailures = $oTaskUser->getValidationFailures();
$aValidationFailures = $oTaskUser->getValidationFailures(); foreach ($aValidationFailures as $oValidationFailure) {
foreach($aValidationFailures as $oValidationFailure) { $sMessage .= $oValidationFailure->getMessage() . '<br />';
$sMessage .= $oValidationFailure->getMessage() . '<br />'; }
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
} }
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
} }
catch (Exception $oError) {
$oConnection->rollback(); /**
throw($oError); * Remove the application document registry
*
* @param string $sTasUid
* @param string $sUserUid
* @return string
*
*/
public function remove ($sTasUid, $sUserUid, $iType, $iRelation)
{
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$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!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
} }
}
/** public function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation)
* Remove the application document registry {
* @param string $sTasUid $con = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
* @param string $sUserUid try {
* @return string $oTaskUser = TaskUserPeer::retrieveByPk( $sTasUid, $sUserUid, $iType, $iRelation );
**/ if (is_object( $oTaskUser ) && get_class( $oTaskUser ) == 'TaskUser') {
public function remove($sTasUid, $sUserUid, $iType, $iRelation) return true;
{ } else {
$oConnection = Propel::getConnection(TaskUserPeer::DATABASE_NAME); return false;
try { }
$oTaskUser = TaskUserPeer::retrieveByPK($sTasUid, $sUserUid, $iType, $iRelation); } catch (Exception $oError) {
if (!is_null($oTaskUser)) throw ($oError);
{ }
$oConnection->begin();
$iResult = $oTaskUser->delete();
$oConnection->commit();
return $iResult;
}
else {
throw(new Exception('This row does not exist!'));
}
} }
catch (Exception $oError) {
$oConnection->rollback(); public function getCountAllTaksByGroups ()
throw($oError); {
$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
public function getUsersTask ($TAS_UID, $TU_TYPE = 1)
{
require_once 'classes/model/Users.php';
function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation) { $groupsTask = array ();
$con = Propel::getConnection(TaskUserPeer::DATABASE_NAME); $usersTask = array ();
try {
$oTaskUser = TaskUserPeer::retrieveByPk($sTasUid, $sUserUid, $iType, $iRelation); //getting task's users
if ( is_object($oTaskUser) && get_class ($oTaskUser) == 'TaskUser' ) { $criteria = new Criteria( 'workflow' );
return true; $criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
} $criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
else { $criteria->addSelectColumn( UsersPeer::USR_USERNAME );
return false; $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 );
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 );
$dataset = TaskUserPeer::doSelectRS( $criteria );
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while ($dataset->next()) {
$usersTask[] = $dataset->getRow();
}
$result->data = $usersTask;
$result->totalCount = sizeof( $usersTask );
return $result;
} }
catch (Exception $oError) { }
throw($oError); // TaskUser
}
}
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){
require_once 'classes/model/Users.php';
$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);
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
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);
$dataset = TaskUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while( $dataset->next() )
$usersTask[] = $dataset->getRow();
$result->data = $usersTask;
$result->totalCount = sizeof($usersTask);
return $result;
}
} // TaskUser

File diff suppressed because it is too large Load Diff