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,28 +1,29 @@
<?php
G::LoadSystem( 'dbMaintenance' );
G::LoadClass( "cli" );
/** Class MultipleFilesBackup
/**
* Class MultipleFilesBackup
* create a backup of this workspace
*
* Exports the database and copies the files to an tar archive o several if the max filesize is reached.
*
*/
class multipleFilesBackup{
class multipleFilesBackup
{
private $dir_to_compress = "";
private $filename = "backUpProcessMaker.tar";
private $fileSize = "1000"; // 1 GB by default.
private $sizeDescriptor = "m"; //megabytes
private $fileSize = "1000";
// 1 GB by default.
private $sizeDescriptor = "m";
//megabytes
private $tempDirectories = array ();
/* Constructor
* @filename contains the path and filename of the comppress file(s).
* @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size.
*/
function multipleFilesBackup($filename,$size)
public function multipleFilesBackup ($filename, $size)
{
if (! empty( $filename )) {
$this->filename = $filename;
@@ -31,6 +32,7 @@ class multipleFilesBackup{
$this->fileSize = $size;
}
}
/* Gets workspace information enough to make its backup.
* @workspace contains the workspace to be add to the commpression process.
*/
@@ -53,9 +55,7 @@ class multipleFilesBackup{
$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)))) {
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" );
@@ -75,8 +75,8 @@ class multipleFilesBackup{
}
}
/* Commpress the DB and files into a single or several files with numerical series extentions
*/
// Commpress the DB and files into a single or several files with numerical series extentions
public function letsBackup ()
{
// creating command
@@ -89,8 +89,7 @@ class multipleFilesBackup{
//executing command to create the files
echo exec( $CommpressCommand );
//Remove leftovers dirs.
foreach($this->tempDirectories as $tempDirectory)
{
foreach ($this->tempDirectories as $tempDirectory) {
CLI::logging( "Deleting: " . $tempDirectory . "\n" );
G::rm_dir( $tempDirectory );
}
@@ -101,12 +100,11 @@ class multipleFilesBackup{
* @ dstWorkspace contains the workspace to be overwriting.
* @ overwrite got the option true if the workspace will be overwrite.
*/
static public function letsRestore($filename, $srcWorkspace, $dstWorkspace = NULL, $overwrite = true)
static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
{
// Needed info:
// TEMPDIR /shared/workflow_data/upgrade/
// BACKUPS /shared/workflow_data/backups/
// Creating command cat myfiles_split.tgz_* | tar xz
$DecommpressCommand = "cat " . $filename . ".* ";
$DecommpressCommand .= " | tar xzv";
@@ -130,12 +128,10 @@ class multipleFilesBackup{
$metaFiles = glob( $tempDirectory . "/*.txt" );
if (! empty( $metaFiles )) {
return workspaceTools::restoreLegacy( $tempDirectory );
}
else{
} else {
throw new Exception( "No metadata found in backup" );
}
}
else {
} else {
CLI::logging( "Found " . count( $metaFiles ) . " workspaces in backup:\n" );
foreach ($metaFiles as $metafile) {
CLI::logging( "-> " . basename( $metafile ) . "\n" );
@@ -156,24 +152,21 @@ class multipleFilesBackup{
if (isset( $dstWorkspace )) {
$workspaceName = $dstWorkspace;
$createWorkspace = true;
}
else {
} else {
$workspaceName = $metadata->WORKSPACE_NAME;
$createWorkspace = false;
}
if (isset( $srcWorkspace ) && strcmp( $metadata->WORKSPACE_NAME, $srcWorkspace ) != 0) {
CLI::logging( CLI::warning( "> Workspace $backupWorkspace found, but not restoring." ) . "\n" );
continue;
}
else {
} 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{
} else {
throw new Exception( "Destination workspace already exist (use -o to overwrite)" );
}
}
@@ -191,8 +184,7 @@ class multipleFilesBackup{
$shared_stat = stat( PATH_DATA );
if ($shared_stat !== false) {
workspaceTools::dirPerms( $workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode'] );
}
else{
} else {
CLI::logging( CLI::error( "Could not get the shared folder permissions, not changing workspace permissions" ) . "\n" );
}
@@ -224,4 +216,3 @@ class multipleFilesBackup{
}
}
?>

View File

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

View File

@@ -13,9 +13,10 @@ require_once 'classes/model/om/BaseAppNotes.php';
*
* @package classes.model
*/
class AppNotes extends BaseAppNotes {
class AppNotes extends BaseAppNotes
{
function getNotesList($appUid, $usrUid='', $start='', $limit='')
public function getNotesList ($appUid, $usrUid = '', $start = '', $limit = '')
{
require_once ("classes/model/Users.php");
@@ -75,9 +76,8 @@ class AppNotes extends BaseAppNotes {
return $result;
}
function postNewNote($appUid, $usrUid, $noteContent, $notify=true, $noteAvalibility="PUBLIC", $noteRecipients="", $noteType="USER", $noteDate="now") {
public function postNewNote ($appUid, $usrUid, $noteContent, $notify = true, $noteAvalibility = "PUBLIC", $noteRecipients = "", $noteType = "USER", $noteDate = "now")
{
$this->setAppUid( $appUid );
$this->setUsrUid( $usrUid );
$this->setNoteDate( $noteDate );
@@ -115,7 +115,6 @@ class AppNotes extends BaseAppNotes {
$noteRecipientsA = array ();
G::LoadClass( 'case' );
$oCase = new Cases();
$p = $oCase->getUsersParticipatedInCase( $appUid );
foreach ($p['array'] as $key => $userParticipated) {
$noteRecipientsA[] = $key;
@@ -129,7 +128,8 @@ class AppNotes extends BaseAppNotes {
return $response;
}
public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom="") {
public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
{
try {
require_once ('classes/model/Configuration.php');
$oConfiguration = new Configuration();
@@ -206,7 +206,6 @@ class AppNotes extends BaseAppNotes {
$sSubject = G::replaceDataField( $configNoteNotification['subject'], $aFields );
//erik: new behaviour for messages
//G::loadClass('configuration');
//$oConf = new Configurations;
@@ -222,15 +221,12 @@ class AppNotes extends BaseAppNotes {
if ( ! file_exists ( $fileTemplate ) ) {
throw new Exception("Template file '$fileTemplate' does not exist.");
}
$sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
} else {*/
$sBody = nl2br( G::replaceDataField( $configNoteNotification['body'], $aFields ) );
/*}*/
G::LoadClass( 'spool' );
$oUser = new Users();
$recipientsArray = explode( ",", $noteRecipients );
foreach ($recipientsArray as $recipientUid) {
@@ -238,40 +234,18 @@ class AppNotes extends BaseAppNotes {
$aUser = $oUser->load( $recipientUid );
$sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
$oSpool = new spoolRun();
$oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],
'MESS_SERVER' => $aConfiguration['MESS_SERVER'],
'MESS_PORT' => $aConfiguration['MESS_PORT'],
'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],
'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],
'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,
'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''
));
$oSpool->create(array('msg_uid' => '',
'app_uid' => $appUid,
'del_index' => 1,
'app_msg_type' => 'DERIVATION',
'app_msg_subject' => $sSubject,
'app_msg_from' => $sFrom,
'app_msg_to' => $sTo,
'app_msg_body' => $sBody,
'app_msg_cc' => '',
'app_msg_bcc' => '',
'app_msg_attach' => '',
'app_msg_template' => '',
'app_msg_status' => 'pending'
));
$oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') );
$oSpool->create( array ('msg_uid' => '','app_uid' => $appUid,'del_index' => 1,'app_msg_type' => 'DERIVATION','app_msg_subject' => $sSubject,'app_msg_from' => $sFrom,'app_msg_to' => $sTo,'app_msg_body' => $sBody,'app_msg_cc' => '','app_msg_bcc' => '','app_msg_attach' => '','app_msg_template' => '','app_msg_status' => 'pending') );
if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) {
$oSpool->sendMail();
}
}
//Send derivation notification - End
} catch (Exception $oException) {
throw $oException;
}
}
}

View File

@@ -1,13 +1,13 @@
<?php
/**
* FieldCondition.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseFieldCondition.php';
require_once 'classes/model/Dynaform.php';
/**
* Skeleton subclass for representing a row from the 'FIELD_CONDITION' table.
*
@@ -19,15 +19,18 @@ require_once 'classes/model/Dynaform.php';
*
* @package workflow.engine.classes.model
*/
class FieldCondition extends BaseFieldCondition {
class FieldCondition extends BaseFieldCondition
{
public $oDynaformHandler;
var $oDynaformHandler;
/**
* Quick get all records into a criteria object
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function get( $UID ) {
public function get ($UID)
{
$obj = FieldConditionPeer::retrieveByPk( $UID );
if (! isset( $obj )) {
@@ -42,7 +45,8 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllCriteriaByDynUid( $DYN_UID, $filter='all' ) {
public function getAllCriteriaByDynUid ($DYN_UID, $filter = 'all')
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_UID );
$oCriteria->addSelectColumn( FieldConditionPeer::FCD_FUNCTION );
@@ -68,7 +72,8 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function getAllByDynUid( $DYN_UID, $filter='all' ) {
public function getAllByDynUid ($DYN_UID, $filter = 'all')
{
$aRows = Array ();
$oCriteria = $this->getAllCriteriaByDynUid( $DYN_UID, $filter );
@@ -90,7 +95,8 @@ class FieldCondition extends BaseFieldCondition {
*
* @author Erik A. Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/
public function quickSave($aData) {
public function quickSave ($aData)
{
$con = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$obj = null;
@@ -123,7 +129,8 @@ class FieldCondition extends BaseFieldCondition {
}
}
function getConditionScript($DYN_UID) {
public function getConditionScript ($DYN_UID)
{
require_once 'classes/model/Dynaform.php';
G::LoadSystem( 'dynaformhandler' );
@@ -142,7 +149,6 @@ class FieldCondition extends BaseFieldCondition {
$sCode = '';
if (sizeof( $aRows ) != 0) {
foreach ($aRows as $aRow) {
$hashCond = md5( $aRow['FCD_UID'] );
$sCondition = $this->parseCondition( $aRow['FCD_CONDITION'] );
@@ -159,31 +165,26 @@ class FieldCondition extends BaseFieldCondition {
$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'] );
@@ -194,7 +195,6 @@ class FieldCondition extends BaseFieldCondition {
}
$sDynaformFieldsAsStrings = implode( ',', $aDynaFields );
$sCode .= "hideRowsById(Array($sDynaformFieldsAsStrings));";
break;
}
$sCode .= " } ";
@@ -218,7 +218,6 @@ class FieldCondition extends BaseFieldCondition {
case 'percentage':
$sJSEvent = 'blur';
break;
default:
$sJSEvent = 'change';
break;
@@ -236,14 +235,14 @@ class FieldCondition extends BaseFieldCondition {
}
}
return $sCode;
} else {
return NULL;
return null;
}
}
function parseCondition($sCondition) {
public function parseCondition ($sCondition)
{
preg_match_all( '/@#[a-zA-Z0-9_.]+/', $sCondition, $result );
if (sizeof( $result[0] ) > 0) {
foreach ($result[0] as $fname) {
@@ -271,16 +270,17 @@ class FieldCondition extends BaseFieldCondition {
}
return $sCondition;
}
public function create($aData) {
public function create ($aData)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
// $aData['FCD_UID'] = '';
if ( isset ( $aData['FCD_UID'] ) && $aData['FCD_UID']== '' )
if (isset( $aData['FCD_UID'] ) && $aData['FCD_UID'] == '') {
unset( $aData['FCD_UID'] );
if ( !isset ( $aData['FCD_UID'] ) )
}
if (! isset( $aData['FCD_UID'] )) {
$aData['FCD_UID'] = G::generateUniqueID();
}
$oFieldCondition = new FieldCondition();
$oFieldCondition->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oFieldCondition->validate()) {
@@ -302,8 +302,8 @@ class FieldCondition extends BaseFieldCondition {
}
}
public function remove($sUID) {
public function remove ($sUID)
{
$oConnection = Propel::getConnection( FieldConditionPeer::DATABASE_NAME );
try {
$oConnection->begin();
@@ -317,33 +317,35 @@ class FieldCondition extends BaseFieldCondition {
}
}
function fieldConditionExists ( $sUid, $aDynaform ) {
public function fieldConditionExists ($sUid, $aDynaform)
{
try {
$found = false;
$obj = FieldConditionPeer::retrieveByPk( $sUid );
if (isset( $obj )) {
$aFields = $obj->toArray( BasePeer::TYPE_FIELDNAME );
foreach ($aDynaform as $key => $row) {
if($row['DYN_UID'] == $aFields['FCD_DYN_UID'])
if ($row['DYN_UID'] == $aFields['FCD_DYN_UID']) {
$found = true;
}
}
}
// return( get_class($obj) == 'FieldCondition') ;
return ($found);
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
function Exists ( $sUid ) {
public function Exists ($sUid)
{
try {
$obj = FieldConditionPeer::retrieveByPk( $sUid );
return (is_object( $obj ) && get_class( $obj ) == 'FieldCondition');
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
}
// FieldCondition
} // FieldCondition

View File

@@ -1,12 +1,12 @@
<?php
/**
* Gateway.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseGateway.php';
/**
* Skeleton subclass for representing a row from the 'GATEWAY' table.
*
@@ -18,7 +18,8 @@ require_once 'classes/model/om/BaseGateway.php';
*
* @package workflow.engine.classes.model
*/
class Gateway extends BaseGateway {
class Gateway extends BaseGateway
{
public function create ($aData)
{
@@ -33,8 +34,7 @@ class Gateway extends BaseGateway {
$iResult = $oGateway->save();
$oConnection->commit();
return $sGatewayUID;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oGateway->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -42,8 +42,7 @@ class Gateway extends BaseGateway {
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -53,18 +52,15 @@ class Gateway extends BaseGateway {
{
try {
$oRow = GatewayPeer::retrieveByPK( $GatewayUid );
if (!is_null($oRow))
{
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
}
else {
} else {
throw (new Exception( "The row '" . $GatewayUid . "' in table Gateway doesn't exist!" ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
@@ -72,25 +68,19 @@ class Gateway extends BaseGateway {
public function update ($fields)
{
$con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try
{
try {
$con->begin();
$this->load( $fields['GAT_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if($this->validate())
{
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
@@ -101,19 +91,16 @@ class Gateway extends BaseGateway {
$oConnection = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try {
$oGateWay = GatewayPeer::retrieveByPK( $GatewayUid );
if (!is_null($oGateWay))
{
if (! is_null( $oGateWay )) {
$oConnection->begin();
$iResult = $oGateWay->delete();
$oConnection->commit();
//return $iResult;
return true;
}
else {
} else {
throw (new Exception( 'This row does not exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -125,18 +112,17 @@ class Gateway extends BaseGateway {
* @param string $sProUid the uid of the Prolication
*/
function gatewayExists ( $GatUid ) {
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 {
} else {
return false;
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
@@ -147,16 +133,14 @@ class Gateway extends BaseGateway {
* @param array $aData with new values
* @return void
*/
function createRow($aData)
public function createRow ($aData)
{
$con = Propel::getConnection( GatewayPeer::DATABASE_NAME );
try
{
try {
$con->begin();
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if($this->validate())
{
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'] : '') );
@@ -166,20 +150,17 @@ class Gateway extends BaseGateway {
$this->save();
$con->commit();
return;
}
else
{
} else {
$con->rollback();
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$e->aValidationFailures = $this->getValidationFailures();
throw ($e);
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
}
// Gateway
} // Gateway

View File

@@ -1,12 +1,12 @@
<?php
/**
* ReportVar.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseReportVar.php';
/**
* Skeleton subclass for representing a row from the 'REPORT_VAR' table.
*
@@ -18,7 +18,8 @@ require_once 'classes/model/om/BaseReportVar.php';
*
* @package workflow.engine.classes.model
*/
class ReportVar extends BaseReportVar {
class ReportVar extends BaseReportVar
{
/*
* Load the report var registry
* @param string $sRepVarUid
@@ -28,34 +29,35 @@ class ReportVar extends BaseReportVar {
{
try {
$oReportVar = ReportVarPeer::retrieveByPK( $sRepVarUid );
if (!is_null($oReportVar))
{
if (! is_null( $oReportVar )) {
$aFields = $oReportVar->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the report var registry
*
* @param array $aData
* @return string
**/
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( ReportVarPeer::DATABASE_NAME );
try {
if ( isset ( $aData['REP_VAR_UID'] ) && $aData['REP_VAR_UID']== '' )
if (isset( $aData['REP_VAR_UID'] ) && $aData['REP_VAR_UID'] == '') {
unset( $aData['REP_VAR_UID'] );
if ( !isset ( $aData['REP_VAR_UID'] ) )
}
if (! isset( $aData['REP_VAR_UID'] )) {
$aData['REP_VAR_UID'] = G::generateUniqueID();
}
$oReportVar = new ReportVar();
$oReportVar->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oReportVar->validate()) {
@@ -63,8 +65,7 @@ class ReportVar extends BaseReportVar {
$iResult = $oReportVar->save();
$oConnection->commit();
return $aData['REP_VAR_UID'];
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oReportVar->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -72,8 +73,7 @@ class ReportVar extends BaseReportVar {
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -81,24 +81,24 @@ class ReportVar extends BaseReportVar {
/**
* 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))
{
if (! is_null( $oReportVar )) {
$oReportVar->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oReportVar->validate()) {
$oConnection->begin();
$iResult = $oReportVar->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oReportVar->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -106,12 +106,10 @@ class ReportVar extends BaseReportVar {
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -119,44 +117,44 @@ class ReportVar extends BaseReportVar {
/**
* 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))
{
if (! is_null( $oReportVar )) {
$oConnection->begin();
$iResult = $oReportVar->delete();
$oConnection->commit();
return $iResult;
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
function reportVarExists ( $sRepVarUid ) {
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 {
} else {
return false;
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
} // ReportVar
}
// ReportVar

View File

@@ -1,12 +1,12 @@
<?php
/**
* SubProcess.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseSubProcess.php';
/**
* Skeleton subclass for representing a row from the 'SUB_PROCESS' table.
*
@@ -18,24 +18,22 @@ require_once 'classes/model/om/BaseSubProcess.php';
*
* @package workflow.engine.classes.model
*/
class SubProcess extends BaseSubProcess {
class SubProcess extends BaseSubProcess
{
public function load ($SP_UID)
{
try {
$oRow = SubProcessPeer::retrieveByPK( $SP_UID );
if (!is_null($oRow))
{
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
}
else {
} else {
throw (new Exception( "The row '$SP_UID' in table SubProcess doesn't exist!" ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
@@ -43,15 +41,16 @@ class SubProcess extends BaseSubProcess {
public function create ($aData)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try
{
try {
$con->begin();
if ( isset ( $aData['SP_UID'] ) && $aData['SP_UID']== '' )
if (isset( $aData['SP_UID'] ) && $aData['SP_UID'] == '') {
unset( $aData['SP_UID'] );
if ( !isset ( $aData['SP_UID'] ) )
}
if (! isset( $aData['SP_UID'] )) {
$this->setSpUid( G::generateUniqueID() );
else
} else {
$this->setSpUid( $aData['SP_UID'] );
}
$this->setProUid( $aData['PRO_UID'] );
@@ -75,57 +74,47 @@ class SubProcess extends BaseSubProcess {
$this->setSpGridIn( $aData['SP_GRID_IN'] );
if($this->validate())
{
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function update ($fields)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try
{
try {
$con->begin();
$this->load( $fields['SP_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if($this->validate())
{
if ($this->validate()) {
$result = $this->save();
$con->commit();
return $result;
}
else
{
} else {
$con->rollback();
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE->aValidationFailures = $this->getValidationFailures();
throw ($validationE);
}
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function remove ($SP_UID)
{
$con = Propel::getConnection( SubProcessPeer::DATABASE_NAME );
try
{
try {
$con->begin();
$oRepTab = SubProcessPeer::retrieveByPK( $SP_UID );
if (! is_null( $oRepTab )) {
@@ -133,9 +122,7 @@ class SubProcess extends BaseSubProcess {
$con->commit();
}
return $result;
}
catch(Exception $e)
{
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
@@ -147,20 +134,20 @@ class SubProcess extends BaseSubProcess {
* @param string $sUid the uid of the Prolication
*/
function subProcessExists ( $sUid ) {
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 {
} else {
return false;
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
}
// SubProcess
} // SubProcess

View File

@@ -1,6 +1,7 @@
<?php
/**
* SwimlanesElements.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
@@ -38,10 +39,12 @@ require_once 'classes/model/Content.php';
*
* @package workflow.engine.classes.model
*/
class SwimlanesElements extends BaseSwimlanesElements {
class SwimlanesElements extends BaseSwimlanesElements
{
/**
* This value goes in the content table
*
* @var string
*/
protected $swi_text = '';
@@ -55,27 +58,26 @@ class SwimlanesElements extends BaseSwimlanesElements {
{
try {
$oSwimlanesElements = SwimlanesElementsPeer::retrieveByPK( $sSwiEleUid );
if (!is_null($oSwimlanesElements))
{
if (! is_null( $oSwimlanesElements )) {
$aFields = $oSwimlanesElements->toArray( BasePeer::TYPE_FIELDNAME );
$aFields['SWI_TEXT'] = $oSwimlanesElements->getSwiEleText();
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the application document registry
*
* @param array $aData
* @return string
**/
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( SwimlanesElementsPeer::DATABASE_NAME );
@@ -91,8 +93,7 @@ class SwimlanesElements extends BaseSwimlanesElements {
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
return $aData['SWI_UID'];
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -100,8 +101,7 @@ class SwimlanesElements extends BaseSwimlanesElements {
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -109,28 +109,27 @@ class SwimlanesElements extends BaseSwimlanesElements {
/**
* 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))
{
if (! is_null( $oSwimlanesElements )) {
$oSwimlanesElements->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oSwimlanesElements->validate()) {
$oConnection->begin();
if (isset($aData['SWI_TEXT']))
{
if (isset( $aData['SWI_TEXT'] )) {
$oSwimlanesElements->setSwiEleText( $aData['SWI_TEXT'] );
}
$iResult = $oSwimlanesElements->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oSwimlanesElements->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -138,12 +137,10 @@ class SwimlanesElements extends BaseSwimlanesElements {
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -151,50 +148,49 @@ class SwimlanesElements extends BaseSwimlanesElements {
/**
* 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))
{
if (! is_null( $oSwimlanesElements )) {
$oConnection->begin();
Content::removeContent( 'SWI_TEXT', '', $oSwimlanesElements->getSwiUid() );
$iResult = $oSwimlanesElements->delete();
$oConnection->commit();
return $iResult;
}
else {
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
function swimlanesElementsExists ( $sSwiEleUid ) {
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 {
} else {
return false;
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Get the [swi_text] column value.
*
* @return string
*/
public function getSwiEleText ()
@@ -202,8 +198,7 @@ function swimlanesElementsExists ( $sSwiEleUid ) {
if ($this->swi_text == '') {
try {
$this->swi_text = Content::load( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
@@ -226,12 +221,12 @@ function swimlanesElementsExists ( $sSwiEleUid ) {
$this->swi_text = $sValue;
$iResult = Content::addContent( 'SWI_TEXT', '', $this->getSwiUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->swi_text );
}
catch (Exception $oError) {
} catch (Exception $oError) {
$this->swi_text = '';
throw ($oError);
}
}
}
}
// SwimlanesElements
} // SwimlanesElements

View File

@@ -1,6 +1,7 @@
<?php
/**
* TaskUser.php
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
@@ -38,22 +39,25 @@ require_once 'classes/model/Content.php';
*
* @package workflow.engine.classes.model
*/
class TaskUser extends BaseTaskUser {
class TaskUser extends BaseTaskUser
{
/**
* Create the application document registry
*
* @param array $aData
* @return string
**/
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
try {
$taskUser = TaskUserPeer::retrieveByPK( $aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION'] );
if( is_object($taskUser) )
if (is_object( $taskUser )) {
return - 1;
}
$oTaskUser = new TaskUser();
$oTaskUser->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oTaskUser->validate()) {
@@ -61,8 +65,7 @@ class TaskUser extends BaseTaskUser {
$iResult = $oTaskUser->save();
$oConnection->commit();
return $iResult;
}
else {
} else {
$sMessage = '';
$aValidationFailures = $oTaskUser->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
@@ -70,8 +73,7 @@ class TaskUser extends BaseTaskUser {
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
@@ -79,49 +81,48 @@ class TaskUser extends BaseTaskUser {
/**
* 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))
{
if (! is_null( $oTaskUser )) {
$oConnection->begin();
$iResult = $oTaskUser->delete();
$oConnection->commit();
return $iResult;
}
else {
} else {
throw (new Exception( 'This row does not exist!' ));
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
function TaskUserExists ($sTasUid, $sUserUid, $iType, $iRelation) {
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 {
} else {
return false;
}
}
catch (Exception $oError) {
} catch (Exception $oError) {
throw ($oError);
}
}
function getCountAllTaksByGroups(){
public function getCountAllTaksByGroups ()
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addAsColumn( 'GRP_UID', TaskUserPeer::USR_UID );
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
@@ -137,10 +138,9 @@ class TaskUser extends BaseTaskUser {
}
return $aRows;
}
//erik: new functions
function getUsersTask($TAS_UID, $TU_TYPE=1){
public function getUsersTask ($TAS_UID, $TU_TYPE = 1)
{
require_once 'classes/model/Users.php';
$groupsTask = array ();
@@ -163,9 +163,9 @@ class TaskUser extends BaseTaskUser {
$dataset = TaskUserPeer::doSelectRS( $criteria );
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while ($dataset->next())
while ($dataset->next()) {
$usersTask[] = $dataset->getRow();
}
//getting task's groups
$delimiter = DBAdapter::getStringDelimiter();
$criteria = new Criteria( 'workflow' );
@@ -182,17 +182,17 @@ class TaskUser extends BaseTaskUser {
$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() )
while ($dataset->next()) {
$usersTask[] = $dataset->getRow();
}
$result->data = $usersTask;
$result->totalCount = sizeof( $usersTask );
return $result;
}
}
// TaskUser
} // TaskUser

View File

@@ -10,7 +10,8 @@
* @author Zachary Tirrell <zbtirrell@plymouth.edu>
* @GPL 2007, Plymouth State University, ITS
*/
class Zimbra {
class Zimbra
{
public $debug = false;
public $error;
@@ -33,6 +34,7 @@ class Zimbra {
protected $_idm; // IDMObject
protected $_username; // the user we are operating as
/**
* __construct
*
@@ -44,7 +46,8 @@ class Zimbra {
* @param string $which defaults to prod
*/
public function __construct($username, $serverUrl, $preAuthKey, $which = 'prod') {
public function __construct ($username, $serverUrl, $preAuthKey, $which = 'prod')
{
if ($which == 'dev') {
$which = 'zimbra_dev';
$this->_dev = true;
@@ -62,6 +65,7 @@ class Zimbra {
// end __construct
/**
* sso
*
@@ -72,14 +76,15 @@ class Zimbra {
* @param string $options options for sso
* @return boolean
*/
public function sso($options='') {
public function sso ($options = '')
{
if ($this->_username) {
setcookie( 'ZM_SKIN', 'plymouth', time() + 60 * 60 * 24 * 30, '/', '.plymouth.edu' );
$pre_auth = $this->getPreAuth( $this->_username );
$url = $this->_protocol . '/service/preauth?account=' . $this->_username . '@' . $this->_server . '&expires=' . $this->_preauth_expiration . '&timestamp=' . $this->_timestamp . '&preauth=' . $pre_auth; //.'&'.$options;
header( "Location: $url" );
exit;
exit();
} else {
return false;
}
@@ -87,25 +92,26 @@ class Zimbra {
// end sso
/**
* createAccount
*
* @param string $name account name
* @param string $password password
* @return string account id
*/
function createAccount($name, $password) {
function createAccount ($name, $password)
{
$option_string = '';
try {
$soap = '<CreateAccountRequest xmlns="urn:zimbraAccount">
<name>' . $name . '@' . $this->_server1 . '</name>
<password>' . $password . '</password>' . $option_string . '
<session/>
</CreateAccountRequest>';
$response = $this->soapRequest( $soap );
} catch (SoapFault $exception) {
print_exception( $exception );
@@ -124,7 +130,8 @@ class Zimbra {
* @param string $username username
* @return string preauthentication key in hmacsha1 format
*/
private function getPreAuth($username) {
private function getPreAuth ($username)
{
$account_identifier = $username . '@' . $this->_server1;
$by_value = 'name';
$expires = $this->_preauth_expiration;
@@ -137,6 +144,7 @@ class Zimbra {
// end getPreAuth
/**
* hmacsha1
*
@@ -148,28 +156,23 @@ class Zimbra {
* @param string $data data to encrypt
* @return string converted to hmac sha1 format
*/
private function hmacsha1($key, $data) {
private function hmacsha1 ($key, $data)
{
$blocksize = 64;
$hashfunc = 'sha1';
if (strlen($key) > $blocksize)
if (strlen( $key ) > $blocksize) {
$key = pack( 'H*', $hashfunc( $key ) );
}
$key = str_pad( $key, $blocksize, chr( 0x00 ) );
$ipad = str_repeat( chr( 0x36 ), $blocksize );
$opad = str_repeat( chr( 0x5c ), $blocksize );
$hmac = pack(
'H*', $hashfunc(
($key ^ $opad) . pack(
'H*', $hashfunc(
($key ^ $ipad) . $data
)
)
)
);
$hmac = pack( 'H*', $hashfunc( ($key ^ $opad) . pack( 'H*', $hashfunc( ($key ^ $ipad) . $data ) ) ) );
return bin2hex( $hmac );
}
// end hmacsha1
/**
* connect
*
@@ -179,7 +182,8 @@ class Zimbra {
* @access public
* @return array associative array of account information
*/
public function connect() {
public function connect ()
{
if ($this->_connected) {
return $this->_account_info;
}
@@ -239,6 +243,7 @@ class Zimbra {
// end connect
/**
* administerUser
*
@@ -249,7 +254,8 @@ class Zimbra {
* @param string $username username to administer
* @return boolean
*/
public function administerUser($username) {
public function administerUser ($username)
{
if (! $this->_admin) {
return false;
}
@@ -275,6 +281,7 @@ class Zimbra {
// end administerUser
/**
* getInfo
*
@@ -285,7 +292,8 @@ class Zimbra {
* @param string $options options for info retrieval, defaults to null
* @return array information
*/
public function getInfo($options='') {
public function getInfo ($options = '')
{
// valid sections: mbox,prefs,attrs,zimlets,props,idents,sigs,dsrcs,children
$option_string = $this->buildOptionString( $options );
@@ -301,6 +309,7 @@ class Zimbra {
// end getInfo
/**
* getMessages
*
@@ -312,7 +321,8 @@ class Zimbra {
* @param array $options options to apply to retrieval
* @return array array of messages
*/
public function getMessages($search='in:inbox', $options=array('limit' => 5, 'fetch' => 'none')) {
public function getMessages ($search = 'in:inbox', $options = array('limit' => 5, 'fetch' => 'none'))
{
$option_string = $this->buildOptionString( $options );
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="message"' . $option_string . '>
@@ -329,6 +339,7 @@ class Zimbra {
// end getMessages
/**
* getContacts
*
@@ -340,7 +351,8 @@ class Zimbra {
* @param array $options options to apply to retrieval
* @return array array of messages
*/
public function getContacts($search='in:contacts', $options=array('limit' => 5, 'fetch' => 'none')) {
public function getContacts ($search = 'in:contacts', $options = array('limit' => 5, 'fetch' => 'none'))
{
$option_string = $this->buildOptionString( $options );
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="contact"' . $option_string . '>
@@ -369,7 +381,8 @@ class Zimbra {
* @return array array of messages
*/
public function getAppointments($search='in:calendar', $options=array('limit' => 50, 'fetch' => 'none')) {
public function getAppointments ($search = 'in:calendar', $options = array('limit' => 50, 'fetch' => 'none'))
{
$option_string = $this->buildOptionString( $options );
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="appointment"' . $option_string . '>
@@ -386,6 +399,7 @@ class Zimbra {
// end getAppointments
/* getTasks
*
* get the Tasks in folder
@@ -397,7 +411,8 @@ class Zimbra {
* @return array array of messages
*/
public function getTasks($search='in:tasks', $options=array('limit' => 50, 'fetch' => 'none')) {
public function getTasks ($search = 'in:tasks', $options = array('limit' => 50, 'fetch' => 'none'))
{
$option_string = $this->buildOptionString( $options );
$soap = '<SearchRequest xmlns="urn:zimbraMail" types="task"' . $option_string . '>
@@ -414,6 +429,7 @@ class Zimbra {
// end getTasks
/**
* getMessageContent
*
@@ -424,7 +440,8 @@ class Zimbra {
* @param int $id id number of message to retrieve content of
* @return array associative array with message content, valid for tasks, calendar entries, and email messages.
*/
public function getMessageContent($id) {
public function getMessageContent ($id)
{
$soap = '<GetMsgRequest xmlns="urn:zimbraMail">
<m id="' . $id . '" html="1">*</m>
</GetMsgRequest>';
@@ -457,19 +474,22 @@ class Zimbra {
* @access public
* @return array $subscribed
*/
public function getSubscribedCalendars() {
public function getSubscribedCalendars ()
{
$subscribed = array ();
if (is_array( $this->_account_info['link_attribute_name'] )) {
foreach ($this->_account_info['link_attribute_name'] as $i => $name) {
if ($this->_account_info['link_attribute_view'][$i] == 'appointment')
if ($this->_account_info['link_attribute_view'][$i] == 'appointment') {
$subscribed[$this->_account_info['link_attribute_id'][$i]] = $name;
}
}
}
return $subscribed;
}
// end getSubscribedCalendars
/**
* getSubscribedTaskLists
*
@@ -479,19 +499,22 @@ class Zimbra {
* @access public
* @return array $subscribed or false
*/
public function getSubscribedTaskLists() {
public function getSubscribedTaskLists ()
{
$subscribed = array ();
if (is_array( $this->_account_info['link_attribute_name'] )) {
foreach ($this->_account_info['link_attribute_name'] as $i => $name) {
if ($this->_account_info['link_attribute_view'][$i] == 'task')
if ($this->_account_info['link_attribute_view'][$i] == 'task') {
$subscribed[$this->_account_info['link_attribute_id'][$i]] = $name;
}
}
}
return $subscribed;
}
// end getSubscribedCalendars
/**
* getFolder
*
@@ -502,10 +525,12 @@ class Zimbra {
* @param string $folder_options options for folder retrieval
* @return array $folder or false
*/
public function getFolder($folderName, $folder_options='') {
public function getFolder ($folderName, $folder_options = '')
{
//$folder_option_string = $this->buildOptionString($folder_options);
$soap = '<GetFolderRequest xmlns="urn:zimbraMail" visible="1">
<folder path="' . $folderName . '"/>
</GetFolderRequest>';
@@ -526,6 +551,7 @@ class Zimbra {
// end getFolder
/**
* getPrefrences
*
@@ -536,7 +562,8 @@ class Zimbra {
* @example example XML: <GetPrefsRequest> <!-- get only the specified prefs --> [<pref name="{name1}"/> <pref name="{name2}"/>] </GetPrefsRequest>
* @return array $prefs or false
*/
public function getPreferences() {
public function getPreferences ()
{
$soap = '<GetPrefsRequest xmlns="urn:zimbraAccount" />';
$response = $this->soapRequest( $soap );
if ($response) {
@@ -553,6 +580,7 @@ class Zimbra {
// end getPreferences
/**
* setPrefrences
*
@@ -564,7 +592,8 @@ class Zimbra {
* @example example XML: <ModifyPrefsRequest> [<pref name="{name}">{value}</pref>...]+ </ModifyPrefsRequest>
* @return boolean
*/
public function setPreferences($options='') {
public function setPreferences ($options = '')
{
$option_string = '';
foreach ($options as $name => $value) {
$option_string .= '<pref name="' . $name . '">' . $value . '</pref>';
@@ -583,6 +612,7 @@ class Zimbra {
// end setPreferences
/**
* emailChannel
*
@@ -591,7 +621,8 @@ class Zimbra {
* @since version 1.0
* @access public
*/
public function emailChannel() {
public function emailChannel ()
{
require_once 'xtemplate.php';
$tpl = new XTemplate( '/web/pscpages/webapp/portal/channel/email/templates/index.tpl' );
@@ -632,7 +663,8 @@ class Zimbra {
$tpl->assign( 'message', $clean_message );
$tpl->parse( 'main.message' );
}
$inbox = $this->getFolder(array('l' => 2));
$inbox = $this->getFolder( array ('l' => 2
) );
$total_messages = (int) $inbox['n'];
$unread_messages = (int) $inbox['u'];
@@ -662,6 +694,7 @@ class Zimbra {
// end emailChannel
/**
* builOptionString
*
@@ -672,7 +705,8 @@ class Zimbra {
* @param array $options array of options to be parsed into a string
* @return string $options_string
*/
protected function buildOptionString($options) {
protected function buildOptionString ($options)
{
$options_string = '';
foreach ($options as $k => $v) {
$options_string .= ' ' . $k . '="' . $v . '"';
@@ -682,6 +716,7 @@ class Zimbra {
// end buildOptionString
/**
* extractAuthToken
*
@@ -692,7 +727,8 @@ class Zimbra {
* @param string $xml xml to have the auth token pulled from
* @return string $auth_token
*/
private function extractAuthToken($xml) {
private function extractAuthToken ($xml)
{
$auth_token = strstr( $xml, "<authToken" );
$auth_token = strstr( $auth_token, ">" );
$auth_token = substr( $auth_token, 1, strpos( $auth_token, "<" ) - 1 );
@@ -709,7 +745,8 @@ class Zimbra {
* @param string $xml xml to have the session id pulled from
* @return int $session_id
*/
private function extractSessionID($xml) {
private function extractSessionID ($xml)
{
//for testing purpose we are extracting lifetime instead of sessionid
//$session_id = strstr($xml, "<lifetime");
@@ -721,6 +758,7 @@ class Zimbra {
// end extractSessionID
/**
* extractErrorCode
*
@@ -731,7 +769,8 @@ class Zimbra {
* @param string $xml xml to have the error code pulled from
* @return int $session_id
*/
private function extractErrorCode($xml) {
private function extractErrorCode ($xml)
{
$session_id = strstr( $xml, "<Code" );
$session_id = strstr( $session_id, ">" );
$session_id = substr( $session_id, 1, strpos( $session_id, "<" ) - 1 );
@@ -740,6 +779,7 @@ class Zimbra {
// end extractErrorCode
/**
* makeBytesPretty
*
@@ -751,14 +791,15 @@ class Zimbra {
* @param boolean $redlevel
* @return int $size
*/
private function makeBytesPretty($bytes, $redlevel=false) {
if ($bytes < 1024)
private function makeBytesPretty ($bytes, $redlevel = false)
{
if ($bytes < 1024) {
$size = $bytes . ' B';
elseif ($bytes < 1024 * 1024)
} elseif ($bytes < 1024 * 1024) {
$size = round( $bytes / 1024, 1 ) . ' KB';
else
} else {
$size = round( ($bytes / 1024) / 1024, 1 ) . ' MB';
}
if ($redlevel && $bytes > $redlevel) {
$size = '<span style="color:red">' . $size . '</span>';
}
@@ -768,6 +809,7 @@ class Zimbra {
// end makeBytesPretty
/**
* message
*
@@ -777,7 +819,8 @@ class Zimbra {
* @access public
* @param string $message message for debug
*/
protected function message($message) {
protected function message ($message)
{
if ($this->debug) {
echo $message;
}
@@ -785,6 +828,7 @@ class Zimbra {
// end message
/**
* soapRequest
*
@@ -797,7 +841,8 @@ class Zimbra {
* @param boolean $footer
* @return string $response
*/
protected function soapRequest($body, $header=false, $connecting=false) {
protected function soapRequest ($body, $header = false, $connecting = false)
{
if (! $connecting && ! $this->_connected) {
throw new Exception( 'zimbra.class: soapRequest called without a connection to Zimbra server' );
}
@@ -824,7 +869,8 @@ class Zimbra {
$error_code = $this->extractErrorCode( $response );
$this->error = 'ERROR: ' . $error_code . ':<textarea>' . $response . '</textarea>';
$this->message( $this->error );
$aError = array('error' => $error_code);
$aError = array ('error' => $error_code
);
return $aError;
//return false;
}
@@ -836,6 +882,7 @@ class Zimbra {
// end soapRequest
/**
* getNumSOAPCalls
*
@@ -845,12 +892,14 @@ class Zimbra {
* @access public
* @return int $this->_num_soap_calls
*/
public function getNumSOAPCalls() {
public function getNumSOAPCalls ()
{
return $this->_num_soap_calls;
}
// end getNumSOAPCalls
/**
* makeXMLTree
*
@@ -861,7 +910,8 @@ class Zimbra {
* @param string $data data to be built into an array
* @return array $ret
*/
protected function makeXMLTree($data) {
protected function makeXMLTree ($data)
{
// create parser
$parser = xml_parser_create();
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
@@ -912,6 +962,7 @@ class Zimbra {
// end makeXMLTree
/**
* &composeArray
*
@@ -924,7 +975,8 @@ class Zimbra {
* @param array $value
* @return array $array
*/
private function &composeArray($array, $elements, $value=array()) {
private function &composeArray ($array, $elements, $value = array())
{
global $XML_LIST_ELEMENTS;
// get current element
@@ -942,6 +994,7 @@ class Zimbra {
// end composeArray
/**
* noop
*
@@ -951,7 +1004,8 @@ class Zimbra {
* @access public
* @return string xml response from the noop
*/
public function noop() {
public function noop ()
{
return $this->soapRequest( '<NoOpRequest xmlns="urn:zimbraMail"/>' );
}
@@ -963,9 +1017,12 @@ class Zimbra {
* @since version 1.0
* @access public
* @param
*
* @return
*
*/
public function addAppointment($serializeOp1) {
public function addAppointment ($serializeOp1)
{
$unserializeOp1 = unserialize( $serializeOp1 );
$username = $unserializeOp1['username'];
@@ -1030,6 +1087,7 @@ class Zimbra {
// end addAppointments
/**
* addTask
*
@@ -1040,7 +1098,8 @@ class Zimbra {
* @param array $options array of options to apply to retrieval from calendar
* @return array associative array of appointments
*/
public function addTask($serializeOp1) {
public function addTask ($serializeOp1)
{
$unserializeOp1 = unserialize( $serializeOp1 );
$subject = $unserializeOp1['subject'];
@@ -1055,7 +1114,6 @@ class Zimbra {
$status = $unserializeOp1['status'];
$percent = $unserializeOp1['percent'];
$soap = '<CreateTaskRequest xmlns="urn:zimbraMail">
<m l="15">
<su>' . $subject . '</su>
@@ -1092,6 +1150,7 @@ class Zimbra {
// end addTask
/**
* addContacts
*
@@ -1100,9 +1159,12 @@ class Zimbra {
* @since version 1.0
* @access public
* @param
*
* @return
*
*/
public function addContacts($serializeOp1) {
public function addContacts ($serializeOp1)
{
$unserializeOp1 = unserialize( $serializeOp1 );
$firstName = $unserializeOp1['firstName'];
@@ -1139,10 +1201,13 @@ class Zimbra {
* @since version 1.0
* @access public
* @param
*
* @return
*
*/
public function addFolder($serializeOp1) {
public function addFolder ($serializeOp1)
{
$unserializeOp1 = unserialize( $serializeOp1 );
$folderName = $unserializeOp1['folderName'];
@@ -1172,10 +1237,13 @@ class Zimbra {
* @since version 1.0
* @access public
* @param
*
* @return
*
*/
public function upload($folderId, $UploadId, $fileVersion='', $docId='') {
public function upload ($folderId, $UploadId, $fileVersion = '', $docId = '')
{
if ($fileVersion == '' && $docId == '') {
$soap = '<SaveDocumentRequest xmlns="urn:zimbraMail">
<doc l="' . $folderId . '">
@@ -1204,6 +1272,7 @@ class Zimbra {
// end uploadDocument
/**
* getDocId
*
@@ -1212,9 +1281,12 @@ class Zimbra {
* @since version 1.0
* @access public
* @param
*
* @return
*
*/
public function getDocId($folderId, $fileName) {
public function getDocId ($folderId, $fileName)
{
$soap = '<GetItemRequest xmlns="urn:zimbraMail">
<item l="' . $folderId . '" name="' . $fileName . '" />
</GetItemRequest>';
@@ -1239,6 +1311,7 @@ class Zimbra {
// I don't know how to make usort calls to internal OO functions
// if someone knows how, please fix this :)
/**
* zimbra_startSort
*
@@ -1250,7 +1323,8 @@ class Zimbra {
* @param array $task_b
* @return int (($task_a['dueDate']-$task_a['dur']) < ($task_b['dueDate']-$task_b['dur'])) ? -1 : 1
*/
function zimbra_startSort($task_a, $task_b) {
function zimbra_startSort ($task_a, $task_b)
{
if (($task_a['dueDate'] - $task_a['dur']) == ($task_b['dueDate'] - $task_b['dur'])) {
return ($task_a['name'] < $task_b['name']) ? - 1 : 1;
}
@@ -1268,7 +1342,8 @@ function zimbra_startSort($task_a, $task_b) {
* @param array $task_b
* @return int ($task_a['dueDate'] < $task_b['dueDate']) ? -1 : 1
*/
function zimbra_dueSort($task_a, $task_b) {
function zimbra_dueSort ($task_a, $task_b)
{
if ($task_a['dueDate'] == $task_b['dueDate']) {
return ($task_a['name'] < $task_b['name']) ? - 1 : 1;
}
@@ -1286,11 +1361,11 @@ function zimbra_dueSort($task_a, $task_b) {
* @param array $task_b
* @return int ($task_a['name'] < $task_b['name']) ? -1 : 1
*/
function zimbra_nameSort($task_a, $task_b) {
function zimbra_nameSort ($task_a, $task_b)
{
if ($task_a['name'] == $task_b['name']) {
return 0;
}
return ($task_a['name'] < $task_b['name']) ? - 1 : 1;
}
?>