Index: sandbox/workflow/branches/993/lib/settings/Settings.php
===================================================================
--- sandbox/workflow/branches/993/lib/settings/Settings.php	(revision 2429)
+++ sandbox/workflow/branches/993/lib/settings/Settings.php	(revision 2492)
@@ -29,6 +29,5 @@
 	private static $_configs = array(
 		'workflow' => array(
-			'intranet_subnetworks' => '',
-			'db' => array(
+			'db_processes' => array(
 				'name' => '',
 				'host' => '',
@@ -38,20 +37,27 @@
 				'type' => ''
 			),
-			'galaxia' => array(
-				'db' => array(
-					'name' => '',
-					'host' => '',
-					'port' => '',
-					'user' => '',
-					'password' => '',
-					'type' => ''
-				)
-			),
-			'ldap' => array(
-				'host' => '',
+			'db_module' => array(
+				'name' => '',
+				'host' => '',
+				'port' => '',
 				'user' => '',
 				'password' => '',
-				'follow_referrals' => ''
-			),
+				'type' => ''
+			),
+			'ldap' => array(
+				'host' => '',
+				'user' => '',
+				'password' => '',
+				'follow_referrals' => '',
+				'user_context' => '',
+				'group_context' => ''
+			),
+			'preferences' => array(
+				'startpage' => '',
+				'ui_items_per_page' => '',
+				'show_activity_complete_page' => ''
+			),
+			'intranet_subnetworks' => '',
+			'user_can_clean_instances' => ''
 		),
 		'expresso' => array(
@@ -65,8 +71,20 @@
 			),
 			'ldap' => array(
-				'host' => ''
-			),
-		),
-		'process' => array(
+				'host' => '',
+				'user_context' => '',
+				'group_context' => ''
+			),
+			'user' => array(
+				'account_id' => '',
+				'account_lid' => '',
+				'account_dn' => '',
+				'userid' => '',
+				'passwd' => '',
+				'email' => ''
+			),
+			'preferences' => array(
+				'lang' => ''
+			),
+			'webserver_url' => ''
 		)
 	);
@@ -92,5 +110,6 @@
 
 	/**
-	 * Returns settings.
+	 * Returns settings. If the hole path has not be setted, return the hole
+	 * hierarchy under it.
 	 *
 	 * @param string $args 	A variable number of parameters which specify the scope
@@ -105,13 +124,6 @@
 		$args = func_get_args();
 
-		/**
-		 * Here we check if the configuration was defined into $_configs array.
-		 * If it does not, an exception will be thrown.
-		 * p.s. Do not try to understand this piece of code. Just fave faith! It works...
-		 */
-		for ($i=0, $sub_array=&self::$_configs; $i<count($args); $sub_array=&$sub_array[$args[$i++]]) {
-			if (!array_key_exists($args[$i], $sub_array))
-				throw new Exception("Sorry! Setting '".implode("->", $args)."' do not exists.");
-		}
+		/* checking if the key exists */
+		self::_keyExists($args);
 
 		/* check if we already load the settings */
@@ -123,4 +135,50 @@
 
 		return $value;
+	}
+
+
+	public static function set() {
+
+		/* getting the variable number of parameters */
+		$args = func_get_args();
+
+		/* the last position is always the value that we are trying to set, so pop it */
+		$value = array_pop($args);
+
+		/* checking if the key exists */
+		self::_keyExists($args);
+
+		/* check if we already load the settings */
+		if (!self::$_isLoaded)
+			self::_load();
+
+		/* retrieving the setting. More 'for' programming. */
+		for ($i=0, $key=&self::$_configs; $i<count($args); $key=&$key[$args[$i++]]);
+
+		/* updating the value. p.s: $key is a pointer to a $_config node */
+		$key = $value;
+		return true;
+	}
+
+	/**
+	 * Here we check if the configuration was defined into $_configs array.
+	 * If it does not, an exception will be thrown.
+	 *
+	 * @param string $args 	A variable number of parameters which specify the scope
+	 *						and the configuration to be retrieved.
+	 * @access private
+	 * @return boolean
+	 * @static
+	 */
+	private static function _keyExists($path) {
+
+		/**
+		 * p.s: Do not try to understand this piece of code. Just fave faith! It works...
+		 */
+		for ($i=0, $sub_array=&self::$_configs; $i<count($path); $sub_array=&$sub_array[$path[$i++]]) {
+			if (!array_key_exists($path[$i], $sub_array))
+				throw new Exception("Sorry! Setting '".implode("->", $path)."' do not exists.");
+		}
+		return true;
 	}
 
