Index: sandbox/workflow/branches/609/showUserPicture.php
===================================================================
--- sandbox/workflow/branches/609/showUserPicture.php	(revision 1468)
+++ sandbox/workflow/branches/609/showUserPicture.php	(revision 2233)
@@ -12,4 +12,4 @@
 if (empty($_SESSION))
 	exit(0);
-$GLOBALS['workflow']['factory']->getInstance('UserPictureProvider')->serve();
+Factory::getInstance('UserPictureProvider')->serve();
 ?>
Index: sandbox/workflow/branches/609/templateFile.php
===================================================================
--- sandbox/workflow/branches/609/templateFile.php	(revision 2223)
+++ sandbox/workflow/branches/609/templateFile.php	(revision 2233)
@@ -12,5 +12,4 @@
 if (empty($_SESSION))
 	exit(0);
-//$GLOBALS['workflow']['factory']->getInstance('TemplateServer')->redirect();
 Factory::getInstance('TemplateServer')->redirect();
 ?>
Index: sandbox/workflow/branches/609/lib/factory/BaseFactory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/BaseFactory.php	(revision 2222)
+++ sandbox/workflow/branches/609/lib/factory/BaseFactory.php	(revision 2233)
@@ -154,7 +154,7 @@
 		/* not found */
 		if (!($entry = $this->_getEntry($className)))
-			throw new Exception('You are not allowed to instantiate '.$className.' class.');
+			throw new Exception('You are not allowed to instantiate \''.$className.'\' class.');
 
-		$fullPath = $entry['basePath'] . SEP . $entry['path'] . SEP . $entry['filename'];
+		$fullPath = $entry['basePath'] . '/' . $entry['path'] . '/' . $entry['filename'];
 
 		/* file not found */
Index: sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2223)
+++ sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2233)
@@ -49,9 +49,22 @@
 		/* registering allowed classes */
 		$this->registerFileInfo('WorkflowObjects', 'class.WorkflowObjects.inc.php', 'inc');
+		$this->registerFileInfo('WorkflowWatcher', 'class.WorkflowWatcher.inc.php', 'inc');
+		$this->registerFileInfo('WorkflowLDAP', 'class.WorkflowLDAP.inc.php', 'inc');
+		$this->registerFileInfo('WorkflowSecurity', 'class.WorkflowSecurity.inc.php', 'inc');
+		$this->registerFileInfo('ResourcesRedirector', 'class.ResourcesRedirector.inc.php', 'inc');
 		$this->registerFileInfo('TemplateServer', 'class.TemplateServer.inc.php', 'inc');
+		$this->registerFileInfo('CachedLDAP', 'class.CachedLDAP.inc.php', 'inc');
+		$this->registerFileInfo('BrowserInfo', 'class.BrowserInfo.inc.php', 'inc');
+
 		$this->registerFileInfo('workflow_smarty', 'class.workflow_smarty.inc.php', 'inc');
+		$this->registerFileInfo('workflow_acl', 'class.workflow_acl.inc.php', 'inc');
+		$this->registerFileInfo('workflow_processmanager', 'class.workflow_processmanager.inc.php', 'inc');
+
+		$this->registerFileInfo('bo_participants', 'class.bo_participants.inc.php', 'inc');
 
 		/* registering egw class example */
-		//$this->registerFileInfo('db', 'x', 'inc', PHPGW_API_INC);
+		$this->registerFileInfo('phpgw', 'class.phpgw.inc.php', '', EGW_INC_ROOT);
+		$this->registerFileInfo('db', 'class.db.inc.php', '', EGW_INC_ROOT);
+		$this->registerFileInfo('accounts', 'class.accounts.inc.php', '', EGW_INC_ROOT);
 
 		/* ok. no more instances of this class.. */
Index: sandbox/workflow/branches/609/lib/factory/Factory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/Factory.php	(revision 2223)
+++ sandbox/workflow/branches/609/lib/factory/Factory.php	(revision 2233)
@@ -64,5 +64,5 @@
 	 * @static
 	 */
