Changeset 6528 for trunk/prototype/api
- Timestamp:
- 06/15/12 17:00:17 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
/sandbox/2.4.1-3 merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/prototype/api/config.php
r5764 r6528 1 1 <?php 2 3 namespace prototype\api; 2 4 3 5 class Config 4 6 { 5 6 7 static $register; 8 static $sessionStarted; 7 9 8 9 10 11 12 10 static function module($config , $module = false) 11 { 12 //Todo: registrar na nova api o currentapp 13 if(!$module) 14 $module = $_SESSION['flags']['currentapp']; 13 15 14 15 16 if( !isset( $_SESSION['config'][$module] ) || !isset( $_SESSION['config'][$module][$config] )) 17 $_SESSION['config'][$module] = parse_ini_file( ROOTPATH."/config/$module.ini", true ); 16 18 17 19 return isset($_SESSION['config'][$module][$config]) ? $_SESSION['config'][$module][$config] : false; 18 20 19 21 } 20 22 21 22 23 static function me($config) 24 { 23 25 24 25 26 return isset($_SESSION['wallet']['user'][$config]) ? $_SESSION['wallet']['user'][$config] : false; 27 } 26 28 27 28 29 30 29 static function service( $service , $config ) 30 { 31 if( !isset( $_SESSION['wallet'][$service] ) || !isset( $_SESSION['wallet'][$service][$config] )) 32 $_SESSION['wallet'][$service] = parse_ini_file( ROOTPATH."/config/$service.srv", true ); 31 33 32 33 34 return (isset($_SESSION['wallet'][$service][$config])) ? $_SESSION['wallet'][$service][$config] : false; 35 } 34 36 35 36 37 37 static function get( $concept , $config = false , $module = false ) 38 { 39 $load = parse_ini_file( ROOTPATH."/config/$concept.ini", true ); 38 40 39 41 if($config === false) return $load; 40 42 41 42 43 return (isset($load[$config])) ? $load[$config] : false; 44 } 43 45 44 45 46 47 48 49 50 51 46 static function regSet( $name , $value) 47 { 48 self::$register[$name] = $value; 49 } 50 static function regGet ($name ) 51 { 52 return (isset(self::$register[$name]) ? self::$register[$name] : false ); 53 } 52 54 53 static function init( ) 54 { 55 static function init( ) 56 { 57 58 if( !defined( 'ROOTPATH' ) ) 59 define( 'ROOTPATH', dirname(__FILE__).'/..' ); 55 60 56 if( !defined( 'ROOTPATH' ) ) 57 define( 'ROOTPATH', dirname(__FILE__).'/..' ); 58 59 if ( isset( $_COOKIE[ 'sessionid' ] ) ) 60 { 61 session_id( $_COOKIE[ 'sessionid' ] ); 62 $GLOBALS['phpgw']->session->sessionid = $_COOKIE[ 'sessionid' ]; 63 } 61 if ( isset( $_COOKIE[ 'sessionid' ] ) ) 62 { 63 session_id( $_COOKIE[ 'sessionid' ] ); 64 $GLOBALS['phpgw']->session->sessionid = $_COOKIE[ 'sessionid' ]; 65 } 64 66 65 67 if( !self::$sessionStarted ) 66 self::$sessionStarted = session_start(); 67 // 68 // if( $header === true ) 69 // { 70 // require_once (dirname(__FILE__).'/../../header.inc.php'); 71 // 72 // $_SESSION['wallet']['Sieve']['user'] = $GLOBALS['phpgw_info']['user']['account_lid']; 73 // $_SESSION['wallet']['Sieve']['password'] = $GLOBALS['phpgw_info']['user']['passwd']; 74 // 75 // $_SESSION['wallet']['Cyrus']['user'] = $GLOBALS['phpgw_info']['user']['account_lid']; 76 // $_SESSION['wallet']['Cyrus']['password'] = $GLOBALS['phpgw_info']['user']['passwd']; 77 // 78 // $_SESSION['wallet']['user']['uid'] = $GLOBALS['phpgw_info']['user']['userid']; 79 // $_SESSION['wallet']['user']['uidNumber'] = $GLOBALS['phpgw_info']['user']['account_id']; 80 // $_SESSION['wallet']['user']['password'] = $GLOBALS['phpgw_info']['user']['passwd']; 81 // $_SESSION['wallet']['user']['cn'] = $GLOBALS['phpgw_info']['user']['cn']; 82 // $_SESSION['wallet']['user']['mail'] = $GLOBALS['phpgw_info']['user']['email']; 83 // 84 // $_SESSION['wallet']['PostgreSQL']['user'] = $GLOBALS['phpgw_info']['server']['db_user']; 85 // $_SESSION['wallet']['PostgreSQL']['password'] = $GLOBALS['phpgw_info']['server']['db_pass']; 86 // $_SESSION['wallet']['PostgreSQL']['dbname'] = $GLOBALS['phpgw_info']['server']['db_name']; 87 // $_SESSION['wallet']['PostgreSQL']['host'] = $GLOBALS['phpgw_info']['server']['db_host']; 88 // 89 // $_SESSION['wallet']['OpenLDAP']['context'] = $GLOBALS['phpgw_info']['server']['ldap_context']; 90 // $_SESSION['wallet']['OpenLDAP']['host'] = $GLOBALS['phpgw_info']['server']['ldap_host']; 91 // 92 // } 68 self::$sessionStarted = session_start(); 93 69 94 } 70 } 71 72 public static function writeIniFile($assoc_arr, $path, $has_sections) 73 { 74 $content = ''; 75 self::_writeIniFile($content, $assoc_arr, $has_sections); 76 if( file_put_contents($path, $content) === false) 77 { 78 trigger_error("Permission failure when trying to write in the file: $path ", E_USER_WARNING); 79 return false; 80 } 81 return true; 82 } 83 84 private static function _writeIniFile(&$content, $assoc_arr, $has_sections) 85 { 86 foreach ($assoc_arr as $key => $val) 87 { 88 if (is_array($val)) 89 { 90 if($has_sections) 91 { 92 $content .= "[$key]\n"; 93 self::_writeIniFile(&$content, $val, false); 94 } 95 else 96 foreach($val as $iKey => $iVal) 97 { 98 if (is_int($iKey)) 99 $content .= $key ."[] = $iVal\n"; 100 else 101 $content .= $key ."[$iKey] = $iVal\n"; 102 } 103 } 104 else 105 $content .= "$key = $val\n"; 106 } 107 } 95 108 96 109 } 97 110 98 111 Config::init(); 99 112 100 113 -
trunk/prototype/api/controller.php
r6419 r6528 44 44 45 45 require_once(ROOTPATH.'/api/config.php'); 46 46 use prototype\api\Config as Config; 47 47 /** 48 48 TODO list: -
trunk/prototype/api/newcontroller.php
r5715 r6528 5 5 6 6 require_once(ROOTPATH.'/api/config.php'); 7 use prototype\api\Config as Config; 7 8 8 9 /**
Note: See TracChangeset
for help on using the changeset viewer.