@@ -143,5 +201,25 @@
 		self::$_configs['expresso']['db']['type'] = $GLOBALS['phpgw_info']['server']['db_type'];
 
+		/* current user information */
+		self::$_configs['expresso']['user']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
+		self::$_configs['expresso']['user']['account_lid'] = $GLOBALS['phpgw_info']['user']['account_lid'];
+		self::$_configs['expresso']['user']['account_dn'] = $GLOBALS['phpgw_info']['user']['account_dn'];
+		self::$_configs['expresso']['user']['userid'] = $GLOBALS['phpgw_info']['user']['userid'];
+		self::$_configs['expresso']['user']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd'];
+		self::$_configs['expresso']['user']['email'] = $GLOBALS['phpgw_info']['user']['email'];
+
 		self::$_configs['expresso']['ldap']['host'] = $GLOBALS['phpgw_info']['server']['ldap_host'];
+		self::$_configs['expresso']['ldap']['user_context'] = $GLOBALS['phpgw_info']['server']['ldap_user_context'];
+		self::$_configs['expresso']['ldap']['group_context'] = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
+
+		/* workflow specific preferences */
+		self::$_configs['workflow']['preferences']['startpage'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['startpage'];
+		self::$_configs['workflow']['preferences']['ui_items_per_page'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['ui_items_per_page'];
+		self::$_configs['workflow']['preferences']['show_activity_complete_page'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['show_activity_complete_page'];
+
+		/*expresso preferences */
+		self::$_configs['expresso']['preferences']['lang'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
+
+		self::$_configs['expresso']['webserver_url'] = $GLOBALS['phpgw_info']['server']['webserver_url'];
 
 		/* loading database settings */
@@ -151,17 +229,17 @@
 		self::$_configs['workflow']['intranet_subnetworks'] = $values['intranet_subnetworks'];
 
-		self::$_configs['workflow']['db']['name'] = $values['database_name'];
-		self::$_configs['workflow']['db']['host'] = $values['database_host'];
-		self::$_configs['workflow']['db']['port'] = $values['database_port'];
-		self::$_configs['workflow']['db']['admin_user'] = $values['database_admin_user'];
-		self::$_configs['workflow']['db']['admin_password'] = $values['database_admin_password'];
-		self::$_configs['workflow']['db']['type'] = $values['database_type'];
-
-		self::$_configs['workflow']['galaxia']['db']['name'] = $values['workflow_database_name'];
-		self::$_configs['workflow']['galaxia']['db']['host'] = $values['workflow_database_host'];
-		self::$_configs['workflow']['galaxia']['db']['port'] = $values['workflow_database_port'];
-		self::$_configs['workflow']['galaxia']['db']['user'] = $values['workflow_database_user'];
-		self::$_configs['workflow']['galaxia']['db']['password'] = $values['workflow_database_password'];
-		self::$_configs['workflow']['galaxia']['db']['type'] = $values['workflow_database_type'];
+		self::$_configs['workflow']['db_processes']['name'] = $values['database_name'];
+		self::$_configs['workflow']['db_processes']['host'] = $values['database_host'];
+		self::$_configs['workflow']['db_processes']['port'] = $values['database_port'];
+		self::$_configs['workflow']['db_processes']['admin_user'] = $values['database_admin_user'];
+		self::$_configs['workflow']['db_processes']['admin_password'] = $values['database_admin_password'];
+		self::$_configs['workflow']['db_processes']['type'] = $values['database_type'];
+
+		self::$_configs['workflow']['db_module']['name'] = $values['workflow_database_name'];
+		self::$_configs['workflow']['db_module']['host'] = $values['workflow_database_host'];
+		self::$_configs['workflow']['db_module']['port'] = $values['workflow_database_port'];
+		self::$_configs['workflow']['db_module']['user'] = $values['workflow_database_user'];
+		self::$_configs['workflow']['db_module']['password'] = $values['workflow_database_password'];
+		self::$_configs['workflow']['db_module']['type'] = $values['workflow_database_type'];
 
 		self::$_configs['workflow']['ldap']['host'] = $values['ldap_host'];
@@ -169,4 +247,6 @@
 		self::$_configs['workflow']['ldap']['password'] = $values['ldap_password'];
 		self::$_configs['workflow']['ldap']['follow_referrals'] = $values['ldap_follow_referrals'];
+		self::$_configs['workflow']['ldap']['user_context'] = $values['ldap_user_context'];
+		self::$_configs['workflow']['ldap']['group_context'] = $values['ldap_group_context'];
 
 		/* the settings are already loaded. No need to call this method again. */