-	public static function getInstance() {
+	public static function &getInstance() {
 
 		/* oops. we are in the process space. */
@@ -93,10 +93,31 @@
 	 * Just forward this call to the correct class.
 	 *
-	 * @todo I must implement it!
 	 * @access public
 	 * @retun object
 	 * @static
 	 */
-	public static function newInstance() {
+	public static function &newInstance() {
+
+		/* oops. we are in the process space. */
+		if (Security::isEnabled()) {
+
+			/* must instatiate it */
+			if (is_null(self::$_securedFactory))
+				self::$_securedFactory = new ProcessFactory();
+
+			$args = func_get_args();
+			return call_user_func_array(array(self::$_securedFactory, "newInstance"), $args);
+
+		}
+		/* regular module space */
+		else {
+
+			/* must instatiate it */
+			if (is_null(self::$_unsecuredFactory))
+				self::$_unsecuredFactory = new WorkflowFactory();
+
+			$args = func_get_args();
+			return call_user_func_array(array(self::$_unsecuredFactory, "newInstance"), $args);
+		}
 	}
 }
Index: sandbox/workflow/branches/609/redirect.php
===================================================================
--- sandbox/workflow/branches/609/redirect.php	(revision 1468)
+++ sandbox/workflow/branches/609/redirect.php	(revision 2233)
@@ -12,4 +12,4 @@
 if (empty($_SESSION))
 	exit(0);
-$GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->redirect();
+Factory::getInstance('ResourcesRedirector')->redirect();
 ?>
Index: sandbox/workflow/branches/609/controller.php
===================================================================
--- sandbox/workflow/branches/609/controller.php	(revision 1484)
+++ sandbox/workflow/branches/609/controller.php	(revision 2233)
@@ -16,5 +16,5 @@
 	{
 		require_once dirname(__FILE__) . '/inc/common.inc.php';
-		$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+		Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 	}
 
Index: sandbox/workflow/branches/609/inc/class.workflow_processmonitor.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_processmonitor.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_processmonitor.inc.php	(revision 2233)
@@ -17,5 +17,5 @@
 		function workflow_processmonitor()
 		{
-			parent::ProcessMonitor($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::ProcessMonitor(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_utils.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_utils.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_utils.inc.php	(revision 2233)
@@ -34,5 +34,5 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
 	}
 
Index: sandbox/workflow/branches/609/inc/class.run_activity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2072)
+++ sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2233)
@@ -301,5 +301,5 @@
 			$this->process_version	= $this->process->getVersion();
 			$this->activity_name	= $activity->getName();
-			$this->user_name	= $GLOBALS['phpgw']->accounts->id2name($GLOBALS['user']);
+			$this->user_name	= Factory::getForeignInstance('phpgwapi', 'phpgw')->accounts->id2name($GLOBALS['user']);
 			$this->view_activity	= $this->GUI->gui_get_process_view_activity($this->process_id);
 
@@ -318,8 +318,8 @@
 			$GLOBALS['workflow']['wf_workflow_path']			= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow';
 			$GLOBALS['workflow']['wf_resources_path']			= $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file=';
-			$GLOBALS['workflow']['wf_default_resources_path']	= $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes');
-			$GLOBALS['workflow']['wf_workflow_resources_path']	= $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('');
+			$GLOBALS['workflow']['wf_default_resources_path']	= Factory::getInstance('TemplateServer')->generateLink('processes');
+			$GLOBALS['workflow']['wf_workflow_resources_path']	= Factory::getInstance('TemplateServer')->generateLink('');
 			$GLOBALS['workflow']['wf_activity_url']				= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id;
-			$GLOBALS['workflow']['wf_user_cnname']				= $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']);
+			$GLOBALS['workflow']['wf_user_cnname']				= Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']);
 			$GLOBALS['workflow']['wf_back_link']				= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1';
 			$GLOBALS['workflow']['wf_js_path']					= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode';
@@ -376,5 +376,5 @@
 
 				/* check some permissions */
-				if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || ($GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($newUser) === false))
+				if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || (Factory::getInstance('WorkflowLDAP')->getName($newUser) === false))
 				{
 					$_SESSION['phpgw_info']['workflow']['user_groups'] = $actualUserGroups;
@@ -472,5 +472,5 @@
 
 			/* activate the security policy */
-			$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy();
+			Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy();
 
 			/* include the files */
@@ -661,8 +661,8 @@
 			$GLOBALS['workflow']['wf_workflow_path']			= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow';
 			$GLOBALS['workflow']['wf_resources_path']			= $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file=';
-			$GLOBALS['workflow']['wf_default_resources_path']	= $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes');
-			$GLOBALS['workflow']['wf_workflow_resources_path']	= $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('');
+			$GLOBALS['workflow']['wf_default_resources_path']	= Factory::getInstance('TemplateServer')->generateLink('processes');
+			$GLOBALS['workflow']['wf_workflow_resources_path']	= Factory::getInstance('TemplateServer')->generateLink('');
 			$GLOBALS['workflow']['wf_activity_url']				= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id;
-			$GLOBALS['workflow']['wf_user_cnname']				= $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']);
+			$GLOBALS['workflow']['wf_user_cnname']				= Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']);
 			$GLOBALS['workflow']['wf_back_link']				= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1';
 			$GLOBALS['workflow']['wf_js_path']					= $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode';
@@ -712,5 +712,5 @@
 
 			/* activate the security policy */
-			$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy();
+			Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy();
 
 			$GLOBALS['workflow_env'] = &$env;
Index: sandbox/workflow/branches/609/inc/class.workflow_baseactivity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_baseactivity.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_baseactivity.inc.php	(revision 2233)
@@ -17,5 +17,5 @@
 		function workflow_baseactivity()
 		{
-			parent::BaseActivity($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::BaseActivity(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.workflow_acl.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_acl.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_acl.inc.php	(revision 2233)
@@ -30,5 +30,5 @@
 	function workflow_acl()
 	{
-		parent::so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		parent::so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 
Index: sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php	(revision 2233)
@@ -43,8 +43,8 @@
 		parent::bo_ajaxinterface();
 
-		if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id']))
+		if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id']))
 			exit(serialize(array('error' => 'Você não tem permissão para executar esta operação.')));
 
-		$this->so = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$this->so = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 
@@ -57,5 +57,5 @@
 	function get_all_processes()
 	{
-		$proc_mng = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$proc_mng = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proc_list = $proc_mng->list_processes(0,-1,'wf_name__ASC');
 
Index: sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php	(revision 2223)
+++ sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php	(revision 2233)
@@ -115,8 +115,8 @@
 
 		// Get a connection to db workflow and galaxia (module)
-		if ($GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Error)
+		if (Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Error)
 			$errors[] = 'Unable to connect to database Workflow';
 
-		if ($errormsg = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Error)
+		if ($errormsg = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Error)
 			$errors[] = 'Unable to connect to database Galaxia';
 
Index: sandbox/workflow/branches/609/inc/class.TemplateServer.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.TemplateServer.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.TemplateServer.inc.php	(revision 2233)
@@ -99,5 +99,5 @@
 				else
 				{
-					$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+					Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 					if (!isset($GLOBALS['phpgw_info']['login_template_set']))
 						return false;
@@ -131,5 +131,5 @@
 				{
 					/* se não for encontrado em nenhuma variável de ambiente, tenta carregar do banco de dados */
-					$webServerURL = (string) $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->GetOne('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'webserver_url'));
+					$webServerURL = (string) Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->GetOne('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'webserver_url'));
 					$this->WEB_WORKFLOW_BASE = str_replace('//', '/', "{$webServerURL}/workflow");
 				}
Index: sandbox/workflow/branches/609/inc/class.ui_adminjobs.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminjobs.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_adminjobs.inc.php	(revision 2233)
@@ -41,5 +41,5 @@
 			'app_header' => $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('Jobs')
 		);
-		$smarty = &$GLOBALS['workflow']['factory']->getInstance('workflow_smarty');
+		$smarty = &Factory::getInstance('workflow_smarty');
 
 		$javaScripts = $this->get_common_js();
@@ -54,5 +54,5 @@
 		$css .= $this->get_css_link('adminjobs');
 
-		$processInfo = $GLOBALS['workflow']['factory']->getInstance('workflow_processmanager')->get_process((int) $_REQUEST['p_id']);
+		$processInfo = Factory::getInstance('workflow_processmanager')->get_process((int) $_REQUEST['p_id']);
 		$smarty->assign('processNameVersion', "{$processInfo['wf_name']} v{$processInfo['wf_version']}");
 		$smarty->assign('processID', (int) $processInfo['wf_p_id']);
Index: sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php	(revision 2233)
@@ -26,5 +26,5 @@
 			'database_user',
 			'database_password'
-		); 
+		);
 	   /**
 		 * Constructor
@@ -34,7 +34,7 @@
 		function workflow_processmanager()
 		{
-			parent::ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 			$this->workflow_acl = CreateObject('workflow.workflow_acl');
-			
+
 			/* allow regular users to see the process graph */
 			if ($_GET['menuaction'] == "workflow.ui_adminactivities.show_graph")
Index: sandbox/workflow/branches/609/inc/class.ui_generic_select.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_generic_select.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_generic_select.inc.php	(revision 2233)
@@ -79,5 +79,5 @@
 	function form()
 	{
-		$smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false);
+		$smarty = Factory::getInstance('workflow_smarty', false);
 		$smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER);
 
Index: sandbox/workflow/branches/609/inc/class.CachedLDAP.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.CachedLDAP.inc.php	(revision 1310)
+++ sandbox/workflow/branches/609/inc/class.CachedLDAP.inc.php	(revision 2233)
@@ -97,8 +97,8 @@
 
 		/* load the information and establish a connection */
-		$tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$tmpLDAP =& Factory::getInstance('WorkflowLDAP');
 		$this->userContext  = $tmpLDAP->getUserContext();
 		$this->groupContext = $tmpLDAP->getGroupContext();
-		$this->dataSource = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->dataSource =& Factory::getInstance('WorkflowObjects')->getLDAP();
 	}
 
@@ -115,5 +115,5 @@
 
 		/* establish a connection */
-		$this->DBLink = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->DBLink =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 	}
 
Index: sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php	(revision 989)
+++ sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php	(revision 2233)
@@ -127,5 +127,5 @@
 		}
 
-		if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
+		if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
 		{
 			$proc_ids = $this->workflow_acl->get_granted_processes($GLOBALS['phpgw_info']['user']['account_id']);
@@ -589,5 +589,5 @@
 
 			$myp_id = $item['wf_p_id'];
-			$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+			$templateServer = &Factory::getInstance('TemplateServer');
 			$this->t->set_var(array(
 				'item_wf_p_id'		=> $myp_id,
Index: sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 2233)
@@ -91,6 +91,6 @@
 		$this->userID = $_SESSION['phpgw_info']['workflow']['account_id'];
 		$this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin'];
-		$this->acl = &$GLOBALS['ajax']->acl;
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->acl =& $GLOBALS['ajax']->acl;
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 	}
 
Index: sandbox/workflow/branches/609/inc/class.workflow_activitymanager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_activitymanager.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_activitymanager.inc.php	(revision 2233)
@@ -20,5 +20,5 @@
 		function workflow_activitymanager()
 		{
-			parent::ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.WorkflowObjects.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowObjects.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowObjects.inc.php	(revision 2233)
@@ -87,5 +87,5 @@
 			{
 				/* connect to the database */
-				$this->cache['DBGalaxia'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db'));
+				$this->cache['DBGalaxia'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db'));
 				$this->cache['DBGalaxia']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */
 				$this->cache['DBGalaxia']->Halt_On_Error = 'no';
@@ -98,6 +98,6 @@
 					$dbConfigValues['workflow_database_type']
 				);
-				$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']);
-				$this->cache['DBGalaxia']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBGalaxia']->Link_ID);
+				Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']);
+				$this->cache['DBGalaxia']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBGalaxia']->Link_ID);
 			}
 			else
@@ -128,5 +128,5 @@
 			if (!isset($connectionInfo['db_name']))
 			{
-				$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+				Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 				if (isset($GLOBALS['phpgw_info']['server']))
 					$connectionInfo = $GLOBALS['phpgw_info']['server'];
@@ -136,5 +136,5 @@
 
 			/* connect to the database */
-			$this->cache['DBExpresso'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db'));
+			$this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db'));
 			$this->cache['DBExpresso']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */
 			$this->cache['DBExpresso']->Halt_On_Error = 'no';
@@ -147,6 +147,6 @@
 				$connectionInfo['db_type']
 			);
-			$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']);
-			$this->cache['DBExpresso']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBExpresso']->Link_ID);
+			Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']);
+			$this->cache['DBExpresso']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBExpresso']->Link_ID);
 		}
 
@@ -177,5 +177,5 @@
 
 			/* connect to the database */
-			$this->cache['DBWorkflow'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db'));
+			$this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db'));
 			$this->cache['DBWorkflow']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */
 			$this->cache['DBWorkflow']->Halt_On_Error = 'no';
@@ -188,6 +188,6 @@
 				$dbConfigValues['database_type']
 			);
-			$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']);
-			$this->cache['DBWorkflow']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBWorkflow']->Link_ID);
+			Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']);
+			$this->cache['DBWorkflow']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBWorkflow']->Link_ID);
 		}
 
Index: sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php	(revision 2233)
@@ -67,12 +67,12 @@
 		{
 			$GLOBALS['ajax']->ldap = new ajax_ldap();
-			$GLOBALS['ajax']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
+			$GLOBALS['ajax']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
 			$GLOBALS['ajax']->db->Halt_On_Error = 'no';
 
-			$GLOBALS['ajax']->db_workflow = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow();
+			$GLOBALS['ajax']->db_workflow =& Factory::getInstance('WorkflowObjects')->getDBWorkflow();
 			$GLOBALS['ajax']->db_workflow->Halt_On_Error = 'no';
 
 			$GLOBALS['phpgw']->ADOdb = &$GLOBALS['ajax']->db->Link_ID;
-			$GLOBALS['ajax']->acl = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			$GLOBALS['ajax']->acl = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 		else
Index: sandbox/workflow/branches/609/inc/class.UserPictureProvider.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.UserPictureProvider.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.UserPictureProvider.inc.php	(revision 2233)
@@ -114,5 +114,5 @@
 					/* em último caso, tenta buscar a informação em banco de dados */
 					/* prepara o ambiente para a carga de informações sobre o banco de dados */
-					$result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'));
+					$result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'));
 					if (empty($result))
 						return;
@@ -141,5 +141,5 @@
 				mkdir($baseDirectory, 0770, true);
 
-			$contents = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserPicture($this->userID);
+			$contents = Factory::getInstance('WorkflowLDAP')->getUserPicture($this->userID);
 			$success = true;
 			if ($contents !== false)
@@ -165,5 +165,5 @@
 		}
 
-		$GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($filename);
+		Factory::getInstance('ResourcesRedirector')->show($filename);
 	}
 }
Index: sandbox/workflow/branches/609/inc/class.ui_external_applications.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_external_applications.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_external_applications.inc.php	(revision 2233)
@@ -49,5 +49,5 @@
 	function draw()
 	{
-		if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
+		if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
 		{
 			$GLOBALS['phpgw']->common->phpgw_header();
Index: sandbox/workflow/branches/609/inc/class.workflow_rolemanager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_rolemanager.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_rolemanager.inc.php	(revision 2233)
@@ -17,5 +17,5 @@
 		function workflow_rolemanager()
 		{
-			parent::RoleManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::RoleManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.so_agent.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_agent.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.so_agent.inc.php	(revision 2233)
@@ -26,8 +26,8 @@
 {
 	//public functions
-	
+
 	/**
 	 * @var array $public_functions Array of public functions
-	 * @access public 
+	 * @access public
 	 */
 	var $public_functions = array(
@@ -36,34 +36,34 @@
 	);
 	/**
-	 * @var array $wf_table 
+	 * @var array $wf_table
 	 * @access public
 	 */
 	var $wf_table = 'egw_wf_agent_';
 	/**
-	 * @var string $agent_table 
+	 * @var string $agent_table
 	 * @access public
 	 */
 	var $agent_table = '';
-	
+
 	// link to the global db-object
-	
+
 	/**
-	 * @var object $db objeto para conexao do banco de dados 
+	 * @var object $db objeto para conexao do banco de dados
 	 * @access public
 	 */
 	var $db;
-	
+
 	/**
 	 * Constructor of the so_agent class
 	 * do not forget to call it (parent::so_agent();) in child classes
 	 * @access public
-	 * @return object 
+	 * @return object
 	 */
-	
+
 	function so_agent()
 	{
-		$this->db =& $GLOBALS['workflow']['workflowObjects']->getDBGalaxia();
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia();
 	}
-	
+
 	/**
 	 * @abstract read all agent datas from the database
Index: sandbox/workflow/branches/609/inc/class.WorkflowSecurity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowSecurity.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowSecurity.inc.php	(revision 2233)
@@ -51,5 +51,5 @@
 	{
 		/* garante que o objeto de DataBase do Expresso estará disponível */
-		$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
+		Factory::getInstance('WorkflowObjects')->getDBExpresso();
 	}
 
@@ -77,5 +77,5 @@
 				continue;
 			$this->removeSensitiveInformationFromDatabaseObject($variable);
-			$variable = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $variable);
+			$variable = Factory::newInstance('WorkflowWatcher', $variable);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/engine/config.egw.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/config.egw.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/config.egw.inc.php	(revision 2233)
@@ -151,5 +151,5 @@
 	function galaxia_user_can_admin_process()
 	{
-		return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_workflow', 1, 'workflow'));
+		return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_workflow', 1, 'workflow'));
 	}
 }
@@ -165,5 +165,5 @@
 	function galaxia_user_can_admin_instance()
 	{
-		return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_instance_workflow', 1, 'workflow'));
+		return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_instance_workflow', 1, 'workflow'));
 	}
 }
@@ -179,5 +179,5 @@
 	function galaxia_user_can_clean_instances()
 	{
-		return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_workflow', 1, 'workflow'));
+		return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_workflow', 1, 'workflow'));
 	}
 }
@@ -191,5 +191,5 @@
 	function galaxia_user_can_clean_aborted_instances()
 	{
-		return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_aborted_workflow', 1, 'workflow'));
+		return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_aborted_workflow', 1, 'workflow'));
 	}
 }
