Index: sandbox/workflow/trunk/inc/local/classes/class.wf_instance.php
===================================================================
--- sandbox/workflow/trunk/inc/local/classes/class.wf_instance.php	(revision 2466)
+++ sandbox/workflow/trunk/inc/local/classes/class.wf_instance.php	(revision 2858)
@@ -250,29 +250,35 @@
 
 	/**
-	* Busca as instâncias filhas de uma instância
-	* Se os parâmetros não forem informados, retorna instâncias filhas das instância atual.
-	* @param int $instanceID O ID da instância pai (não obrigatório).
-	* @param int $activityID O ID da atividade corrente da instância pai
-	* @return array As instâncias filhas do par instância/atividade atual
-	* @access public
-	*/
-	public function getChildren($instanceID = null, $activityID = null)
+	* This method gets all children instances of the given instance.
+	* If there is no parameter, it gets the children instances of the current instance
+	* @param int $instanceID Dad instance's identification.
+	* @return array Array with the children instances, or false
+	* @access public
+	*/
+	public function getChildren($instanceID = null)
 	{
 		$output = array();
 		if (is_null($instanceID))
 			$instanceID = $GLOBALS['workflow']['wf_runtime']->instance_id;
-		if (is_null($activityID))
-			$activityID = $GLOBALS['workflow']['wf_runtime']->activity_id;
-
-		/* check instanceID */
-		if (!$this->checkInstanceAccess($instanceID, $activityID))
+
+		/* check instanceID */
+		if (!$this->checkInstanceAccess($instanceID))
 			return $output;
 
 		/* build the SQL query */
-		$query = 'SELECT i.wf_instance_id AS wf_instance_id, ia.wf_activity_id AS wf_activity_id, ia.wf_started AS wf_started, i.wf_name AS wf_name, i.wf_status AS wf_status, ia.wf_user AS wf_user, ir.wf_parent_lock AS wf_parent_lock ';
-		$query .= 'FROM egw_wf_interinstance_relations ir, egw_wf_instances i LEFT JOIN egw_wf_instance_activities ia ON (ia.wf_instance_id = i.wf_instance_id)';
-		$query .= 'WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)';
-
-		$result = $this->db->query($query, array($instanceID, $activityID));
+		$query = 'SELECT i.wf_instance_id AS wf_instance_id, ' .
+				 '       ia.wf_activity_id AS wf_activity_id, ' .
+				 '       i.wf_started AS wf_started, ' .
+				 '       i.wf_name AS wf_name, ' .
+				 '       i.wf_status AS wf_status, ' .
+				 '       ia.wf_user AS wf_user, ' .
+				 '       ir.wf_parent_lock AS wf_parent_lock ' .
+				 ' FROM egw_wf_interinstance_relations ir, egw_wf_instances i ' .
+				 '  LEFT JOIN egw_wf_instance_activities ia ' .
+				 '  ON (ia.wf_instance_id = i.wf_instance_id) ' .
+				 ' WHERE ' .
+				 '  (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) ';
+
+		$result = $this->db->query($query, array($instanceID));
 		$output = $result->GetArray(-1);
 
Index: sandbox/workflow/trunk/inc/local/classes/class.wf_engine.php
===================================================================
--- sandbox/workflow/trunk/inc/local/classes/class.wf_engine.php	(revision 2466)
+++ sandbox/workflow/trunk/inc/local/classes/class.wf_engine.php	(revision 2858)
@@ -192,5 +192,5 @@
 	{
 		$WFInstance = &Factory::getInstance('wf_instance');
-		$preOutput = $WFInstance->getChildren($instanceID, $activityID);
+		$preOutput = $WFInstance->getChildren($instanceID);
 		$output = array();
 		foreach ($preOutput as $childInstance)
Index: sandbox/workflow/trunk/inc/local/classes/class.wf_natural.php
===================================================================
--- sandbox/workflow/trunk/inc/local/classes/class.wf_natural.php	(revision 795)
+++ sandbox/workflow/trunk/inc/local/classes/class.wf_natural.php	(revision 2858)
@@ -1,130 +1,114 @@
 <?php
-	require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php');
+/**************************************************************************\
+* eGroupWare                                                               *
+* http://www.egroupware.org                                                *
+* --------------------------------------------                             *
+*  This program is free software; you can redistribute it and/or modify it *
+*  under the terms of the GNU General Public License as published by the   *
+*  Free Software Foundation; either version 2 of the License, or (at your  *
+*  option) any later version.                                              *
+\**************************************************************************/
+
+require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php');
+
+/**
+ * Mainframe connection to workflow
+ *
+ * TODO - This class should be removed from here. Its based on a not
+ * public protocol, thus cannot be used for everybody.
+ *
+ * @package Workflow
+ * @subpackage local
+ * @license http://www.gnu.org/copyleft/gpl.html GPL
+ * @author Everton Flávio Rufino Seára
+ */
+class wf_natural extends Natural
+{
 
 	/**
-	* Mainframe connection to workflow
-	* @author Everton Flávio Rufino Seára
-	* @package Workflow
-	* @subpackage local
-	* @license http://www.gnu.org/copyleft/gpl.html GPL
-	**/
+	 * @var object Log Object
+	 * @access private
+	 */
+	private $logger = null;
 
-	class wf_natural extends Natural
+	function __construct()
 	{
+		parent::Natural();
 
-		function __construct()
-		{
-			parent::Natural();
+		$natconf = array(
+					'mainframe_ip'			=> '',
+					'mainframe_port'		=> '',
+					'mainframe_key'			=> '',
+					'mainframe_password'	=> '',
+					'mainframe_environment'	=> ''
+		);
 
-			$natconf = array(
-						'mainframe_ip'			=> '',
-						'mainframe_port'		=> '',
-						'mainframe_key'			=> '',
-						'mainframe_password'	=> '',
-						'mainframe_environment'	=> ''
-			);
+		$nat_conf_values = &Factory::getInstance('workflow_wfruntime')->getConfigValues($natconf);
 
-			$nat_conf_values = $GLOBALS['workflow']['wf_runtime']->getConfigValues($natconf);
+		$this->setIPAddress($nat_conf_values['mainframe_ip']);
+		$this->setServerPort($nat_conf_values['mainframe_port']);
+		$this->setKey($nat_conf_values['mainframe_key']);
+		$this->setPassword($nat_conf_values['mainframe_password']);
+		$this->setApplication($nat_conf_values['mainframe_environment']);
 
-			$this->setIPAddress($nat_conf_values['mainframe_ip']);
-			$this->setServerPort($nat_conf_values['mainframe_port']);
-			$this->setKey($nat_conf_values['mainframe_key']);
-			$this->setPassword($nat_conf_values['mainframe_password']);
-			$this->setApplication($nat_conf_values['mainframe_environment']);
+		$this->logger = &Factory::getInstance('Logger', array('file'));
+	}
+
+	/**
+	 * This method MUST be called before using execute method
+	 * It specifies the natural sub-program to be accessed.
+	 *
+	 * @param Object $obj Object that specifies natural sub-program properties
+	 * @return void
+	 */
+	public function configure($obj)
+	{
+		$this->obj = $obj;
+
+		$this->initialize($obj->name);
+
+		if ($obj->server != NULL){
+			$this->setIPAddress($obj->server);
 		}
-
-		/**
-		 * Method to configure the access to mainframe
-		 * This method MUST be called before using execute method, else 'false' will be returned
-		 *
-		 * Only the first and second param are mandatory.
-		 *
-		 * @param String $subProgram - Name of sub-program
-		 * @param String $inputParameter - Input parameters to sub-program
-		 *
-		 * @param String $ip - IP Address of Mainfram
-		 * @param int $port - ServerPort to access the mainframe
-		 * @param String $key - Access key (user)
-		 * @param String $password - Key (user) password
-		 * @param char $environment - Application environment access 'D' (development) or 'P' (production)
-
-		 */
-
-		public function configure($obj)
-		{
-			$this->obj = $obj;
-
-			$this->initialize($obj->name);
-
-			if ($obj->server != NULL){
-				$this->setIPAddress($obj->server);
-			}
-			if ($obj->port != NULL){
-				$this->setServerPort($obj->port);
-			}
-			if ($obj->key != NULL){
-				$this->setKey($obj->key);
-			}
-			if ($obj->password != NULL){
-				$this->setPassword($obj->password);
-			}
-			if ($obj->environment != NULL){
-				$this->setApplication($obj->environment);
-			}
-			if ($obj->logon != NULL){
-				$this->setLogon($obj->logon);
-			}
-			if ($obj->system != NULL){
-				$this->setSystem($obj->system);
-			}
-			if ($obj->rc != NULL){
-				$this->setRC($obj->rc);
-			}
+		if ($obj->port != NULL){
+			$this->setServerPort($obj->port);
 		}
-
-		/*
-
-		public function configure($subProgram, $inputParameter, $ip = NULL, $port = NULL,
-										$key = NULL, $password = NULL, $environment = NULL, $logon = NULL, $system = NULL, $rc = NULL)
-		{
-			$this->initialize($subProgram, $inputParameter);
-
-			if ($ip != NULL){
-				$this->setIPAddress($ip);
-			}
-			if ($port != NULL){
-				$this->setServerPort($port);
-			}
-			if ($key != NULL){
-				$this->setKey($key);
-			}
-			if ($password != NULL){
-				$this->setPassword($password);
-			}
-			if ($environment != NULL){
-				$this->setApplication($environment);
-			}
-			if ($logon != NULL){
-				$this->setLogon($logon);
-			}
-			if ($system != NULL){
-				$this->setSystem($system);
-			}
-			if ($rc != NULL){
-				$this->setRC($rc);
-			}
-
+		if ($obj->key != NULL){
+			$this->setKey($obj->key);
 		}
-
-		 */
-
-		/**
-		 * Access and retrieve data from mainframe
-		 * @return bool
-		 */
-		public function execute($inputParams = "")
-		{
-			return parent::execute($inputParams);
+		if ($obj->password != NULL){
+			$this->setPassword($obj->password);
+		}
+		if ($obj->environment != NULL){
+			$this->setApplication($obj->environment);
+		}
+		if ($obj->logon != NULL){
+			$this->setLogon($obj->logon);
+		}
+		if ($obj->system != NULL){
+			$this->setSystem($obj->system);
+		}
+		if ($obj->rc != NULL){
+			$this->setRC($obj->rc);
 		}
 	}
+
+	/**
+	 * Method for accessing and retrieving data from mainframe
+	 * @return bool
+	 */
+	public function execute($inputParams = "")
+	{
+		// execute action and log wasted time
+		$totalTime = microtime(true);
+		$result = parent::execute($inputParams);
+		$totalTime = microtime(time) - $totalTime;
+		$log = sprintf("WF_NATURAL [subprogram=%s] [time=%ss]",
+					$this->obj->name,
+					number_format($totalTime,3)
+					);
+		$this->logger->debug($log);
+		return $result;
+	}
+}
 ?>
