Changeset 2492 for sandbox/workflow/branches/993/lib/settings/Settings.php
- Timestamp:
- 04/12/10 16:21:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/branches/993/lib/settings/Settings.php
r2429 r2492 29 29 private static $_configs = array( 30 30 'workflow' => array( 31 'intranet_subnetworks' => '', 32 'db' => array( 31 'db_processes' => array( 33 32 'name' => '', 34 33 'host' => '', … … 38 37 'type' => '' 39 38 ), 40 'galaxia' => array( 41 'db' => array( 42 'name' => '', 43 'host' => '', 44 'port' => '', 45 'user' => '', 46 'password' => '', 47 'type' => '' 48 ) 49 ), 50 'ldap' => array( 51 'host' => '', 39 'db_module' => array( 40 'name' => '', 41 'host' => '', 42 'port' => '', 52 43 'user' => '', 53 44 'password' => '', 54 'follow_referrals' => '' 55 ), 45 'type' => '' 46 ), 47 'ldap' => array( 48 'host' => '', 49 'user' => '', 50 'password' => '', 51 'follow_referrals' => '', 52 'user_context' => '', 53 'group_context' => '' 54 ), 55 'preferences' => array( 56 'startpage' => '', 57 'ui_items_per_page' => '', 58 'show_activity_complete_page' => '' 59 ), 60 'intranet_subnetworks' => '', 61 'user_can_clean_instances' => '' 56 62 ), 57 63 'expresso' => array( … … 65 71 ), 66 72 'ldap' => array( 67 'host' => '' 68 ), 69 ), 70 'process' => array( 73 'host' => '', 74 'user_context' => '', 75 'group_context' => '' 76 ), 77 'user' => array( 78 'account_id' => '', 79 'account_lid' => '', 80 'account_dn' => '', 81 'userid' => '', 82 'passwd' => '', 83 'email' => '' 84 ), 85 'preferences' => array( 86 'lang' => '' 87 ), 88 'webserver_url' => '' 71 89 ) 72 90 ); … … 92 110 93 111 /** 94 * Returns settings. 112 * Returns settings. If the hole path has not be setted, return the hole 113 * hierarchy under it. 95 114 * 96 115 * @param string $args A variable number of parameters which specify the scope … … 105 124 $args = func_get_args(); 106 125 107 /** 108 * Here we check if the configuration was defined into $_configs array. 109 * If it does not, an exception will be thrown. 110 * p.s. Do not try to understand this piece of code. Just fave faith! It works... 111 */ 112 for ($i=0, $sub_array=&self::$_configs; $i<count($args); $sub_array=&$sub_array[$args[$i++]]) { 113 if (!array_key_exists($args[$i], $sub_array)) 114 throw new Exception("Sorry! Setting '".implode("->", $args)."' do not exists."); 115 } 126 /* checking if the key exists */ 127 self::_keyExists($args); 116 128 117 129 /* check if we already load the settings */ … … 123 135 124 136 return $value; 137 } 138 139 140 public static function set() { 141 142 /* getting the variable number of parameters */ 143 $args = func_get_args(); 144 145 /* the last position is always the value that we are trying to set, so pop it */ 146 $value = array_pop($args); 147 148 /* checking if the key exists */ 149 self::_keyExists($args); 150 151 /* check if we already load the settings */ 152 if (!self::$_isLoaded) 153 self::_load(); 154 155 /* retrieving the setting. More 'for' programming. */ 156 for ($i=0, $key=&self::$_configs; $i<count($args); $key=&$key[$args[$i++]]); 157 158 /* updating the value. p.s: $key is a pointer to a $_config node */ 159 $key = $value; 160 return true; 161 } 162 163 /** 164 * Here we check if the configuration was defined into $_configs array. 165 * If it does not, an exception will be thrown. 166 * 167 * @param string $args A variable number of parameters which specify the scope 168 * and the configuration to be retrieved. 169 * @access private 170 * @return boolean 171 * @static 172 */ 173 private static function _keyExists($path) { 174 175 /** 176 * p.s: Do not try to understand this piece of code. Just fave faith! It works... 177 */ 178 for ($i=0, $sub_array=&self::$_configs; $i<count($path); $sub_array=&$sub_array[$path[$i++]]) { 179 if (!array_key_exists($path[$i], $sub_array)) 180 throw new Exception("Sorry! Setting '".implode("->", $path)."' do not exists."); 181 } 182 return true; 125 183 } 126 184 … … 143 201 self::$_configs['expresso']['db']['type'] = $GLOBALS['phpgw_info']['server']['db_type']; 144 202 203 /* current user information */ 204 self::$_configs['expresso']['user']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 205 self::$_configs['expresso']['user']['account_lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; 206 self::$_configs['expresso']['user']['account_dn'] = $GLOBALS['phpgw_info']['user']['account_dn']; 207 self::$_configs['expresso']['user']['userid'] = $GLOBALS['phpgw_info']['user']['userid']; 208 self::$_configs['expresso']['user']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd']; 209 self::$_configs['expresso']['user']['email'] = $GLOBALS['phpgw_info']['user']['email']; 210 145 211 self::$_configs['expresso']['ldap']['host'] = $GLOBALS['phpgw_info']['server']['ldap_host']; 212 self::$_configs['expresso']['ldap']['user_context'] = $GLOBALS['phpgw_info']['server']['ldap_user_context']; 213 self::$_configs['expresso']['ldap']['group_context'] = $GLOBALS['phpgw_info']['server']['ldap_group_context']; 214 215 /* workflow specific preferences */ 216 self::$_configs['workflow']['preferences']['startpage'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['startpage']; 217 self::$_configs['workflow']['preferences']['ui_items_per_page'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['ui_items_per_page']; 218 self::$_configs['workflow']['preferences']['show_activity_complete_page'] = $GLOBALS['phpgw_info']['user']['preferences']['workflow']['show_activity_complete_page']; 219 220 /*expresso preferences */ 221 self::$_configs['expresso']['preferences']['lang'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']; 222 223 self::$_configs['expresso']['webserver_url'] = $GLOBALS['phpgw_info']['server']['webserver_url']; 146 224 147 225 /* loading database settings */ … … 151 229 self::$_configs['workflow']['intranet_subnetworks'] = $values['intranet_subnetworks']; 152 230 153 self::$_configs['workflow']['db ']['name'] = $values['database_name'];154 self::$_configs['workflow']['db ']['host'] = $values['database_host'];155 self::$_configs['workflow']['db ']['port'] = $values['database_port'];156 self::$_configs['workflow']['db ']['admin_user'] = $values['database_admin_user'];157 self::$_configs['workflow']['db ']['admin_password'] = $values['database_admin_password'];158 self::$_configs['workflow']['db ']['type'] = $values['database_type'];159 160 self::$_configs['workflow'][' galaxia']['db']['name'] = $values['workflow_database_name'];161 self::$_configs['workflow'][' galaxia']['db']['host'] = $values['workflow_database_host'];162 self::$_configs['workflow'][' galaxia']['db']['port'] = $values['workflow_database_port'];163 self::$_configs['workflow'][' galaxia']['db']['user'] = $values['workflow_database_user'];164 self::$_configs['workflow'][' galaxia']['db']['password'] = $values['workflow_database_password'];165 self::$_configs['workflow'][' galaxia']['db']['type'] = $values['workflow_database_type'];231 self::$_configs['workflow']['db_processes']['name'] = $values['database_name']; 232 self::$_configs['workflow']['db_processes']['host'] = $values['database_host']; 233 self::$_configs['workflow']['db_processes']['port'] = $values['database_port']; 234 self::$_configs['workflow']['db_processes']['admin_user'] = $values['database_admin_user']; 235 self::$_configs['workflow']['db_processes']['admin_password'] = $values['database_admin_password']; 236 self::$_configs['workflow']['db_processes']['type'] = $values['database_type']; 237 238 self::$_configs['workflow']['db_module']['name'] = $values['workflow_database_name']; 239 self::$_configs['workflow']['db_module']['host'] = $values['workflow_database_host']; 240 self::$_configs['workflow']['db_module']['port'] = $values['workflow_database_port']; 241 self::$_configs['workflow']['db_module']['user'] = $values['workflow_database_user']; 242 self::$_configs['workflow']['db_module']['password'] = $values['workflow_database_password']; 243 self::$_configs['workflow']['db_module']['type'] = $values['workflow_database_type']; 166 244 167 245 self::$_configs['workflow']['ldap']['host'] = $values['ldap_host']; … … 169 247 self::$_configs['workflow']['ldap']['password'] = $values['ldap_password']; 170 248 self::$_configs['workflow']['ldap']['follow_referrals'] = $values['ldap_follow_referrals']; 249 self::$_configs['workflow']['ldap']['user_context'] = $values['ldap_user_context']; 250 self::$_configs['workflow']['ldap']['group_context'] = $values['ldap_group_context']; 171 251 172 252 /* the settings are already loaded. No need to call this method again. */
Note: See TracChangeset
for help on using the changeset viewer.