]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/classes/cfg/config.classe.php
bacula-web: Removed useless functions in bweb php classe
[bacula/bacula] / gui / bacula-web / classes / cfg / config.classe.php
1 <?php
2
3  class BW_Config {
4  
5         private $config_params;
6         private $config;
7         private $catalogs = array();
8         
9         function __construct()
10         {
11                 global $config;
12                 $this->config = $config;
13         }
14         
15         public function Check_Config_file()
16         {
17                 // Check if config file exist and is readable
18                 return is_readable( CONFIG_FILE );
19         }
20         
21         public function Load_Config()
22         {
23                 global $config;
24                 
25                 if( is_array($config) && !empty($config) ) {
26                         // Loading database connection information
27                         foreach( $config as $parameter => $value )
28                         {
29                                 if( is_array($value) )          // Parsing database section
30                                         array_push( $this->catalogs, $value );
31                         }
32                         return true;
33                 }else {
34                         return false;           
35                 }
36         }
37         
38         public function Get_Config_Param( $param )
39         {
40                 if( isset( $config[$param] ) )
41                         return $config[$param];
42         }
43         
44         public function Get_Catalogs()
45         {
46                 $result = array();
47                 foreach( $this->catalogs as $db )
48                         array_push( $result, $db['label']);
49                 
50                 return $result;
51         }
52         
53         public function Count_Catalogs()
54         {
55                 return count( $this->catalogs );
56         }
57         
58         public function Get_Dsn( $catalog_id )
59         {
60                 // Construct a valid dsn
61                 $dsn = array();
62         $dsn['hostspec'] = $this->catalogs[$catalog_id]["host"];
63         $dsn['username'] = $this->catalogs[$catalog_id]["login"];
64                 $dsn['password'] = $this->catalogs[$catalog_id]["password"];
65                 $dsn['database'] = $this->catalogs[$catalog_id]["db_name"];
66                 $dsn['phptype']  = $this->catalogs[$catalog_id]["db_type"];
67                 return $dsn;
68         }
69                 
70         function __destruct()
71         {
72                 
73         }
74         
75  } // end classe BW_Config
76  
77 ?>