array( 'db_processes' => array( 'name' => '', 'host' => '', 'port' => '', 'admin_user' => '', 'admin_password' => '', 'type' => '' ), 'db_module' => array( 'name' => '', 'host' => '', 'port' => '', 'user' => '', 'password' => '', 'type' => '' ), 'ldap' => array( 'host' => '', 'user' => '', 'password' => '', 'follow_referrals' => '', 'user_context' => '', 'group_context' => '' ), 'preferences' => array( 'startpage' => '', 'ui_items_per_page' => '', 'show_activity_complete_page' => '' ), 'app' => array( 'title' => '', 'version' => '' ), 'intranet_subnetworks' => '', 'user_can_clean_instances' => '' ), 'expresso' => array( 'db' => array( 'name' => '', 'host' => '', 'port' => '', 'user' => '', 'password' => '', 'type' => '' ), 'ldap' => array( 'host' => '', 'user_context' => '', 'group_context' => '' ), 'user' => array( 'account_id' => '', 'account_lid' => '', 'account_dn' => '', 'userid' => '', 'passwd' => '', 'email' => '' ), 'preferences' => array( 'lang' => '' ), 'webserver_url' => '', 'use_https' => '' ) ); /** * @var boolean $_isLoaded Stores whether the settings are loaded or not. * @access private * @static */ private static $_isLoaded = false; /** * Constructor. Just disabling direct instantiation. * * @access public * @return void */ public function __construct() { throw new Exception("Oops! Static only class."); } /** * Implements security policy. Throw an exception if not allowed; * do nothing otherwise. Advanced security policies for this class * could be implemeted here. * * @access private * @return void * @static */ private static function _isAllowed() { /* if we are an process mode */ if (Security::isEnabled()) { /** * even in process mode, if we are dealing with a module class, not process code, * we should grant access. */ if (!Security::isSafeDir(2)) throw new Exception("You are not allowed to access 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 * and the configuration to be retrieved. * @access public * @return string * @static */ public static function get() { /* checking permission to access */ self::_isAllowed(); /* getting the variable number of parameters */ $args = func_get_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, $value=&self::$_configs; $i", $path)."' do not exists."); } return true; } /** * Loads settings into $_configs private array. * * @access private * @return void * @static */ private static function _load() { /* loading global variables into $_configs */ self::$_configs['expresso']['db']['name'] = $GLOBALS['phpgw_info']['server']['db_name']; self::$_configs['expresso']['db']['host'] = $GLOBALS['phpgw_info']['server']['db_host']; self::$_configs['expresso']['db']['port'] = $GLOBALS['phpgw_info']['server']['db_port']; self::$_configs['expresso']['db']['user'] = $GLOBALS['phpgw_info']['server']['db_user']; self::$_configs['expresso']['db']['password'] = $GLOBALS['phpgw_info']['server']['db_pass']; 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']; self::$_configs['workflow']['preferences']['common']['template_set'] = $GLOBALS['phpgw_info']['server']['template_set']; self::$_configs['workflow']['app']['title'] = $GLOBALS['phpgw_info']['apps']['workflow']['title']; self::$_configs['workflow']['app']['version'] = $GLOBALS['phpgw_info']['apps']['workflow']['version']; /* 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']; self::$_configs['expresso']['use_https'] = $GLOBALS['phpgw_info']['server']['use_https']; /* loading database settings */ $config = &Factory::newInstance('config', 'workflow'); $values = $config->read_repository(); self::$_configs['workflow']['intranet_subnetworks'] = $values['intranet_subnetworks']; 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']; self::$_configs['workflow']['ldap']['user'] = $values['ldap_user']; 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. */ self::$_isLoaded = true; } } ?>