@@ -203,5 +203,5 @@
 	function galaxia_user_can_monitor()
 	{
-		return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('monitor_workflow', 1, 'workflow'));
+		return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('monitor_workflow', 1, 'workflow'));
 	}
 }
@@ -221,5 +221,5 @@
 				$user = $GLOBALS['phpgw_info']['user']['account_id'];
 
-			$memberships = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($user);
+			$memberships = Factory::getInstance('WorkflowLDAP')->getUserGroups($user);
 
 			if ($memberships === false)
@@ -245,5 +245,5 @@
 		{
 			/* get information regarding the members of the group */
-			$members = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getGroupUsers($group);
+			$members = &Factory::getInstance('WorkflowLDAP')->getGroupUsers($group);
 
 			/* checl for error in the LDAP query */
Index: sandbox/workflow/branches/609/inc/engine/class.ajax_ldap.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/class.ajax_ldap.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/class.ajax_ldap.inc.php	(revision 2233)
@@ -29,9 +29,9 @@
 	function ajax_ldap()
 	{
-		$tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$tmpLDAP = &Factory::getInstance('WorkflowLDAP');
 		$this->user_context  = $tmpLDAP->getUserContext();
 		$this->group_context = $tmpLDAP->getGroupContext();
 
-		$this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->ds =& Factory::getInstance('WorkflowObjects')->getLDAP();
 	}
 
@@ -83,5 +83,5 @@
 	function id2fullname($account_id)
     {
-		return $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($account_id);
+		return Factory::getInstance('WorkflowLDAP')->getName($account_id);
     }
 
@@ -107,5 +107,5 @@
 			$accountID = $_SESSION['phpgw_info']['workflow']['account_id'];
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap =& Factory::getInstance('WorkflowLDAP');
 		if (count($output = $ldap->getUserGroups($accountID)) == 0)
 			return false;
Index: sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php	(revision 2233)
@@ -170,5 +170,5 @@
 		if ($loadGroups)
 		{
-			$memberships = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($user);
+			$memberships = Factory::getInstance('WorkflowLDAP')->getUserGroups($user);
 			if ($user == $_SESSION['phpgw_info']['workflow']['account_id'])
 				$_SESSION['phpgw_info']['workflow']['user_groups'] = $memberships;
@@ -196,5 +196,5 @@
 		{
 			/* get information regarding the members of the group */
-			$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+			$ldap = &Factory::getInstance('WorkflowLDAP');
 			$members = $ldap->getGroupUsers($group);
 
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php	(revision 2233)
@@ -247,5 +247,5 @@
     $result = $this->query($query,$bindvars);
     $ret = Array();
-    $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+    $ldap = &Factory::getInstance('WorkflowLDAP');
     if (!(empty($result)))
     {
Index: sandbox/workflow/branches/609/inc/engine/class.ajax_config.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/class.ajax_config.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/class.ajax_config.inc.php	(revision 2233)
@@ -45,5 +45,5 @@
 		}
 
-		$this->db      = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
+		$this->db      =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
 		$this->appname = $appname;
   	}
@@ -51,5 +51,5 @@
  	/**
    	* Reads the whole repository for $this->appname, appname has to be set via the constructor
-   	* 
+   	*
    	* @return array the whole config-array for that app
    	* @access public
Index: sandbox/workflow/branches/609/inc/class.workflow_process.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_process.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_process.inc.php	(revision 2233)
@@ -16,5 +16,5 @@
 		function workflow_process()
 		{
-			parent::Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php	(revision 2233)
@@ -57,6 +57,6 @@
 	{
 		$this->currentDate = new DateTime(date('Y-n-j G:i:00'));
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
-		$this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager');
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
+		$this->jobManager = &Factory::getInstance('WorkflowJobManager');
 	}
 
@@ -171,5 +171,5 @@
 		$previousDir = getcwd();
 		chdir(GALAXIA_LIBRARY . '/../');
-		$output = $GLOBALS['workflow']['factory']->newInstance('Thread', 'class.JobRunner.inc.php "' . $parameters . '"');
+		$output = Factory::newInstance('Thread', 'class.JobRunner.inc.php "' . $parameters . '"');
 		chdir($previousDir);
 		return $output;
@@ -192,5 +192,5 @@
 {
 	require_once 'common.inc.php';
-	$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+	Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 
 	$job = new JobScheduler();
Index: sandbox/workflow/branches/609/inc/class.so_orgchart.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_orgchart.inc.php	(revision 2063)
+++ sandbox/workflow/branches/609/inc/class.so_orgchart.inc.php	(revision 2233)
@@ -127,6 +127,6 @@
 		$this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin'];
 		$this->acl = &$GLOBALS['ajax']->acl;
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
 		$this->db->SetFetchMode(ADODB_FETCH_ASSOC);
 	}
@@ -711,5 +711,5 @@
 
 		$output = $result->GetArray(-1);
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE);
 		for ($i = 0; $i < count($output); $i++)
@@ -765,6 +765,6 @@
 
 		/* search for the $searchTerm in the LDAP */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
-		$list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), $ldapSearch, array('uidnumber', 'cn', 'uid'));
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
+		$list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), $ldapSearch, array('uidnumber', 'cn', 'uid'));
 		if ($list === false)
 			die(serialize("O sistema de busca não pode ser utilizado nesta organização."));
@@ -774,5 +774,5 @@
 
 		/* search for the $searchTerm in the DB */
-		$resultSet = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query($DBSearch, $DBValues)->GetArray(-1);
+		$resultSet = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query($DBSearch, $DBValues)->GetArray(-1);
 		foreach ($resultSet as $row)
 			if (!isset($unifiedResult[$row['uidnumber']]))
