Index: branches/2.2/workflow/inc/class.bo_adminsource.inc.php
===================================================================
--- branches/2.2/workflow/inc/class.bo_adminsource.inc.php	(revision 795)
+++ branches/2.2/workflow/inc/class.bo_adminsource.inc.php	(revision 3167)
@@ -11,9 +11,4 @@
 
 require_once('class.bo_ajaxinterface.inc.php');
-
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php');
 
 /**
@@ -80,5 +75,5 @@
 		$fileSizeUnit[] = 'Mb';
 		$fileSizeUnit[] = 'Gb';
-		
+
 		$unitSelect = 0;
 		while ($value > 1024.0)
@@ -87,26 +82,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 = &Factory::newInstance('ProcessManager');
+		$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 +114,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 +133,5 @@
 			$start_stop_img  = '';
 		}
-	
+
 		/* load other processes link */
 		$proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']);
@@ -145,10 +140,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 +172,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 +198,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 +212,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    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
-		$activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$activity_manager   = &Factory::newInstance('ActivityManager');
 		$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 +237,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 +253,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 +274,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 +288,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 = &Factory::newInstance('ProcessManager');
+		$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 +310,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 +337,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 = &Factory::newInstance('ProcessManager');
+		$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 +381,7 @@
 		}
 
-		if (file_exists($complete_path)) 
-		{
-			if (!$p['rewrite']) 
+		if (file_exists($complete_path))
+		{
+			if (!$p['rewrite'])
 			{
 				return FILE_ALREADY_EXISTS;
@@ -396,5 +391,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 +404,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 +418,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    = &Factory::newInstance('ProcessManager');
+		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code';
 
@@ -442,9 +437,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 +462,5 @@
 
 
-		if (isset($p['sort'])) 
+		if (isset($p['sort']))
 		{
 			$order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC;
@@ -483,17 +478,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    = &Factory::newInstance('ProcessManager');
+		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates';
 
@@ -502,9 +497,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 +536,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 = &Factory::newInstance('ProcessManager');
 		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = basename($_FILES['resource_file']['name']);
@@ -587,5 +582,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    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($_REQUEST['proc_id']);
 
@@ -617,5 +612,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 +625,5 @@
 	function get_resource_files($p)
 	{
-		$process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
 
