67061c71a6c7d2d5757cf32d79fa3f5f88c61e43
1 <?php
3 /**
4 * ConfigManagerException to handle exceptions that happen inside
5 * the config manager module.
6 */
7 class ConfigManagerException extends Exception {
8 public function __construct($message, $code = 0) {
9 parent::__construct($message, $code);
10 }
11 }
15 /**
16 * ConfigManager loads and manages GOsa session configurations.
17 *
18 * This class should be integrated via Registry.
19 */
20 class ConfigManager {
22 /* Config container */
23 protected $config= NULL;
25 public function __construct(){}
27 /**
28 * Returns a static instance of $class
29 * Creates a new instance of $class if required.
30 * @param string $class
31 * @return obj $$class
32 */
33 public function load($file){
34 if (!is_readable($file)){
35 throw new ConfigManagerException(sprintf(_("Can't read configuration file '%s'!"), $file));
36 }
38 /* Capture errors - just the first line is interesting */
39 ob_start();
40 $this->config= parse_ini_file($file, TRUE);
41 $ret= preg_replace( array('/^.*\nWarning: /', '/\n.*$/'),
42 array('', ''),
43 ob_get_contents());
44 ob_end_clean();
46 /* Bail out in case of errors */
47 if ($ret != ""){
48 throw new ConfigManagerException($ret);
49 }
51 echo "Test config and load additional configuration data from LDAP\n";
52 #$this->test_config();
53 #$this->load_servers(); -> Section servers/...;
54 #$this->load_plugin_configs(); -> Section pugins/name/value;
56 print_r($this->config);
57 }
60 public function save($file){
61 }
64 public function set_section($section_name){
65 }
68 public function &get_section(){
69 }
72 public function &get_sections(){
73 }
76 public function &get_value($section){
77 }
80 public function set_value($section, $value){
81 }
83 }
85 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
86 ?>