Index: sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2338)
+++ sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2440)
@@ -134,4 +134,9 @@
 		$this->registerFileInfo('NanoSanitizer', 'NanoSanitizer.class.php', 'inc/nano');
 
+		/* natural classes */
+		$this->registerFileInfo('PosString', 'pos_string.php', 'inc/natural');
+		$this->registerFileInfo('NatType', 'nat_types.php', 'inc/natural');
+		$this->registerFileInfo('NaturalResultSet', 'class.natural_resultset.php', 'inc/natural');
+
 		/* registering egw external classes */
 		$this->registerFileInfo('db', 'class.db.inc.php', '', EGW_INC_ROOT);
Index: sandbox/workflow/branches/609/inc/class.run_activity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2355)
+++ sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2440)
@@ -168,5 +168,4 @@
 		var $agents = Array();
 
-		/* CELEPAR */
 		/**
 		 * @var object $smarty holds a Smarty instance
@@ -194,7 +193,10 @@
          */
 		var $isChildInstance = false;
-
+		/**
+		 * @var object Stores a 'workflow_smarty' object
+         * @access private
+         */
 		private $workflowSmarty = null;
-		/* CELEPAR */
+
 		/**
 		 * Constructor
@@ -212,12 +214,10 @@
 			$this->runtime			= &Factory::newInstance('workflow_wfruntime');
 			$this->runtime->setDebug(_DEBUG);
-			//$this->base_activity	= Factory::getInstance('workflow_baseactivity');
-			//$this->process		= Factory::getInstance('workflow_process');
 			$this->GUI				= &Factory::getInstance('workflow_gui');
 			$this->categories 		= &Factory::getInstance('categories');
 
 			$this->workflowSmarty 	= &Factory::getInstance('workflow_smarty', false);
+
 			// TODO: open a new connection to the database under a different username to allow privilege handling on tables
-			/* CELEPAR */
 			unset($this->db);
 		}
@@ -335,5 +335,4 @@
 			$wf =& $GLOBALS['workflow'];
 
-			/* CELEPAR */
 			/* path to the local functions developed by Celepar */
 			$functions = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php';
@@ -341,5 +340,4 @@
 			/* activate local functions */
 			require_once($functions);
-			/* CELEPAR */
 
 			//get configuration options with default values if no init was done before
@@ -401,6 +399,4 @@
 				$this->download_mode = get_var('download_mode', array('POST','GET'), false);
 
-				/* #celepar# smarty code*/
-
 				$smarty = Factory::getInstance('process_smarty');
 
@@ -423,5 +419,5 @@
 				$smarty->assign('wf_back_link',$GLOBALS['workflow']['wf_back_link']);
 				$smarty->assign('wf_activity_url',$GLOBALS['workflow']['wf_activity_url']);
-				
+
 				/* register the prefilter smarty plugin wf_default_template */
 				$smarty->load_filter('pre', 'wf_default_template');
@@ -444,5 +440,4 @@
 			$security             =& Factory::newInstance('SecurityUtils');              //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST);    //sanitizes input data from client
-			//$env['factory']       =& new ProcessFactory();             //instantiation controller class
 			$env['factory']       =& Factory::getInstance('ProcessWrapperFactory');  //instantiation controller class
 			$env['natural']		  =& wf_create_object('wf_natural');   //data access object instance for mainframe
@@ -450,9 +445,11 @@
 
 			$GLOBALS['workflow_env'] = &$env;
-			//echo "<br><br><br><br><br>Including $source <br>In request: <pre>";print_r($_REQUEST);echo "</pre>";
-			//[__leave_activity] is setted if needed in the xxx_pre code or by the user in his code
-			// HERE the user code is 'executed'. Note that we do not use include_once or require_once because
-			//it could the same code several times with automatic activities looping in the graph and it still
-			//need to be executed
+
+			/**
+			 * [__leave_activity] is setted if needed in the xxx_pre code or by the user in his code
+			 * HERE the user code is 'executed'. Note that we do not use include_once or require_once because
+			 * it could the same code several times with automatic activities looping in the graph and it still
+			 * need to be executed
+			 */
 			$_engineProcessCodeDirectory = GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code';
 			$_engineCompilerDirectory = GALAXIA_LIBRARY . SEP . 'compiler';
@@ -480,10 +477,8 @@
 
 			/**
-			 * XXX
-			 * here we are going to use our new Security static class.
+			 * Here we are going to use our new Security static class.
 			 * From now, the factory frontend (static) will forward
 			 * the messages for the process factory instead of Workflow
 			 * factory.
-			 * XXX
 			*/
 			Security::enable();
@@ -688,8 +683,6 @@
 				unset($GLOBALS['workflow']['wf_instance_url']);
 
-			/* CELEPAR */
 			/* activate local functions */
 			require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php');
-			/* CELEPAR */
 
 			//get configuration options with default values if no init was done before
@@ -716,5 +709,4 @@
 			$security             =& Factory::newInstance('SecurityUtils'); //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST); //sanitizes input data from client
-			//$env['factory']       =& new ProcessFactory();			   //instantiation controller class
 			$env['factory']       =& Factory::newInstance('ProcessWrapperFactory');  //instantiation controller class
 			$env['natural']		  =& wf_create_object('wf_natural');   //data access object instance for mainframe
