Index: trunk/prototype/api/config.php
===================================================================
--- trunk/prototype/app/config.php	(revision 5341)
+++ trunk/prototype/api/config.php	(revision 5399)
@@ -8,13 +8,10 @@
     static function module($config , $module = false)
     {
-	self::init();
-      
         //Todo: registrar na nova api o currentapp
         if(!$module)
             $module =  $_SESSION['flags']['currentapp'];
-        /*
-        if( !isset( $_SESSION['config'][$module] ) )
-            Carregar Config do modulo
-         */  
+  
+        if( !isset( $_SESSION['config'][$module] ) || !isset( $_SESSION['config'][$module][$config] ))
+            $_SESSION['config'][$module] = parse_ini_file( ROOTPATH."/config/$module.ini", true );
         
         return isset($_SESSION['config'][$module][$config]) ? $_SESSION['config'][$module][$config] : false;
@@ -24,27 +21,72 @@
     static function me($config)
     {
-	self::init();
+        
         return isset($_SESSION['wallet']['user'][$config]) ? $_SESSION['wallet']['user'][$config] : false;
-     
     }
-
+    
+    static function service( $service , $config )
+    {
+        if( !isset( $_SESSION['wallet'][$service] ) || !isset( $_SESSION['wallet'][$service][$config] ))
+            $_SESSION['wallet'][$service] = parse_ini_file( ROOTPATH."/config/$service.srv", true );
+        
+        return isset($_SESSION['wallet'][$service][$config]) ? $_SESSION['wallet'][$service][$config] : false;
+    }
+    
     static function regSet( $name , $value)
     {
-	    self::$register[$name] = $value;
+        self::$register[$name] = $value;
     }
     static function regGet ($name )
     {
-	    return (isset(self::$register[$name]) ? self::$register[$name] : false );
+        return (isset(self::$register[$name]) ? self::$register[$name] : false );
     }
 
-    static function init()
+    static function init( $header = false )
     {
-	if ( isset( $_COOKIE[ 'sessionid' ] ) ) 
-	    session_id( $_COOKIE[ 'sessionid' ] ); 
+        
+        if( !defined( 'ROOTPATH' ) )
+            define( 'ROOTPATH', dirname(__FILE__).'/..' );
+        
+        if ( isset( $_COOKIE[ 'sessionid' ] ) ) 
+        {
+            session_id( $_COOKIE[ 'sessionid' ] ); 
+            $GLOBALS['phpgw']->session->sessionid = $_COOKIE[ 'sessionid' ];
+        }
+		
+	if( !self::$sessionStarted )
+            self::$sessionStarted = session_start();
+		
+	if( $header === true )
+	{
+            require_once (dirname(__FILE__).'/../../header.inc.php');
 
-	if( !self::$sessionStarted )
-	    self::$sessionStarted = session_start();
+            $_SESSION['wallet']['Sieve']['user']          =  $GLOBALS['phpgw_info']['user']['account_lid'];
+            $_SESSION['wallet']['Sieve']['password']      =  $GLOBALS['phpgw_info']['user']['passwd'];
+
+            $_SESSION['wallet']['Cyrus']['user']          =  $GLOBALS['phpgw_info']['user']['account_lid'];
+            $_SESSION['wallet']['Cyrus']['password']      =  $GLOBALS['phpgw_info']['user']['passwd'];
+
+            $_SESSION['wallet']['user']['uid']	      	  =  $GLOBALS['phpgw_info']['user']['userid'];
+            $_SESSION['wallet']['user']['uidNumber']      =  $GLOBALS['phpgw_info']['user']['account_id'];
+            $_SESSION['wallet']['user']['password']       =  $GLOBALS['phpgw_info']['user']['passwd'];
+            $_SESSION['wallet']['user']['cn']             =  $GLOBALS['phpgw_info']['user']['cn'];
+            $_SESSION['wallet']['user']['mail']           =  $GLOBALS['phpgw_info']['user']['email'];
+
+            $_SESSION['wallet']['PostgreSQL']['user']     = $GLOBALS['phpgw_info']['server']['db_user'];
+            $_SESSION['wallet']['PostgreSQL']['password'] = $GLOBALS['phpgw_info']['server']['db_pass'];
+            $_SESSION['wallet']['PostgreSQL']['dbname']   = $GLOBALS['phpgw_info']['server']['db_name'];
+            $_SESSION['wallet']['PostgreSQL']['host']     = $GLOBALS['phpgw_info']['server']['db_host'];
+            
+            $_SESSION['wallet']['OpenLDAP']['context']   =  $GLOBALS['phpgw_info']['server']['ldap_context'];
+            $_SESSION['wallet']['OpenLDAP']['host']      =  $GLOBALS['phpgw_info']['server']['ldap_host'];
+           
+	}
+		
     }
+
 }
 
+    Config::init();
+	
+
 ?>