@@ -823,5 +823,5 @@
 		{
 			$errors = array(
-				"O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($employeeID) . "\" já pertença à área \"{$row['sigla']}\".",
+				"O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($employeeID) . "\" já pertença à área \"{$row['sigla']}\".",
 				'-----------------',
 				'Caso você queira colocá-lo na área selecionada, siga o procedimento: faça uma busca por seu nome, clique para editá-lo e, troque pela área desejada.'
@@ -881,5 +881,5 @@
 		{
 			$errors = array(
-				"O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($employeeID) . "\" é titular, substituto, já participou de substituição ou é auxiliar administrativo das seguintes áreas: " . implode(", ", $areas),
+				"O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($employeeID) . "\" é titular, substituto, já participou de substituição ou é auxiliar administrativo das seguintes áreas: " . implode(", ", $areas),
 				'-----------------',
 				'Se você quiser excluir este funcionário, precisa removê-lo dos "cargos" que ele possui nas áreas citadas.'
@@ -919,5 +919,5 @@
 		$this->_checkError($result);
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
 		{
@@ -999,5 +999,5 @@
 			$query = 'SELECT 1 FROM funcionario WHERE (funcionario_id = ?)';
 			if (!$this->db->query($query, $checkEmployee)->fetchRow())
-				$errors[] = "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área.";
+				$errors[] = "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área.";
 		}
 
@@ -1044,5 +1044,5 @@
 			$query = 'SELECT 1 FROM funcionario WHERE (funcionario_id = ?)';
 			if (!$this->db->query($query, $checkEmployee)->fetchRow())
-				$errors[] = "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área.";
+				$errors[] = "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área.";
 		}
 
@@ -1096,5 +1096,5 @@
 		$outputInfo = array();
 
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 
 		/* here we need fresh information. Let's access ldap first */
@@ -1262,5 +1262,5 @@
 		);
 
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE);
 		if (!empty($areaInfo['titular_funcionario_id']))
@@ -1512,5 +1512,5 @@
 
 		/* we must query ldap to get full user names. In workflow db we just store uids */
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 
 		$cachedLDAP->getEntryByID();
Index: sandbox/workflow/branches/609/inc/class.so_adminaccess.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_adminaccess.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.so_adminaccess.inc.php	(revision 2233)
@@ -77,5 +77,5 @@
 	{
 		$output = array();
-		$names = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames($userIDs);
+		$names = Factory::getInstance('WorkflowLDAP')->getNames($userIDs);
 		foreach ($names as $name)
 			$output[] = array(
@@ -201,6 +201,6 @@
 		if (!is_object($GLOBALS['phpgw']->acl))
 		{
-			$GLOBALS['phpgw']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
-			$GLOBALS['phpgw']->acl = &$GLOBALS['workflow']['factory']->getForeignInstance('phpgwapi', 'acl', $userID);
+			$GLOBALS['phpgw']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
+			$GLOBALS['phpgw']->acl =& Factory::getForeignInstance('phpgwapi', 'acl', $userID);
 		}
 
Index: sandbox/workflow/branches/609/inc/class.bo_participants.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_participants.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_participants.inc.php	(revision 2233)
@@ -34,5 +34,5 @@
 	function bo_participants()
 	{
-		$this->ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$this->ldap = &Factory::getInstance('WorkflowLDAP');
 	}
 
Index: sandbox/workflow/branches/609/inc/common.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/common.inc.php	(revision 2223)
+++ sandbox/workflow/branches/609/inc/common.inc.php	(revision 2233)
@@ -17,5 +17,13 @@
  * @name EGW_SERVER_ROOT
  */
-define('EGW_SERVER_ROOT', $HTTP_SERVER_VARS['DOCUMENT_ROOT']);
+define('EGW_SERVER_ROOT', $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']);
+
+/**
+ * Server include base path. We must define our own constants
+ * because there are several cases in which workflow is called
+ * directly, thus PHPGW constants are not defined.
+ * @name EGW_INC_ROOT
+ */
+define('EGW_INC_ROOT', EGW_SERVER_ROOT . '/phpgwapi/inc/');
 
 /**
Index: sandbox/workflow/branches/609/inc/class.ui_adminroles.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminroles.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_adminroles.inc.php	(revision 2233)
@@ -254,8 +254,8 @@
 			$this->t->set_var('list_mappings', '<tr><td colspan="3" align="center">'. lang('There are no mappings defined for this process')  .'</td></tr>');
 		}
-		else {	
+		else {
 			/* load the LDAP information */
-			$cachedLDAP = $GLOBALS['workflow']['factory']->getInstance('CachedLDAP');
-			$tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+			$cachedLDAP = Factory::getInstance('CachedLDAP');
+			$tmpLDAP = &Factory::getInstance('WorkflowLDAP');
 			$userContext  = $tmpLDAP->getUserContext();
 			$groupContext = $tmpLDAP->getGroupContext();
@@ -264,10 +264,10 @@
 			{
 				if ($mapping['wf_account_type'] == 'g') {
-					$sri = ldap_search($GLOBALS['workflow']['workflowObjects']->getLDAP(), 
-									$groupContext, 
+					$sri = ldap_search(Factory::getInstance('WorkflowObjects')->getLDAP(),
+									$groupContext,
 									'(&(gidnumber=' . (int)$mapping['wf_user'] . ')(phpgwAccountType=g))');
-									
-					$allValues = ldap_get_entries($GLOBALS['workflow']['workflowObjects']->getLDAP(), $sri);
-					
+
+					$allValues = ldap_get_entries(Factory::getInstance('WorkflowObjects')->getLDAP(), $sri);
+
 					$cname = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
 					$glabel = '[' . lang('Group') . ']';
@@ -280,5 +280,5 @@
 						$glabel = '<font color="red">(excluído)</font>';
 				}
-				
+
 				$this->t->set_var(array(
 					'map_user_id'	=> $mapping['wf_user'],
@@ -313,9 +313,9 @@
 	 * Show users roles selects
 	 * @param string $all_roles_data
-	 * @return 
+	 * @return
 	 */
 	function show_users_roles_selects($all_roles_data)
 	{
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer = &Factory::getInstance('TemplateServer');
 		$imgaddusers = $templateServer->generateImageLink('add_group.png');
 		$imgdelusers = $templateServer->generateImageLink('delete_group.png');
@@ -325,5 +325,5 @@
 			'src_img_del_users' => $imgdelusers
 		));
-		
+
 		$this->t->set_block('admin_roles', 'block_select_roles', 'select_roles');
 		foreach ($all_roles_data as $role)
Index: sandbox/workflow/branches/609/inc/class.WorkflowUtils.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowUtils.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowUtils.inc.php	(revision 2233)
@@ -107,5 +107,5 @@
 		/**
 		 * Fill the process bar
-		 * 
+		 *
 		 * @param array $proc_info
 		 * @access public
@@ -116,5 +116,5 @@
 			//echo "proc_info: <pre>";print_r($proc_info);echo "</pre>";
 			$this->t->set_file('proc_bar_tpl', 'proc_bar.tpl');
-			$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+			$templateServer = &Factory::getInstance('TemplateServer');
 
 			if ($proc_info['wf_is_valid'] == 'y')
@@ -170,5 +170,5 @@
 		/**
 		 * Select activity representation icon
-		 *  
+		 *
 		 * @var string $type type of activity
 		 * @var bool   $interactive interactive?
@@ -207,10 +207,10 @@
 					$ic="no-activity.gif";
 			}
-			return '<img src="'. $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink($ic) .'" alt="'. lang($type) .'" title="'. lang($type) .'" />';
-		}
-	
+			return '<img src="'. Factory::getInstance('TemplateServer')->generateImageLink($ic) .'" alt="'. lang($type) .'" title="'. lang($type) .'" />';
+		}
+
 		/**
 		 * Translate template file
-		 * @param string $template_name template name 
+		 * @param string $template_name template name
 		 * @return void
 		 * @access public
@@ -387,12 +387,12 @@
 		{
 			$file = "css/$css_name" . (($print_mode !== false) ? '_print' : '') . '.css';
-			return $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->getWebFile($file);
-		}
-		
+			return Factory::getInstance('TemplateServer')->getWebFile($file);
+		}
+
 		/**
 		 * Return a given duration in human readable form, usefull for workitems duration
 		 * @param int $to given duration
 		 * @return string given duration in human readable form
-		 * @access public 
+		 * @access public
 		 */
 		function time_diff($to) {
Index: sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 2233)
@@ -40,5 +40,5 @@
 		require dirname(__FILE__) . '/../setup/setup.inc.php'; /* DO NOT USE require_once */
 		$GLOBALS['phpgw_info']['apps']['workflow'] = $setup_info['workflow'];
-		$row = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow();
+		$row = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow();
 		$_SESSION['phpgw_info']['workflow']['vfs_basedir'] = ($row !== false) ? $row['config_value'] : '/home/expressolivre';
 		$_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC;
@@ -67,5 +67,5 @@
 		require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
 
-		$runtime = new WfRuntime($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$runtime = new WfRuntime(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$runtime->loadProcess($processID);
 
Index: sandbox/workflow/branches/609/inc/class.ui_participants.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_participants.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_participants.inc.php	(revision 2233)
@@ -41,5 +41,5 @@
 	function ui_participants()
 	{
-		$this->bo = $GLOBALS['workflow']['factory']->getInstance('bo_participants');
+		$this->bo = Factory::getInstance('bo_participants');
 	}
 
@@ -51,9 +51,9 @@
 	function form()
 	{
-		$smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false);
+		$smarty = Factory::getInstance('workflow_smarty', false);
 		$smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER);
-		$ldap = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = Factory::getInstance('WorkflowLDAP');
 		$userDN = $GLOBALS['phpgw_info']['user']['account_dn'];
-		$account = $GLOBALS['workflow']['factory']->getForeignInstance('phpgwapi', 'accounts', $userDN);
+		$account = Factory::getInstance('accounts', $userDN);
 		$organizationList = $this->bo->getOrganizations();
 
Index: sandbox/workflow/branches/609/inc/class.external_bridge.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.external_bridge.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.external_bridge.inc.php	(revision 2233)
@@ -52,6 +52,6 @@
 	function external_bridge()
 	{
-		$this->db = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia();
-		$this->acl = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$this->db = Factory::getInstance('WorkflowObjects')->getDBGalaxia();
+		$this->acl = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 	/**
@@ -156,5 +156,5 @@
 
 		/* assign variables to the template */
-		$smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false);
+		$smarty = Factory::getInstance('workflow_smarty', false);
 		$smarty->assign('encodedForm', $encodedForm);
 		$smarty->assign('siteAddress', $this->siteAddress);
Index: sandbox/workflow/branches/609/inc/class.workflow_instance.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_instance.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_instance.inc.php	(revision 2233)
@@ -20,5 +20,5 @@
 		function workflow_Instance()
 		{
-			parent::Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2094)
+++ sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2233)
@@ -22,5 +22,5 @@
 	function so_userinterface()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
 		$this->db->SetFetchMode(ADODB_FETCH_ASSOC);
 	}
@@ -93,5 +93,5 @@
 		if (!empty($externalApplicationsID))
 		{
-			$result = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query("SELECT DISTINCT external_application_id, name, address, image, authentication, intranet_only FROM egw_wf_external_application WHERE (external_application_id IN (" . implode(', ', $externalApplicationsID)  . ")) ORDER BY name");
+			$result = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query("SELECT DISTINCT external_application_id, name, address, image, authentication, intranet_only FROM egw_wf_external_application WHERE (external_application_id IN (" . implode(', ', $externalApplicationsID)  . ")) ORDER BY name");
 			$preOutput = $result->GetArray(-1);
 
@@ -245,5 +245,5 @@
 
 		$employees = $result->GetArray(-1);
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_NORMAL);
 		$categoriesCount = array();
@@ -318,5 +318,5 @@
 
 		$employees = $result->GetArray(-1);
-		$cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = Factory::newInstance('CachedLDAP');
 		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_NORMAL);
 		for ($i = 0; $i < count($employees); $i++)
@@ -370,5 +370,5 @@
 
 		/* searching employees by name in the ldap server */
-		$list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(cn=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber'));
+		$list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(cn=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber'));
 		if ($list === false)
 			return false;
@@ -466,5 +466,5 @@
 
 		/* executing it */
-		$list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), $ldap_query, array('uidNumber', 'cn', 'telephoneNumber'));
+		$list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), $ldap_query, array('uidNumber', 'cn', 'telephoneNumber'));
 		$entries = ldap_get_entries($ldap, $list);
 
@@ -475,5 +475,5 @@
 
 		/* we will need to search into database 'cache' for users deleted in ldap */
-		$cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' );
+		$cachedLDAP = Factory::newInstance( 'CachedLDAP' );
 		$cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_DATABASE );
 
@@ -531,5 +531,5 @@
 
 		/* searching employees by telephoneNumber in the ldap server */
-		$list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(telephoneNumber=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber'));
+		$list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(telephoneNumber=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber'));
 
 		if (!$list) return false;
@@ -652,5 +652,5 @@
 		$result = $this -> db -> query( "SELECT a.sigla as area, a.titular_funcionario_id as titular, s.funcionario_id as substituto, s.data_inicio, s.data_fim FROM area a INNER JOIN substituicao s ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) WHERE (organizacao_id = ?) ORDER BY area", array( $organizationID ) );
 
-		$cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' );
+		$cachedLDAP = Factory::newInstance( 'CachedLDAP' );
 		$cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_LDAP_DATABASE );
 
@@ -719,5 +719,5 @@
 
 		$employees = $result -> GetArray( -1 );
-		$cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' );
+		$cachedLDAP = Factory::newInstance( 'CachedLDAP' );
 		$cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_NORMAL );
 
@@ -791,5 +791,5 @@
 		$employees = $result -> GetArray( -1 );
 
-		$cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' );
+		$cachedLDAP = Factory::newInstance( 'CachedLDAP' );
 		$cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_NORMAL );
 
@@ -817,5 +817,5 @@
 		usort( $employees, create_function( '$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);' ) );
 
-		$paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 50, $_POST);
+		$paging = Factory::newInstance('Paging', 50, $_POST);
 		$employees = $paging->restrictItems( $employees );
 
