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
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();
/* 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");
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");
}
}
?>
<?php
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 ();
/* 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.
*/
public 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" );
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" );
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,277 +1,251 @@
<?php
<?php
require_once 'classes/model/om/BaseAppNotes.php';
/**
* Skeleton subclass for representing a row from the 'APP_NOTES' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class AppNotes extends BaseAppNotes
{
public function getNotesList ($appUid, $usrUid = '', $start = '', $limit = '')
{
require_once ("classes/model/Users.php");
G::LoadClass( 'ArrayPeer' );
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn( AppNotesPeer::APP_UID );
$Criteria->addSelectColumn( AppNotesPeer::USR_UID );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS );
$Criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_EMAIL );
$Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
$Criteria->add( appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL );
if ($usrUid != '') {
$Criteria->add( appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL );
}
$Criteria->addDescendingOrderByColumn( AppNotesPeer::NOTE_DATE );
$response = array ();
$totalCount = AppNotesPeer::doCount( $Criteria );
$response['totalCount'] = $totalCount;
$response['notes'] = array ();
if ($start != '') {
$Criteria->setLimit( $limit );
$Criteria->setOffset( $start );
}
$oDataset = appNotesPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aRow['NOTE_CONTENT'] = stripslashes( $aRow['NOTE_CONTENT'] );
$response['notes'][] = $aRow;
$oDataset->next();
}
$result['criteria'] = $Criteria;
$result['array'] = $response;
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 );
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 {
$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'] != '') {
require_once 'classes/model/om/BaseAppNotes.php';
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
$fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
/**
* Skeleton subclass for representing a row from the 'APP_NOTES' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class AppNotes extends BaseAppNotes {
function getNotesList($appUid, $usrUid='', $start='', $limit='')
{
require_once ("classes/model/Users.php");
G::LoadClass('ArrayPeer');
$Criteria = new Criteria('workflow');
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn(AppNotesPeer::APP_UID);
$Criteria->addSelectColumn(AppNotesPeer::USR_UID);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_DATE);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2);
$Criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS);
$Criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$Criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
$Criteria->addSelectColumn(UsersPeer::USR_EMAIL);
$Criteria->addJoin(AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$Criteria->add(appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL);
if ($usrUid != '') {
$Criteria->add(appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL);
}
$Criteria->addDescendingOrderByColumn(AppNotesPeer::NOTE_DATE);
$response = array();
$totalCount = AppNotesPeer::doCount($Criteria);
$response['totalCount'] = $totalCount;
$response['notes'] = array();
if ($start != '') {
$Criteria->setLimit($limit);
$Criteria->setOffset($start);
}
$oDataset = appNotesPeer::doSelectRS($Criteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aRow['NOTE_CONTENT'] = stripslashes($aRow['NOTE_CONTENT']);
$response['notes'][] = $aRow;
$oDataset->next();
}
$result['criteria'] = $Criteria;
$result['array'] = $response;
return $result;
}
function postNewNote($appUid, $usrUid, $noteContent, $notify=true, $noteAvalibility="PUBLIC", $noteRecipients="", $noteType="USER", $noteDate="now") {
$this->setAppUid($appUid);
$this->setUsrUid($usrUid);
$this->setNoteDate($noteDate);
$this->setNoteContent($noteContent);
$this->setNoteType($noteType);
$this->setNoteAvailability($noteAvalibility);
$this->setNoteOriginObj('');
$this->setNoteAffectedObj1('');
$this->setNoteAffectedObj2('');
$this->setNoteRecipients($noteRecipients);
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 {
$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>';
if ( ! file_exists ( $fileTemplate ) ) {
throw new Exception("Template file '$fileTemplate' does not exist.");
}
}
}
}
$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;
}
}
}
$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,349 +1,351 @@
<?php
/**
* FieldCondition.php
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseFieldCondition.php';
require_once 'classes/model/Dynaform.php';
/**
* Skeleton subclass for representing a row from the 'FIELD_CONDITION' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class FieldCondition extends BaseFieldCondition {
var $oDynaformHandler;
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function get( $UID ) {
$obj = FieldConditionPeer::retrieveByPk($UID);
if( !isset($obj) ) {
throw new Exception("the record with UID: $UID doesn't exits!");
}
<?php
/**
* FieldCondition.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseFieldCondition.php';
require_once 'classes/model/Dynaform.php';
/**
* Skeleton subclass for representing a row from the 'FIELD_CONDITION' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class FieldCondition extends BaseFieldCondition
{
public $oDynaformHandler;
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function get ($UID)
{
$obj = FieldConditionPeer::retrieveByPk( $UID );
if (! isset( $obj )) {
throw new Exception( "the record with UID: $UID doesn't exits!" );
}
//TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
return $obj->toArray(BasePeer::TYPE_FIELDNAME);
}
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllCriteriaByDynUid( $DYN_UID, $filter='all' ) {
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_UID);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FUNCTION);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_FIELDS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_CONDITION);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENTS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_EVENT_OWNERS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_STATUS);
$oCriteria->addSelectColumn(FieldConditionPeer::FCD_DYN_UID);
$oCriteria->add(FieldConditionPeer::FCD_DYN_UID, $DYN_UID);
switch( $filter ) {
case 'active':
$oCriteria->add(FieldConditionPeer::FCD_STATUS, '1', Criteria::EQUAL);
break;
}
return $oCriteria;
}
/**
* Quick get all records into a associative array
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllByDynUid( $DYN_UID, $filter='all' ) {
$aRows = Array();
$oCriteria = $this->getAllCriteriaByDynUid($DYN_UID, $filter);
$oDataset = FieldConditionPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while( $aRow = $oDataset->getRow() ) {
$aRows[] = $aRow;
$oDataset->next();
}
return $aRows;
}
/**
* Quick save a record
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function quickSave($aData) {
$con = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
try {
$obj = null;
if( isset($aData['FCD_UID']) && trim($aData['FCD_UID']) != '' ) {
$obj = FieldConditionPeer::retrieveByPk($aData['FCD_UID']);
} else {
$aData['FCD_UID'] = G::generateUniqueID();
}
if (!is_object($obj)) {
$obj = new FieldCondition();
}
$obj->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($obj->validate()) {
$result = $obj->save();
$con->commit();
return $result;
} else {
$e = new Exception("Failed Validation in class " . get_class($this) . ".");
$e->aValidationFailures = $obj->getValidationFailures();
throw ($e);
}
} catch (exception $e) {
$con->rollback();
throw ($e);
}
}
function getConditionScript($DYN_UID) {
require_once 'classes/model/Dynaform.php';
G::LoadSystem('dynaformhandler');
$oDynaform = DynaformPeer::retrieveByPk($DYN_UID);
$PRO_UID = $oDynaform->getProUid();
$this->oDynaformHandler = new dynaFormHandler(PATH_DYNAFORM . "$PRO_UID/$DYN_UID" . '.xml');
$aDynaformFields = $this->oDynaformHandler->getFieldNames();
for ( $i = 0; $i < count($aDynaformFields); $i++ ) {
$aDynaformFields[$i] = "'$aDynaformFields[$i]'";
}
$sDynaformFieldsAsStrings = implode(',', $aDynaformFields);
$aRows = $this->getAllByDynUid($DYN_UID, 'active');
$sCode = '';
if( sizeof($aRows) != 0 ) {
foreach ( $aRows as $aRow ) {
$hashCond = md5($aRow['FCD_UID']);
$sCondition = $this->parseCondition($aRow['FCD_CONDITION']);
$sCondition = addslashes($sCondition);
$sCode .= "function __condition__$hashCond() { ";
$sCode .= "if( eval(\"{$sCondition}\") ) { ";
$aFields = explode(',', $aRow['FCD_FIELDS']);
switch( $aRow['FCD_FUNCTION'] ) {
case 'show':
foreach ( $aFields as $aField ) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showOnly':
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
foreach ( $aFields as $aField ) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showAll':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
break;
case 'hide':
foreach ( $aFields as $aField ) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideOnly':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
foreach ( $aFields as $aField ) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideAll':
$aDynaFields = array();
$aEventOwner = explode(',', $aRow['FCD_EVENT_OWNERS'] );
foreach($aDynaformFields as $sDynaformFields){
if(! in_array(str_replace("'", "", $sDynaformFields), $aEventOwner) ) {
$aDynaFields[] = $sDynaformFields;
}
}
$sDynaformFieldsAsStrings = implode(',', $aDynaFields);
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
break;
}
$sCode .= " } ";
$sCode .= "} ";
$aFieldOwners = explode(',', $aRow['FCD_EVENT_OWNERS']);
$aEvents = explode(',', $aRow['FCD_EVENTS']);
if( in_array('onchange', $aEvents) ) {
foreach ( $aFieldOwners as $aField ) {
return $obj->toArray( BasePeer::TYPE_FIELDNAME );
}
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllCriteriaByDynUid ($DYN_UID, $filter = 'all')
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_UID );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_FUNCTION );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_FIELDS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_CONDITION );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_EVENTS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_EVENT_OWNERS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_STATUS );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_DYN_UID );
$oCriteria->add( FieldConditionPeer::FCD_DYN_UID, $DYN_UID );
switch ($filter) {
case 'active':
$oCriteria->add( FieldConditionPeer::FCD_STATUS, '1', Criteria::EQUAL );
break;
}
return $oCriteria;
}
/**
* Quick get all records into a associative array
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllByDynUid ($DYN_UID, $filter = 'all')
{
$aRows = Array ();
$oCriteria = $this->getAllCriteriaByDynUid( $DYN_UID, $filter );
$oDataset = FieldConditionPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aRows[] = $aRow;
$oDataset->next();
}
return $aRows;
}
/**
* Quick save a record
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function quickSave ($aData)
{
$con = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$obj = null;
if (isset( $aData['FCD_UID'] ) && trim( $aData['FCD_UID'] ) != '') {
$obj = FieldConditionPeer::retrieveByPk( $aData['FCD_UID'] );
} else {
$aData['FCD_UID'] = G::generateUniqueID();
}
if (! is_object( $obj )) {
$obj = new FieldCondition();
}
$obj->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($obj->validate()) {
$result = $obj->save();
$con->commit();
return $result;
} else {
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $obj->getValidationFailures();
throw ($e);
}
} catch (exception $e) {
$con->rollback();
throw ($e);
}
}
public function getConditionScript ($DYN_UID)
{
require_once 'classes/model/Dynaform.php';
G::LoadSystem( 'dynaformhandler' );
$oDynaform = DynaformPeer::retrieveByPk( $DYN_UID );
$PRO_UID = $oDynaform->getProUid();
$this->oDynaformHandler = new dynaFormHandler( PATH_DYNAFORM . "$PRO_UID/$DYN_UID" . '.xml' );
$aDynaformFields = $this->oDynaformHandler->getFieldNames();
for ($i = 0; $i < count( $aDynaformFields ); $i ++) {
$aDynaformFields[$i] = "'$aDynaformFields[$i]'";
}
$sDynaformFieldsAsStrings = implode( ',', $aDynaformFields );
$aRows = $this->getAllByDynUid( $DYN_UID, 'active' );
$sCode = '';
if (sizeof( $aRows ) != 0) {
foreach ($aRows as $aRow) {
$hashCond = md5( $aRow['FCD_UID'] );
$sCondition = $this->parseCondition( $aRow['FCD_CONDITION'] );
$sCondition = addslashes( $sCondition );
$sCode .= "function __condition__$hashCond() { ";
$sCode .= "if( eval(\"{$sCondition}\") ) { ";
$aFields = explode( ',', $aRow['FCD_FIELDS'] );
switch ($aRow['FCD_FUNCTION']) {
case 'show':
foreach ($aFields as $aField) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showOnly':
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
foreach ($aFields as $aField) {
$sCode .= "showRowById('$aField');";
}
break;
case 'showAll':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
break;
case 'hide':
foreach ($aFields as $aField) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideOnly':
$sCode .= "showRowsById(Array($sDynaformFieldsAsStrings));";
foreach ($aFields as $aField) {
$sCode .= "hideRowById('$aField');";
}
break;
case 'hideAll':
$aDynaFields = array ();
$aEventOwner = explode( ',', $aRow['FCD_EVENT_OWNERS'] );
foreach ($aDynaformFields as $sDynaformFields) {
if (! in_array( str_replace( "'", "", $sDynaformFields ), $aEventOwner )) {
$aDynaFields[] = $sDynaformFields;
}
}
$sDynaformFieldsAsStrings = implode( ',', $aDynaFields );
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
break;
}
$sCode .= " } ";
$sCode .= "} ";
$aFieldOwners = explode( ',', $aRow['FCD_EVENT_OWNERS'] );
$aEvents = explode( ',', $aRow['FCD_EVENTS'] );
if (in_array( 'onchange', $aEvents )) {
foreach ($aFieldOwners as $aField) {
//verify the field type
$node = $this->oDynaformHandler->getNode($aField);
$nodeType = $node->getAttribute('type');
switch($nodeType){
case 'checkbox':
$sJSEvent = 'click';
break;
case 'text':
case 'textarea':
case 'currency':
case 'percentage':
$sJSEvent = 'blur';
break;
default:
$sJSEvent = 'change';
break;
}
$sCode .= "leimnud.event.add(getField('$aField'), '$sJSEvent', function() {";
$sCode .= " __condition__$hashCond(); ";
$sCode .= "}.extend(getField('$aField')));";
}
}
if( in_array('onload', $aEvents) ) {
foreach ( $aFieldOwners as $aField ) {
$sCode .= " __condition__$hashCond(); ";
}
}
}
return $sCode;
} else {
return NULL;
}
}
function parseCondition($sCondition) {
preg_match_all('/@#[a-zA-Z0-9_.]+/', $sCondition, $result);
if ( sizeof($result[0]) > 0 ) {
foreach( $result[0] as $fname ) {
preg_match_all('/(@#[a-zA-Z0-9_]+)\.([@#[a-zA-Z0-9_]+)/', $fname, $result2);
if( isset($result2[2][0]) && $result2[1][0]){
$sCondition = str_replace($fname, "getField('".str_replace('@#', '', $result2[1][0])."').".$result2[2][0], $sCondition);
} else {
$field = str_replace('@#', '', $fname);
$node = $this->oDynaformHandler->getNode($field);
if(isset($node)) {
$nodeType = $node->getAttribute('type');
switch($nodeType){
case 'checkbox':
$sAtt = 'checked';
break;
default:
$sAtt = 'value';
}
} else {
$sAtt = 'value';
}
$sCondition = str_replace($fname, "getField('".$field."').$sAtt", $sCondition);
}
}
}
return $sCondition;
}
public function create($aData) {
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
try {
$node = $this->oDynaformHandler->getNode( $aField );
$nodeType = $node->getAttribute( 'type' );
switch ($nodeType) {
case 'checkbox':
$sJSEvent = 'click';
break;
case 'text':
case 'textarea':
case 'currency':
case 'percentage':
$sJSEvent = 'blur';
break;
default:
$sJSEvent = 'change';
break;
}
$sCode .= "leimnud.event.add(getField('$aField'), '$sJSEvent', function() {";
$sCode .= " __condition__$hashCond(); ";
$sCode .= "}.extend(getField('$aField')));";
}
}
if (in_array( 'onload', $aEvents )) {
foreach ($aFieldOwners as $aField) {
$sCode .= " __condition__$hashCond(); ";
}
}
}
return $sCode;
} else {
return null;
}
}
public function parseCondition ($sCondition)
{
preg_match_all( '/@#[a-zA-Z0-9_.]+/', $sCondition, $result );
if (sizeof( $result[0] ) > 0) {
foreach ($result[0] as $fname) {
preg_match_all( '/(@#[a-zA-Z0-9_]+)\.([@#[a-zA-Z0-9_]+)/', $fname, $result2 );
if (isset( $result2[2][0] ) && $result2[1][0]) {
$sCondition = str_replace( $fname, "getField('" . str_replace( '@#', '', $result2[1][0] ) . "')." . $result2[2][0], $sCondition );
} else {
$field = str_replace( '@#', '', $fname );
$node = $this->oDynaformHandler->getNode( $field );
if (isset( $node )) {
$nodeType = $node->getAttribute( 'type' );
switch ($nodeType) {
case 'checkbox':
$sAtt = 'checked';
break;
default:
$sAtt = 'value';
}
} else {
$sAtt = 'value';
}
$sCondition = str_replace( $fname, "getField('" . $field . "').$sAtt", $sCondition );
}
}
}
return $sCondition;
}
public function create ($aData)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
// $aData['FCD_UID'] = '';
if ( isset ( $aData['FCD_UID'] ) && $aData['FCD_UID']== '' )
unset ( $aData['FCD_UID'] );
if ( !isset ( $aData['FCD_UID'] ) )
$aData['FCD_UID'] = G::generateUniqueID();
$oFieldCondition = new FieldCondition();
$oFieldCondition->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oFieldCondition->validate()) {
$oConnection->begin();
$iResult = $oFieldCondition->save();
$oConnection->commit();
return true;
} else {
$sMessage = '';
$aValidationFailures = $oFieldCondition->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);
}
}
public function remove($sUID) {
$oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
try {
$oConnection->begin();
$this->setFcdUid($sUID);
$iResult = $this->delete();
$oConnection->commit();
return $iResult;
} catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
function fieldConditionExists ( $sUid, $aDynaform ) {
try {
$found = false;
$obj = FieldConditionPeer::retrieveByPk( $sUid );
if( isset($obj) ) {
$aFields = $obj->toArray(BasePeer::TYPE_FIELDNAME);
foreach($aDynaform as $key => $row){
if($row['DYN_UID'] == $aFields['FCD_DYN_UID'])
$found = true;
}
}
if (isset( $aData['FCD_UID'] ) && $aData['FCD_UID'] == '') {
unset( $aData['FCD_UID'] );
}
if (! isset( $aData['FCD_UID'] )) {
$aData['FCD_UID'] = G::generateUniqueID();
}
$oFieldCondition = new FieldCondition();
$oFieldCondition->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oFieldCondition->validate()) {
$oConnection->begin();
$iResult = $oFieldCondition->save();
$oConnection->commit();
return true;
} else {
$sMessage = '';
$aValidationFailures = $oFieldCondition->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);
}
}
public function remove ($sUID)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$oConnection->begin();
$this->setFcdUid( $sUID );
$iResult = $this->delete();
$oConnection->commit();
return $iResult;
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
public function fieldConditionExists ($sUid, $aDynaform)
{
try {
$found = false;
$obj = FieldConditionPeer::retrieveByPk( $sUid );
if (isset( $obj )) {
$aFields = $obj->toArray( BasePeer::TYPE_FIELDNAME );
foreach ($aDynaform as $key => $row) {
if ($row['DYN_UID'] == $aFields['FCD_DYN_UID']) {
$found = true;
}
}
}
// return( get_class($obj) == 'FieldCondition') ;
return($found);
}
catch (Exception $oError) {
throw($oError);
}
}
function Exists ( $sUid ) {
try {
$obj = FieldConditionPeer::retrieveByPk( $sUid );
return(is_object($obj) && get_class($obj) == 'FieldCondition') ;
}
catch (Exception $oError) {
throw($oError);
}
}
} // FieldCondition
return ($found);
} catch (Exception $oError) {
throw ($oError);
}
}
public function Exists ($sUid)
{
try {
$obj = FieldConditionPeer::retrieveByPk( $sUid );
return (is_object( $obj ) && get_class( $obj ) == 'FieldCondition');
} catch (Exception $oError) {
throw ($oError);
}
}
}
// FieldCondition

View File

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

View File

@@ -1,166 +1,153 @@
<?php
/**
* SubProcess.php
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseSubProcess.php';
/**
* Skeleton subclass for representing a row from the 'SUB_PROCESS' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class SubProcess extends BaseSubProcess {
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();
if ( isset ( $aData['SP_UID'] ) && $aData['SP_UID']== '' )
unset ( $aData['SP_UID'] );
if ( !isset ( $aData['SP_UID'] ) )
$this->setSpUid(G::generateUniqueID());
else
$this->setSpUid($aData['SP_UID'] );
$this->setProUid($aData['PRO_UID']);
$this->setTasUid($aData['TAS_UID']);
$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)
{
$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
*/
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
<?php
/**
* SubProcess.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseSubProcess.php';
/**
* Skeleton subclass for representing a row from the 'SUB_PROCESS' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class SubProcess extends BaseSubProcess
{
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();
if (isset( $aData['SP_UID'] ) && $aData['SP_UID'] == '') {
unset( $aData['SP_UID'] );
}
if (! isset( $aData['SP_UID'] )) {
$this->setSpUid( G::generateUniqueID() );
} else {
$this->setSpUid( $aData['SP_UID'] );
}
$this->setProUid( $aData['PRO_UID'] );
$this->setTasUid( $aData['TAS_UID'] );
$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) {
$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

View File

@@ -1,237 +1,232 @@
<?php
/**
* SwimlanesElements.php
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once 'classes/model/om/BaseSwimlanesElements.php';
require_once 'classes/model/Content.php';
/**
* Skeleton subclass for representing a row from the 'SWIMLANES_ELEMENTS' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the input directory.
*
* @package workflow.engine.classes.model
*/
class SwimlanesElements extends BaseSwimlanesElements {
/**
* This value goes in the content table
* @var string
*/
protected $swi_text = '';
/*
<?php
/**
* SwimlanesElements.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once 'classes/model/om/BaseSwimlanesElements.php';
require_once 'classes/model/Content.php';
/**
* Skeleton subclass for representing a row from the 'SWIMLANES_ELEMENTS' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the input directory.
*
* @package workflow.engine.classes.model
*/
class SwimlanesElements extends BaseSwimlanesElements
{
/**
* This value goes in the content table
*
* @var string
*/
protected $swi_text = '';
/*
* Load the application document registry
* @param string $sAppDocUid
* @return variant
*/
public function load($sSwiEleUid)
{
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($sSwiEleUid);
if (!is_null($oSwimlanesElements))
{
$aFields = $oSwimlanesElements->toArray(BasePeer::TYPE_FIELDNAME);
$aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText();
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
return $aFields;
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
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'];
}
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);
}
}
/**
* Update the application document registry
* @param array $aData
* @return string
**/
public function update($aData)
{
$oConnection = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK($aData['SWI_UID']);
if (!is_null($oSwimlanesElements))
{
$oSwimlanesElements->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset($aData['SWI_TEXT']))
{
$oSwimlanesElements->setSwiEleText($aData['SWI_TEXT']);
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
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);
}
}
/**
* Remove the application document registry
* @param array $aData
* @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);
}
}
function swimlanesElementsExists ( $sSwiEleUid ) {
$con = Propel::getConnection(SwimlanesElementsPeer::DATABASE_NAME);
try {
$oSwiEleUid = SwimlanesElementsPeer::retrieveByPk( $sSwiEleUid );
if (is_object($oSwiEleUid) && get_class ($oSwiEleUid) == 'SwimlanesElements' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Get the [swi_text] column value.
* @return string
*/
public function getSwiEleText()
{
if ($this->swi_text == '') {
try {
$this->swi_text = Content::load('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
}
catch (Exception $oError) {
throw($oError);
}
}
return $this->swi_text;
}
/**
* Set the [swi_text] column value.
*
* @param string $sValue new value
* @return void
*/
public function setSwiEleText($sValue)
{
if ($sValue !== null && !is_string($sValue)) {
$sValue = (string)$sValue;
}
if ($this->swi_text !== $sValue || $sValue === '') {
try {
$this->swi_text = $sValue;
$iResult = Content::addContent('SWI_TEXT', '', $this->getSwiUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->swi_text);
}
catch (Exception $oError) {
$this->swi_text = '';
throw($oError);
}
}
}
} // SwimlanesElements
*/
public function load ($sSwiEleUid)
{
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (! is_null( $oSwimlanesElements )) {
$aFields = $oSwimlanesElements->toArray( BasePeer::TYPE_FIELDNAME );
$aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText();
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} 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'];
} 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);
}
}
/**
* Update the application document registry
*
* @param array $aData
* @return string
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $aData['SWI_UID'] );
if (! is_null( $oSwimlanesElements )) {
$oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
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);
}
}
/**
* Remove the application document registry
*
* @param array $aData
* @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);
}
}
public function swimlanesElementsExists ($sSwiEleUid)
{
$con = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
try {
$oSwiEleUid = SwimlanesElementsPeer::retrieveByPk( $sSwiEleUid );
if (is_object( $oSwiEleUid ) && get_class( $oSwiEleUid ) == 'SwimlanesElements') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Get the [swi_text] column value.
*
* @return string
*/
public function getSwiEleText ()
{
if ($this->swi_text == '') {
try {
$this->swi_text = Content::load( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
} catch (Exception $oError) {
throw ($oError);
}
}
return $this->swi_text;
}
/**
* Set the [swi_text] column value.
*
* @param string $sValue new value
* @return void
*/
public function setSwiEleText ($sValue)
{
if ($sValue !== null && ! is_string( $sValue )) {
$sValue = (string) $sValue;
}
if ($this->swi_text !== $sValue || $sValue === '') {
try {
$this->swi_text = $sValue;
$iResult = Content::addContent( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->swi_text );
} catch (Exception $oError) {
$this->swi_text = '';
throw ($oError);
}
}
}
}
// SwimlanesElements