@@ -731,5 +723,4 @@
 
 			/**
-			 * XXX
 			 * here we are going to use our new Security static class.
 			 * From now, the factory frontend (static) will forward
@@ -737,6 +728,5 @@
 			 * factory. Note that this is the same comment as the previous
 			 * function... boooring.. =}
-			 * XXX
-			*/
+			 */
 			Security::enable();
 
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_workitem.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_workitem.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_workitem.php	(revision 2440)
@@ -29,5 +29,5 @@
 	public function wf_workitem()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->processID = (int) $GLOBALS['workflow']['wf_runtime']->activity->getProcessId();
 	}
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_role.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_role.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_role.php	(revision 2440)
@@ -57,5 +57,5 @@
 			$this->processID = (int) $GLOBALS['workflow']['job']['processID'];
 
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->roleManager = Factory::getInstance('workflow_rolemanager');
 		$this->activityManager = Factory::getInstance('workflow_activitymanager');
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php	(revision 2440)
@@ -92,5 +92,5 @@
 	{
 		/* load the DB */
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 
 		/* load the process ID from the runtime */
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php	(revision 2440)
@@ -282,5 +282,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_activity_id = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityID, $processID));
 
@@ -310,5 +310,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_name = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityName, $processID));
 
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_location.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_location.php	(revision 2160)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_location.php	(revision 2440)
@@ -36,5 +36,5 @@
 	function initialize()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 		$this->cityInfo = array();
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_orgchart.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_orgchart.php	(revision 2056)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_orgchart.php	(revision 2440)
@@ -24,5 +24,5 @@
 	function wf_orgchart()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 	}
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php	(revision 2440)
@@ -44,5 +44,5 @@
 		$this->group_context = $tmpLDAP->getGroupContext();
 
-		$this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->ds = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		$this->cachedLDAP = &Factory::getInstance('wf_cached_ldap');
Index: sandbox/workflow/branches/609/inc/natural/class.natural.php
===================================================================
--- sandbox/workflow/branches/609/inc/natural/class.natural.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/natural/class.natural.php	(revision 2440)
@@ -196,5 +196,5 @@
 			try
 			{
-				$str = new PosString(new NatType);
+				$str = Factory::newInstance('PosString', Factory::newInstance('NatType'));
 				$this->strInputParameter = $str->mountString(array_merge($this->obj->input, $this->obj->output), $inputParams);
 
@@ -409,5 +409,5 @@
 	 	if (!empty($this->resultSet))
 	 		unset($this->resultSet);
-	 	$this->resultSet = new NaturalResultSet($result);
+	 	$this->resultSet = &Factory::newInstance('NaturalResultSet', $result);
 	 }
 }
Index: sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php	(revision 2338)
+++ sandbox/workflow/branches/609/inc/class.ui_adminprocesses.inc.php	(revision 2440)
@@ -1,4 +1,3 @@
 <?php
-require_once 'common.inc.php';
 require_once(dirname(__FILE__) . SEP . 'class.bo_workflow_forms.inc.php');
 require_once('engine' . SEP . 'config.egw.inc.php');
Index: sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 2440)
@@ -111,5 +111,5 @@
 				$where[] = 'wf_p_id IS NULL';
 		}
-		$processManager = &Factory::getInstance('ProcessManager', $this->db);
+		$processManager = &Factory::getInstance('ProcessManager');
 
 		/* workaround to sort the result using two columns */
Index: sandbox/workflow/branches/609/inc/engine/src/API/Instance.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/Instance.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/engine/src/API/Instance.php	(revision 2440)
@@ -1170,5 +1170,5 @@
     
     //lock rows and ensure access is granted
-    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity', $this->db);
+    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
     if (!($this->security->checkUserAction($activityId,$this->instanceId,'complete')))
     {
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php	(revision 2440)
@@ -1195,5 +1195,5 @@
     elseif ( (!($result=='*')) && $performAccessCheck)
     {
-      $wf_security = &Factory::getInstance('WfSecurity', $this->db);
+      $wf_security = &Factory::getInstance('WfSecurity');
       // perform the check
       if (!($wf_security->checkUserAccess($result,$activityId)))
Index: sandbox/workflow/branches/609/inc/common.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/common.inc.php	(revision 2338)
+++ sandbox/workflow/branches/609/inc/common.inc.php	(revision 2440)
@@ -70,5 +70,3 @@
 require_once WF_LIB_ROOT . 'factory/WorkflowFactory.php';
 require_once WF_LIB_ROOT . 'factory/ProcessFactory.php';
-
-$GLOBALS['workflow']['workflowObjects'] = Factory::getInstance('WorkflowObjects');
 ?>
Index: sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 2311)
+++ sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 2440)
@@ -65,5 +65,5 @@
 		require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
 
-		$runtime = &Factory::getInstance('WfRuntime', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$runtime = &Factory::getInstance('WfRuntime');
 		$runtime->loadProcess($processID);
 
Index: sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2323)
+++ sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2440)
@@ -351,5 +351,5 @@
 	{
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		$searchTermExploded = explode(" ", $searchTerm);
@@ -431,5 +431,5 @@
 	{
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		/* makes no sense search for an area if the string has more than one word */
@@ -527,5 +527,5 @@
 
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		/* searching employees by telephoneNumber in the ldap server */
