Added a PHP5 module for the configuration class
[gnucomo.git] / src / phpclasses / gnucomo_config.php
1 <?php
2 /**************************************************************************
3 **  (c) Copyright 2002, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************/
7
8 if (substr(phpversion(), 0, 1) == "4")
9 {
10    require_once('configuration.class.php');
11 }
12 else
13 {
14    require_once('configuration.class.php5');
15 }
16
17 /*
18 ///////////////////////////////////////////////////////////////////////////
19 //  NAME           : gnucomo_config
20 //  BASECLASS      : configuration
21 //  MEMBERS        : 
22 //  OPERATORS      :
23 //  METHODS        : Database - Obtain the database access string
24 //
25 //  DESCRIPTION    : Provides Gnucomo-specific configuration functions
26 //
27 //  RELATIONS      :
28 //  SEE ALSO       :
29 //  LAST MODIFIED  : Nov 21, 2002
30 ///////////////////////////////////////////////////////////////////////////
31 */
32
33 class gnucomo_config extends configuration
34 {
35
36    // Return the database access string.
37
38    function Database($usr = "", $pw = "")
39    {
40       $access_string = "";
41
42       $param = $this->find_parameter("database", "name");
43       if ($param != "")
44       {
45          $access_string .= "dbname=" . $param;
46       }
47
48       if ($usr == "")
49       {
50          $param = $this->find_parameter("database", "user");
51          if ($param != "")
52          {
53             $access_string .= " user=" . $param;
54          }
55       }
56       else
57       {
58          $access_string .= " user=" . $usr;
59       }
60
61       if ($pw == "")
62       {
63          $param = $this->find_parameter("database", "password");
64          if ($param != "")
65          {
66             $access_string .= " password=" . $param;
67          }
68       }
69       else
70       {
71          $access_string .= " password=" . $pw;
72       }
73
74       $param = $this->find_parameter("database", "host");
75       if ($param != "")
76       {
77          $access_string .= " host=" . $param;
78       }
79
80       $param = $this->find_parameter("database", "port");
81       if ($param != "")
82       {
83          $access_string .= " port=" . $param;
84       }
85       return $access_string;
86    }
87 };
88 ?>