View File

@@ -1,198 +1,198 @@
<?php
/**
* TaskUser.php
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once 'classes/model/om/BaseTaskUser.php';
require_once 'classes/model/Content.php';
/**
* Skeleton subclass for representing a row from the 'GROUP_USER' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the input directory.
*
* @package workflow.engine.classes.model
*/
class TaskUser extends BaseTaskUser {
/**
* Create the application document registry
* @param array $aData
* @return string
**/
public function create($aData)
{
$oConnection = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
try {
$taskUser = TaskUserPeer::retrieveByPK($aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION']);
if( is_object($taskUser) )
return -1;
$oTaskUser = new TaskUser();
$oTaskUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oTaskUser->validate()) {
$oConnection->begin();
$iResult = $oTaskUser->save();
$oConnection->commit();
return $iResult;
}
else {
$sMessage = '';
$aValidationFailures = $oTaskUser->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);
}
}
/**
* 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);
}
}
function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation) {
$con = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
try {
$oTaskUser = TaskUserPeer::retrieveByPk($sTasUid, $sUserUid, $iType, $iRelation);
if ( is_object($oTaskUser) && get_class ($oTaskUser) == 'TaskUser' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
function getCountAllTaksByGroups(){
$oCriteria = new Criteria('workflow');
$oCriteria->addAsColumn('GRP_UID', TaskUserPeer::USR_UID);
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->add(TaskUserPeer::TU_TYPE,1);
$oCriteria->add(TaskUserPeer::TU_RELATION,2);
$oCriteria->addGroupByColumn(TaskUserPeer::USR_UID);
$oDataset = TaskUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode (ResultSet::FETCHMODE_ASSOC);
$aRows = Array();
while ($oDataset->next()){
$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
<?php
/**
* TaskUser.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once 'classes/model/om/BaseTaskUser.php';
require_once 'classes/model/Content.php';
/**
* Skeleton subclass for representing a row from the 'GROUP_USER' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the input directory.
*
* @package workflow.engine.classes.model
*/
class TaskUser extends BaseTaskUser
{
/**
* Create the application document registry
*
* @param array $aData
* @return string
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$taskUser = TaskUserPeer::retrieveByPK( $aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION'] );
if (is_object( $taskUser )) {
return - 1;
}
$oTaskUser = new TaskUser();
$oTaskUser->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oTaskUser->validate()) {
$oConnection->begin();
$iResult = $oTaskUser->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oTaskUser->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);
}
}
/**
* 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)
{
$con = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$oTaskUser = TaskUserPeer::retrieveByPk( $sTasUid, $sUserUid, $iType, $iRelation );
if (is_object( $oTaskUser ) && get_class( $oTaskUser ) == 'TaskUser') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
public function getCountAllTaksByGroups ()
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addAsColumn( 'GRP_UID', TaskUserPeer::USR_UID );
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
$oCriteria->add( TaskUserPeer::TU_TYPE, 1 );
$oCriteria->add( TaskUserPeer::TU_RELATION, 2 );
$oCriteria->addGroupByColumn( TaskUserPeer::USR_UID );
$oDataset = TaskUserPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aRows = Array ();
while ($oDataset->next()) {
$row = $oDataset->getRow();
$aRows[$row['GRP_UID']] = $row['CNT'];
}
return $aRows;
}
//erik: new functions
public 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