Index: sandbox/workflow/branches/609/inc/class.WorkflowJobManager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowJobManager.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowJobManager.inc.php	(revision 2233)
@@ -16,5 +16,5 @@
 	public function WorkflowJobManager()
 	{
-		parent::JobManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		parent::JobManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 }
Index: sandbox/workflow/branches/609/inc/class.ui_ajaxinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_ajaxinterface.inc.php	(revision 1452)
+++ sandbox/workflow/branches/609/inc/class.ui_ajaxinterface.inc.php	(revision 2233)
@@ -56,12 +56,12 @@
 		$vfs = createobject('phpgwapi.vfs');
 		$_SESSION['phpgw_info']['workflow']['vfs_basedir'] = $vfs->basedir;
-		$_SESSION['phpgw_info']['workflow']['server'] = $GLOBALS['phpgw_info']['server'];			
+		$_SESSION['phpgw_info']['workflow']['server'] = $GLOBALS['phpgw_info']['server'];
 		$_SESSION['phpgw_info']['workflow']['lang'] = $GLOBALS['lang'];
 		$_SESSION['phpgw_info']['workflow']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
-		$_SESSION['phpgw_info']['workflow']['user_groups'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($GLOBALS['phpgw_info']['user']['account_id']);
+		$_SESSION['phpgw_info']['workflow']['user_groups'] = Factory::getInstance('WorkflowLDAP')->getUserGroups($GLOBALS['phpgw_info']['user']['account_id']);
 		$user_is_admin = $acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']);
-		$_SESSION['phpgw_info']['workflow']['user_is_admin'] = $user_is_admin; 
+		$_SESSION['phpgw_info']['workflow']['user_is_admin'] = $user_is_admin;
 		$_SESSION['phpgw_info']['workflow']['user_can_admin_process'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_workflow',1,'workflow')));
-		$_SESSION['phpgw_info']['workflow']['user_can_admin_instance'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_instance_workflow',1,'workflow'))); 
+		$_SESSION['phpgw_info']['workflow']['user_can_admin_instance'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_instance_workflow',1,'workflow')));
 
 		$can_monitor = $acl->checkUserGroupAccessToType('MON', $GLOBALS['phpgw_info']['user']['account_id']);
@@ -118,5 +118,5 @@
 	{
 		$CSSName = "css/{$CSSName}.css";
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer = &Factory::getInstance('TemplateServer');
 		$CSSLink = $templateServer->getWebFile($CSSName);
 		$CSSFile = $templateServer->getSystemFile($CSSName);
Index: sandbox/workflow/branches/609/inc/class.JobRunner.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.JobRunner.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.JobRunner.inc.php	(revision 2233)
@@ -43,5 +43,5 @@
 		$this->parameters = unserialize(base64_decode($parameters));
 		$this->parameters['currentDate'] = new DateTime($this->parameters['currentDate']);
-		$this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager');
+		$this->jobManager =& Factory::getInstance('WorkflowJobManager');
 	}
 
@@ -66,5 +66,5 @@
 	{
 		/* activate the security policy */
-		$GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy();
+		Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy();
 
 		if (!file_exists($this->parameters['file']))
@@ -94,5 +94,5 @@
 
 require_once 'common.inc.php';
-$GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment();
+Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 
 $jobRunner = new JobRunner($argv[1]);
Index: sandbox/workflow/branches/609/inc/class.ui_adminsource.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminsource.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_adminsource.inc.php	(revision 2233)
@@ -78,5 +78,5 @@
 	function form()
 	{
-		$smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false);
+		$smarty = Factory::getInstance('workflow_smarty', false);
 		$smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_NAVIGATION_BAR | workflow_smarty::SHOW_FOOTER, $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('Admin Processes Sources'));
 
Index: sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php	(revision 2233)
@@ -96,5 +96,5 @@
 		$this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin'];
 		$this->acl = &$GLOBALS['ajax']->acl;
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->jobManager = new JobManager(&$this->db);
 	}
@@ -229,5 +229,5 @@
 		$output = array();
 		$job = $this->jobManager->getJob($jobID);
-		$jobScheduler = &$GLOBALS['workflow']['factory']->getInstance('JobScheduler');
+		$jobScheduler =& Factory::getInstance('JobScheduler');
 		$totalTime = microtime(true);
 		$thread = $jobScheduler->execute($job, true);
Index: sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php	(revision 1710)
+++ sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php	(revision 2233)
@@ -374,5 +374,5 @@
 		// fill proc_bar
 		$this->t->set_var('proc_bar', $this->fill_proc_bar($proc_info));
-		
+
 		//collect some messages from used objects
 		$this->message[] = $this->activity_manager->get_error(false, _DEBUG);
@@ -380,5 +380,5 @@
 		$this->message[] = $this->role_manager->get_error(false, _DEBUG);
 
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer = &Factory::getInstance('TemplateServer');
 
 		// fill the general variables of the template
@@ -732,5 +732,5 @@
 			$this->translate_template('block_process_activities_header');
 			$this->t->parse('process_activities_header', 'block_process_activities_header', True);
-			$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+			$templateServer = &Factory::getInstance('TemplateServer');
 			foreach ($process_activities_data as $activity)
 			{
@@ -792,5 +792,5 @@
 				'trans_href_from'	=> $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminactivities.form&where2='. $where2 .'&sort_mode2='. $sort_mode2 .'&p_id='. $this->wf_p_id .'&find='. $find .'&where='. $where .'&sort_mode='. $this->sort_mode .'&activity_id='. $transition['wf_act_from_id']),
 				'trans_actFromName'	=> $transition['wf_act_from_name'],
-				'trans_arrow'		=> $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('next.gif'),
+				'trans_arrow'		=> Factory::getInstance('TemplateServer')->generateImageLink('next.gif'),
 				'trans_href_to'		=> $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminactivities.form&where2='. $where2 .'&sort_mode2='. $sort_mode2 .'&p_id='. $this->wf_p_id .'&find='. $find .'&where='. $where .'&sort_mode='. $this->sort_mode .'&activity_id='. $transition['wf_act_to_id']),
 				'trans_actToName'	=> $transition['wf_act_to_name'],
@@ -1036,5 +1036,5 @@
 		$image_name = $proc_info['wf_normalized_name'] . SEP . 'graph' . SEP . $proc_info['wf_normalized_name'] . '.png';
 		$image = GALAXIA_PROCESSES . SEP . $image_name;
-		if ($GLOBALS['workflow']['factory']->getInstance('BrowserInfo')->isOpera())
+		if (Factory::getInstance('BrowserInfo')->isOpera())
 			$maximumDimension = 1000000;
 		else
@@ -1069,5 +1069,5 @@
 		}
 	}
-	
+
 	/**
 	 * Dislays the activity agents config rows
@@ -1090,5 +1090,5 @@
 			}
 			$this->translate_template('admin_agents');
-												$this->t->parse('agents_config_rows', 'admin_agents');
+			$this->t->parse('agents_config_rows', 'admin_agents');
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.workflow_wfruntime.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_wfruntime.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_wfruntime.inc.php	(revision 2233)
@@ -18,5 +18,5 @@
 		function workflow_wfruntime()
 		{
-			parent::WfRuntime($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::WfRuntime(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.WorkflowLDAP.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowLDAP.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.WorkflowLDAP.inc.php	(revision 2233)
@@ -50,5 +50,5 @@
 	function WorkflowLDAP()
 	{
-		$this->dataSource = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->dataSource =& Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		/* get the required parameters */
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_user.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_user.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_user.php	(revision 2233)
@@ -94,5 +94,5 @@
 		$extraParams .= "&hideSectors=1";
 
-	$image = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('add_user.png');
+	$image = Factory::getInstance('TemplateServer')->generateImageLink('add_user.png');
 
 $output .= <<<EOF
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_state.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_state.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_state.php	(revision 2233)
@@ -46,5 +46,5 @@
 	$sql = "SELECT id_state, state_name FROM phpgw_cc_state WHERE id_country = 'BR' ORDER BY state_name";
 
-	$result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query($sql);
+	$result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query($sql);
 	$estados = array();
 	while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_ldap_users.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_ldap_users.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_ldap_users.php	(revision 2233)
@@ -25,5 +25,5 @@
 {
     require_once $smarty->_get_plugin_filepath('function','html_options');
-	$imagesPath = substr($GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink(''), 0, -1);
+	$imagesPath = substr(Factory::getInstance('TemplateServer')->generateImageLink(''), 0, -1);
 
 	$requiredParams = array(
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_city.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_city.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_city.php	(revision 2233)
@@ -37,14 +37,14 @@
 		if (!array_key_exists($required, $params) || (empty($params[$required])))
 			$smarty->trigger_error("[wf_select_city] missing required parameter(s): $required", E_USER_ERROR);
-	
+
 	/* atribui valores default para os parâmetros não passados */
 	foreach ($defaultValues as $key => $value)
 		if (!isset($params[$key]))
 			$params[$key] = $value;
-	
+
 	/* extrai alguns parâmetros da matriz de parâmetros */
 	foreach ($extractParams as $extract)
 		$$extract = $params[$extract];
-	
+
 	/* parâmetros extras são "acumulados" em uma única variável */
 	$extraParams = array();
@@ -53,5 +53,5 @@
 			$extraParams[$key] = $value_params;
 
-	$db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;
+	$db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID;
 	if (isset($params['value']))
 	{
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_generic_select.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_generic_select.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_generic_select.php	(revision 2233)
@@ -53,5 +53,5 @@
 EOF;
 
-	$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+	$templateServer = &Factory::getInstance('TemplateServer');
 	$imageAdd = $templateServer->generateImageLink('add.png');
 	$imageRemove = $templateServer->generateImageLink('close.png');
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/prefilter.wf_default_template.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/prefilter.wf_default_template.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/prefilter.wf_default_template.php	(revision 2233)
@@ -31,5 +31,5 @@
 	{
 		/* get the header and footer location */
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer = &Factory::getInstance('TemplateServer');
 		$header = $templateServer->getSystemFile('processes/header.tpl');
 		$footer = $templateServer->getSystemFile('processes/footer.tpl');
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_redir_menu.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_redir_menu.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_redir_menu.php	(revision 2233)
@@ -53,9 +53,10 @@
 	$select_tag .= "<option value=\"og\">Organograma</option>";
 
-	$user_is_admin = $GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']);
-	if ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_workflow',1,'workflow'))) {
+	$user_is_admin = Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']);
+	$phpgw =& Factory::getForeignInstance('phpgwapi','phpgw');
+	if ($user_is_admin || ($phpgw->acl->check('admin_workflow',1,'workflow'))) {
 		$select_tag .= "<option value=\"ad\">Administração</option>";
 	}
-	if ($user_is_admin ||  ($GLOBALS['phpgw']->acl->check('monitor_workflow',1,'workflow'))) {
+	if ($user_is_admin ||  ($phpgw->acl->check('monitor_workflow',1,'workflow'))) {
 		$select_tag .= "<option value=\"mo\">Monitoramento</option>";
 	}
Index: sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_users.php
===================================================================
--- sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_users.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/smarty/wf_plugins/function.wf_select_users.php	(revision 2233)
@@ -16,5 +16,5 @@
 {
     require_once $smarty->_get_plugin_filepath('function','html_options');
-	$imagesPath = substr($GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink(''), 0, -1);
+	$imagesPath = substr(Factory::getInstance('TemplateServer')->generateImageLink(''), 0, -1);
 	$requiredParams = array(
 		'name');
Index: sandbox/workflow/branches/609/inc/class.workflow_gui.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_gui.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_gui.inc.php	(revision 2233)
@@ -20,5 +20,5 @@
 		function workflow_gui()
 		{
-			parent::GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php	(revision 2085)
+++ sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php	(revision 2233)
@@ -43,7 +43,7 @@
 	function bo_userinterface()
 	{
-		parent::bo_ajaxinterface();	
+		parent::bo_ajaxinterface();
 		$this->so = new so_userinterface();
-		$GLOBALS['ajax']->gui = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$GLOBALS['ajax']->gui = new GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 
@@ -68,5 +68,5 @@
 		$webserver_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url'];
 
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer =& Factory::getInstance('TemplateServer');
 		foreach ($result['data'] as $line)
 		{
@@ -78,5 +78,5 @@
 				$iconweb = $webserver_url . '/workflow/redirect.php?pid=' . $line['wf_p_id'] . '&file=/icon.png';
 			else
-				$iconweb = $templateServer->generateImageLink('navbar.png');
+				$iconweb = $templateServer->generateImageLink('default_process.png');
 			$procname_ver = $line['wf_normalized_name'];
 			if (!isset($recset[$procname_ver]))
@@ -120,17 +120,17 @@
 		$pid = $params['pid'];
 		$result = array();
-		
-		$process = new Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+
+		$process = new Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$process->getProcess($pid);
 		$result['wf_procname'] = $process->name;
 		$result['wf_version'] = $process->version;
 		$result['wf_description'] = $process->description;
-		
-		$activ_manager = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+
+		$activ_manager = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$result['wf_activities'] = $activ_manager->get_process_activities($pid);
-		
-		$this->disconnect_all();
-		
-		return $result; 
+
+		$this->disconnect_all();
+
+		return $result;
 	}
 
@@ -263,5 +263,5 @@
 				else
 					if ($row['wf_user'] != '')
-						$row['wf_user_fullname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($row['wf_user']);
+						$row['wf_user_fullname'] = Factory::getInstance('WorkflowLDAP')->getName($row['wf_user']);
 
 				/* unset unneeded information */
@@ -495,8 +495,8 @@
 		}
 
-		$instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$instance->getInstance($instanceID);
 
-		$process = new Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process = new Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$process->getProcess($instance->pId);
 
@@ -508,7 +508,7 @@
 			'wf_instance_id' => $instance->instanceId,
 			'wf_priority' => $instance->priority,
-			'wf_owner' => $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($instance->owner),
+			'wf_owner' => Factory::getInstance('WorkflowLDAP')->getName($instance->owner),
 			'wf_next_activity' => $instance->nextActivity,
-			'wf_next_user' => $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($instance->nextUser),
+			'wf_next_user' => Factory::getInstance('WorkflowLDAP')->getName($instance->nextUser),
 			'wf_name' => $instance->name,
 			'wf_category' => $instance->category,
@@ -526,5 +526,5 @@
     		$result['wf_ended'] = "";
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		foreach ($instance->workitems as $line)
 		{
@@ -657,5 +657,5 @@
 		$cod_process = array();
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		$viewActivitiesID = array();
 		foreach ($result['data'] as $row)
@@ -740,5 +740,5 @@
 	/**
 	 * Aplicacoes externas do usuario
-	 * @return array 
+	 * @return array
 	 * @access public
 	 */
@@ -746,5 +746,5 @@
 	{
 		$webserver_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url'];
-		$templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
+		$templateServer = &Factory::getInstance('TemplateServer');
 
 		/* load the sites that the user can access */
Index: sandbox/workflow/branches/609/inc/class.Logger.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.Logger.inc.php	(revision 900)
+++ sandbox/workflow/branches/609/inc/class.Logger.inc.php	(revision 2233)
@@ -80,5 +80,5 @@
 	{
 
-		$this->db =& $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID;
 
 		if(!empty($curProcessName)){
Index: sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php	(revision 2233)
@@ -100,5 +100,5 @@
 		/* paginate the result */
 		$logEntriesPerPage = 30;
-		$paging = &$GLOBALS['workflow']['factory']->newInstance('Paging', $logEntriesPerPage, $params);
+		$paging =& Factory::newInstance('Paging', $logEntriesPerPage, $params);
 		$logs = $paging->restrictItems($logs);
 
Index: sandbox/workflow/branches/609/inc/class.so_external_applications.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_external_applications.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.so_external_applications.inc.php	(revision 2233)
@@ -130,5 +130,5 @@
 		$this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin'];
 		$this->acl = &$GLOBALS['ajax']->acl;
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->EXTERNAL_APPLICATION_PATH = $_SESSION['phpgw_info']['workflow']['server']['files_dir'] . '/workflow//workflow/external_applications';
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php	(revision 2233)
@@ -80,5 +80,5 @@
 		$fileSizeUnit[] = 'Mb';
 		$fileSizeUnit[] = 'Gb';
-		
+
 		$unitSelect = 0;
 		while ($value > 1024.0)
@@ -87,26 +87,26 @@
 			$unitSelect++;
 		}
-	
+
 		$output = round($value, 1);
 		$output .= " " . $fileSizeUnit[$unitSelect];
-	
+
 		return $output;
 	}
-	
+
 	/**
 	* Get process toolbar data
-	* @param  array $p process process data 
-	* @return array
-	* @access public 
-	*/	
-	function get_toolbar_data($p) 
-	{
-		
-		$process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$proc_info       = $process_manager->get_process($p['proc_id']); 
-		
+	* @param  array $p process process data
+	* @return array
+	* @access public
+	*/
+	function get_toolbar_data($p)
+	{
+
+		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_info       = $process_manager->get_process($p['proc_id']);
+
 		$web_server_url  = $_SESSION['phpgw_info']['workflow']['server']['webserver_url'];
-		$img_default_dir = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('');
-		
+		$img_default_dir = Factory::getInstance('TemplateServer')->generateImageLink('');
+
 		if ($proc_info['wf_is_valid'] == 'y')
 		{
@@ -119,5 +119,5 @@
 			$alt_validity = tra('invalid');
 		}
-	
+
 		// if process is active show stop button. Else show start button, but only if it is valid. If it's not valid, don't show any activation or stop button.
 		if ($proc_info['wf_is_active'] == 'y')
@@ -138,5 +138,5 @@
 			$start_stop_img  = '';
 		}
-	
+
 		/* load other processes link */
 		$proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']);
@@ -145,10 +145,10 @@
 		else
 			$where = ' wf_p_id = -1 ';
-	
+
 		$processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where);
 		$otherProcesses = array();
 		foreach ($processesInfo['data'] as $pi)
 			$otherProcesses[] = array("name" => $pi['wf_name'] . " (v" . $pi['wf_version'] . ")", "link" => $web_server_url . "/index.php?menuaction=workflow.ui_adminsource.form&p_id=" . $pi['wf_p_id'], "pid" => $pi['wf_p_id']);
-	
+
 		$toolbar_data = array (
 			'proc_name'					=> $proc_info['wf_name'],
@@ -177,18 +177,18 @@
 			'other_processes'			=> $otherProcesses
 		);
-			
+
 		return $toolbar_data;
 		}
-		
-		
+
+
 	/**
 	* Get process model files
-	* @param  array $p process process data 
-	* @return array
-	* @access public 
+	* @param  array $p process process data
+	* @return array
+	* @access public
 	*/
 	function get_model_files($p)
 	{
-		switch($p['type']) 
+		switch($p['type'])
 		{
 			case 'include'  : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc';
@@ -203,9 +203,9 @@
 		$files          = array();
 
-		if ($handle = opendir($path)) 
-		{
-			while (false !== ($file_name = readdir($handle))) 
-			{	
-				if (!is_dir($path.SEP.$file_name)) 
+		if ($handle = opendir($path))
+		{
+			while (false !== ($file_name = readdir($handle)))
+			{
+				if (!is_dir($path.SEP.$file_name))
 				{
 					$files[] = array('file_name'     => $file_name);
@@ -217,21 +217,21 @@
 		array_multisort($col_file_name,SORT_ASC,$files);
 
-		return $files; 
+		return $files;
 	}
 
 	/**
 	* Get process php files
-	* @param array $p process data 
-	* @return array
-	* @access public 
+	* @param array $p process data
+	* @return array
+	* @access public
 	*/
 	function get_php_files($p)
 	{
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proc_info          = $process_manager->get_process($p['proc_id']);
-		$activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$activity_manager   = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP;
-		
+
 		$files = array();
 
@@ -242,10 +242,10 @@
 		foreach ($process_activities['data'] as $process_activity)
 		{
-			
+
 			$file_name   = $process_activity['wf_normalized_name'].'.php';
 			$activity_id = $process_activity['wf_activity_id'];
 			$tamanho     = filesize($path.$file_name);
 			$modificado  = date('d/m/Y H:i:s', filemtime($path.$file_name) );
-			
+
 			$files[] = array('file_name'     => $file_name,
 							 'activity_id'   => $activity_id,
@@ -258,11 +258,11 @@
 							 'tipo_codigo'   => 'atividade'
 			);
-			
+
 			$col_file_name[]  = $file_name;
 			$col_tamanho[]    = $tamanho;
 			$col_modificado[] = $modificado;
 		}
-		
-		if (isset($p['sort'])) 
+
+		if (isset($p['sort']))
 		{
 			$order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
@@ -279,13 +279,13 @@
 			}
 		}
-		
-		return $files; 
-	}
-	
-	/**
-	* Delete process file 
+
+		return $files;
+	}
+
+	/**
+	* Delete process file
 	* @param array $p process data
 	* @return array
-	* @access public 
+	* @access public
 	*/
 	function delete_file($p)
@@ -293,12 +293,12 @@
 		if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false))
 			return 'Não foi possível executar a operação solicitada';
-		$process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$proc_info = $process_manager->get_process($p['proc_id']); 
+		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = $p['file_name'];
-		$proc_name = $proc_info['wf_normalized_name']; 
+		$proc_name = $proc_info['wf_normalized_name'];
 		$type      = $p['type'];
 		if (strpos($file_name,'/')) return 'Nome de arquivo inválido.';
 		if (!strlen($proc_name)) return 'ID de Processo inválido.';
-		
+
     switch($type)
     {
@@ -315,17 +315,17 @@
 				$path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name;
             break;
-			
+
     }
-   
-	   	if ($type == 'resource') 
+
+	   	if ($type == 'resource')
 		{
 			$complete_path = $path;
-		} 
-		else 
+		}
+		else
 		{
 			$complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
 		}
-	
-		if (file_exists($complete_path)) 
+
+		if (file_exists($complete_path))
 		{
 			if (unlink($complete_path))
@@ -342,17 +342,17 @@
 			return 'O arquivo '.$file_name.' não existe.';
 		}
-	}	
-	/**
-	* Create process new file 
+	}
+	/**
+	* Create process new file
 	* @param array $p process
 	* @return array
-	* @access public 
+	* @access public
 	*/
 	function create_file($p)
 	{
-		$process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$proc_info = $process_manager->get_process($p['proc_id']); 
+		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = $p['file_name'];
-		$proc_name = $proc_info['wf_normalized_name']; 
+		$proc_name = $proc_info['wf_normalized_name'];
 		$type      = $p['type'];
 
@@ -386,7 +386,7 @@
 		}
 
-		if (file_exists($complete_path)) 
-		{
-			if (!$p['rewrite']) 
+		if (file_exists($complete_path))
+		{
+			if (!$p['rewrite'])
 			{
 				return FILE_ALREADY_EXISTS;
@@ -396,5 +396,5 @@
 		}
 
-		if ($fp = fopen($complete_path, 'w')) 
+		if ($fp = fopen($complete_path, 'w'))
 		{
 			$basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource';
@@ -409,5 +409,5 @@
 			if ($type == 'template' || $type == 'include')
 			{
-				if (file_exists($basepath.SEP.$p['modelo'])) 
+				if (file_exists($basepath.SEP.$p['modelo']))
 				{
 					fwrite($fp,file_get_contents($basepath.SEP.$p['modelo']));
@@ -423,15 +423,15 @@
 		}
 	}
-	
+
 	/**
 	* Get process include files
 	* @param  array $p process
 	* @return array
-	* @access public 
+	* @access public
 	*/
 	function get_include_files($p)
 	{
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$proc_info          = $process_manager->get_process($p['proc_id']); 
+		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code';
 
@@ -442,9 +442,9 @@
 		$files          = array();
 
-		if ($handle = opendir($path)) 
-		{
-			while (false !== ($file_name = readdir($handle))) 
-			{	
-				if (!is_dir($path.SEP.$file_name)) 
+		if ($handle = opendir($path))
+		{
+			while (false !== ($file_name = readdir($handle)))
+			{
+				if (!is_dir($path.SEP.$file_name))
 				{
 					$tamanho     = filesize($path.SEP.$file_name);
@@ -467,5 +467,5 @@
 
 
-		if (isset($p['sort'])) 
+		if (isset($p['sort']))
 		{
 			$order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
@@ -483,17 +483,17 @@
 		}
 
-		return $files; 
-	}
-
-	/**
-	* Get process template files 
-	* @param array $p process data 
-	* @return array
-	* @access public 
+		return $files;
+	}
+
+	/**
+	* Get process template files
+	* @param array $p process data
+	* @return array
+	* @access public
 	*/
 	function get_template_files($p)
 	{
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$proc_info          = $process_manager->get_process($p['proc_id']); 
+		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates';
 
@@ -502,9 +502,9 @@
 		$col_modificado = array();
 
-		if ($handle = opendir($path)) 
-		{
-			while (false !== ($file_name = readdir($handle))) 
-			{	
-				if (!is_dir($path.SEP.$file_name)) 
+		if ($handle = opendir($path))
+		{
+			while (false !== ($file_name = readdir($handle)))
+			{
+				if (!is_dir($path.SEP.$file_name))
 				{
 					$tamanho     = filesize($path.SEP.$file_name);
@@ -541,19 +541,19 @@
 
         }
-    }	
-
-		return $files; 
-	}
-
-	/**
-	* Upload process resource  
-	* 
+    }
+
+		return $files;
+	}
+
+	/**
+	* Upload process resource
+	*
 	* @param array $p process
 	* @return array
-	* @access public 
+	* @access public
 	*/
 	function upload_resource($p)
 	{
-		$process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = basename($_FILES['resource_file']['name']);
@@ -587,5 +587,5 @@
 		if (strpos($_REQUEST['file_name'],'/') !== false)
 			return 'Não foi possível executar a operação solicitada';
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proc_info          = $process_manager->get_process($_REQUEST['proc_id']);
 
@@ -617,5 +617,5 @@
 			$completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path;
 
-		$GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download');
+		Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download');
 		exit;
 	}
@@ -630,5 +630,5 @@
 	function get_resource_files($p)
 	{
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proc_info          = $process_manager->get_process($p['proc_id']);
 
Index: sandbox/workflow/branches/609/inc/class.workflow_instancemanager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_instancemanager.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.workflow_instancemanager.inc.php	(revision 2233)
@@ -17,5 +17,5 @@
 		function workflow_instancemanager()
 		{
-			parent::InstanceManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::InstanceManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php	(revision 2233)
@@ -134,12 +134,12 @@
 	{
 		parent::bo_ajaxinterface();
-		$GLOBALS['ajax']->gui   = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$GLOBALS['ajax']->gui   = new GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$this->userID 			= $_SESSION['phpgw_info']['workflow']['account_id'];
 		$this->isWorkflowAdmin  = $GLOBALS['ajax']->acl->checkWorkflowAdmin($this->userID);
-		$this->processManager   = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$this->activityManager  = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$this->instanceManager  = new InstanceManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$this->roleManager 		= new RoleManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
-		$this->processMonitor   = new ProcessMonitor($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$this->processManager   = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->activityManager  = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->instanceManager  = new InstanceManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->roleManager 		= new RoleManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->processMonitor   = new ProcessMonitor(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 
@@ -335,8 +335,8 @@
 	   	$filters[] = '(gia.wf_user IS NOT NULL)';
 
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		if (!$completeData)
 		{
-			$paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 500, $_POST);
+			$paging = Factory::newInstance('Paging', 500, $_POST);
 			$tmp = $this->processMonitor->monitor_list_instances($paging->nextItem, $paging->itemsPerPage, $order, '', implode(' AND ', $filters));
 			$output['data'] = $paging->restrictItems(array_values($tmp['data']), $tmp['cant']);
@@ -353,5 +353,5 @@
 		$activityMapping = array();
 		$instanceCount = count($output['data']);
-		$cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP');
+		$cachedLDAP = &Factory::getInstance('CachedLDAP');
 		for ($i = 0; $i < $instanceCount; $i++)
 		{
@@ -476,8 +476,8 @@
 		/* load the data */
 		$filters[] = '(gp.wf_p_id = ' . $params['pid'] . ')';
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		if (!$completeData)
 		{
-			$paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 500, $_POST);
+			$paging = Factory::newInstance('Paging', 500, $_POST);
 			$tmp = $this->processMonitor->monitor_list_completed_instances($paging->nextItem, $paging->itemsPerPage, $order, '', implode(' AND ', $filters));
 			$output['data'] = $paging->restrictItems(array_values($tmp['data']), $tmp['cant']);
@@ -491,5 +491,5 @@
 		}
 
-		$cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP');
+		$cachedLDAP = &Factory::getInstance('CachedLDAP');
 		$userMapping = array();
 		$instanceCount = count($output['data']);
@@ -627,5 +627,5 @@
 			}
 			else
-				$output['fullname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($user);
+				$output['fullname'] = Factory::getInstance('WorkflowLDAP')->getName($user);
 
 		$this->instanceManager->set_instance_user($params['iid'], $params['aid'], $user);
@@ -648,5 +648,5 @@
 		if ($params['ns'] == 'aborted')
 		{
-			$realInstance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			$realInstance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 			$realInstance->getInstance($params['iid']);
 			if (!empty($realInstance->instanceId))
@@ -684,5 +684,5 @@
 
 		/* use next user or * for the new instance */
-		$realInstance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$realInstance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$realInstance->getInstance($params['iid'], false, false);
 		$user = $realInstance->getNextUser($params['aid']);
@@ -751,5 +751,5 @@
 
 		$maximumDisplaySize = 100;
-		$instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$instance->getInstance($params['iid']);
 
@@ -783,5 +783,5 @@
 			return "Você não tem permissão para executar este procedimento!";
 
-		$instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$instance->getInstance($params['iid']);
 		$output = $params;
@@ -804,5 +804,5 @@
 		$maximumDisplaySize = 100;
 
-		$instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$instance->getInstance($params['iid']);
 		$instance->set($params['name'], $params['value']);
@@ -835,5 +835,5 @@
 			return "Você não tem permissão para executar este procedimento!";
 
-		$instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$instance->getInstance($params['iid']);
 		$instance->clear($params['name']);
@@ -904,5 +904,5 @@
 		/* prepare the data */
 		$aux2 = array();
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		foreach ($aux as $user => $count)
 			$aux2[] = array(
@@ -984,5 +984,5 @@
 
 		/* load LDAP info and sort the result */
-		$foundUsers = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames($users);
+		$foundUsers = Factory::getInstance('WorkflowLDAP')->getNames($users);
 		usort($foundUsers, create_function('$a,$b', 'return strcasecmp($a[\'name\'],$b[\'name\']);'));
 
@@ -991,5 +991,5 @@
 		if (count($users) > count($foundUsers))
 		{
-			$cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP');
+			$cachedLDAP = &Factory::getInstance('CachedLDAP');
 			$foundUsersID = array_map(create_function('$a', 'return $a[\'id\'];'), $foundUsers);
 			$missingUsers = array_diff($users, $foundUsersID);
@@ -1242,5 +1242,5 @@
 			return $output;
 
-		$BOUserInterface = &$GLOBALS['workflow']['factory']->getInstance('bo_userinterface');
+		$BOUserInterface = &Factory::getInstance('bo_userinterface');
 
 		/* initialize some variables */
@@ -1344,5 +1344,5 @@
 
 		/* load the recipient e-mail */
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		foreach ($output as $key => $value)
 		{
@@ -1396,5 +1396,5 @@
 
 		/* prepare the environment to load some configuration values from other module */
-		$GLOBALS['phpgw']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso();
+		$GLOBALS['phpgw']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
 		$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
 		$GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
@@ -1402,5 +1402,5 @@
 
 		/* get the required configuration */
-		$BOEmailAdmin = $GLOBALS['workflow']['factory']->newForeignInstance('emailadmin', 'bo');
+		$BOEmailAdmin = Factory::newForeignInstance('emailadmin', 'bo');
 		$profileList = $BOEmailAdmin->getProfileList();
 		$profile = $BOEmailAdmin->getProfile($profileList[0]['profileID']);
@@ -1494,6 +1494,6 @@
 	{
 		$output = array();
-		$cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP');
-		$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+		$cachedLDAP = &Factory::getInstance('CachedLDAP');
+		$ldap = &Factory::getInstance('WorkflowLDAP');
 		foreach ($userIDs as $userID)
 		{
@@ -1542,5 +1542,5 @@
 	   	$filters[] = '(gia.wf_user IS NOT NULL)';
 
-		$cachedLDAP = &$GLOBALS['workflow']['factory']->newInstance('CachedLDAP');
+		$cachedLDAP = &Factory::newInstance('CachedLDAP');
 		$cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP);
 		$output = array();
@@ -1559,5 +1559,5 @@
 		}
 
-		$validUsers = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames(array_keys($userIDs));
+		$validUsers = Factory::getInstance('WorkflowLDAP')->getNames(array_keys($userIDs));
 		array_walk($validUsers, create_function('&$a', '$a = $a[\'id\'];'));
 
Index: sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php	(revision 2233)
@@ -62,6 +62,6 @@
 	function form()
 	{
-		$smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false);
-		$processManager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$smarty = Factory::getInstance('workflow_smarty', false);
+		$processManager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$proccessInfo = $processManager->get_process($_GET['proc_id']);
 
Index: sandbox/workflow/branches/609/inc/class.ResourcesRedirector.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ResourcesRedirector.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ResourcesRedirector.inc.php	(revision 2233)
@@ -54,5 +54,5 @@
 		if (!isset($_SESSION['workflow']['ResourcesRedirector'][$this->pid]))
 		{
-			$result = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query('SELECT wf_normalized_name FROM egw_wf_processes WHERE wf_p_id = ?', array($this->pid));
+			$result = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query('SELECT wf_normalized_name FROM egw_wf_processes WHERE wf_p_id = ?', array($this->pid));
 			if ($result->numRows() != 1)
 				return;
@@ -94,5 +94,5 @@
 				{
 					/* em último caso, tenta buscar a informação em banco de dados */
-					$result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'));
+					$result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'));
 					if (empty($result))
 						return;
Index: sandbox/workflow/branches/609/inc/class.workflow_wfsecurity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_wfsecurity.inc.php	(revision 1712)
+++ sandbox/workflow/branches/609/inc/class.workflow_wfsecurity.inc.php	(revision 2233)
@@ -18,5 +18,5 @@
 		function workflow_wfsecurity()
 		{
-			parent::WfSecurity($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			parent::WfSecurity(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 	}
Index: sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php	(revision 2233)
@@ -153,5 +153,5 @@
 				return false;
 
-			$ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP');
+			$ldap = &Factory::getInstance('WorkflowLDAP');
 			for ($i = 0; $i < count($output); $i++)
 			{
Index: sandbox/workflow/branches/609/inc/class.ui_adminaccess.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminaccess.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.ui_adminaccess.inc.php	(revision 2233)
@@ -41,5 +41,5 @@
 	function ui_adminaccess()
 	{
-		if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
+		if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']))
 		{
 			$GLOBALS['phpgw']->common->phpgw_header();
