507a46244bf22926b2029bce7aadc5e42cb1093c
[gnucomo.git] / src / web / classes / 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 require_once('configuration.class.php');
9
10 /*
11 ///////////////////////////////////////////////////////////////////////////
12 //  NAME           : gnucomo_config
13 //  BASECLASS      : configuration
14 //  MEMBERS        : 
15 //  OPERATORS      :
16 //  METHODS        : Database - Obtain the database access string
17 //
18 //  DESCRIPTION    : Provides Gnucomo-specific configuration functions
19 //
20 //  RELATIONS      :
21 //  SEE ALSO       :
22 //  LAST MODIFIED  : Nov 21, 2002
23 ///////////////////////////////////////////////////////////////////////////
24 */
25
26 class gnucomo_config extends configuration
27 {
28
29    // Return the database access string.
30
31    function Database($usr = "", $pw = "")
32    {
33       $access_string = "";
34
35       $param = $this->find_parameter("database", "name");
36       if ($param != "")
37       {
38          $access_string .= "dbname=" . $param;
39       }
40
41       if ($usr == "")
42       {
43          $param = $this->find_parameter("database", "user");
44          if ($param != "")
45          {
46             $access_string .= " user=" . $param;
47          }
48       }
49       else
50       {
51          $access_string .= " user=" . $usr;
52       }
53
54       if ($pw == "")
55       {
56          $param = $this->find_parameter("database", "password");
57          if ($param != "")
58          {
59             $access_string .= " password=" . $param;
60          }
61       }
62       else
63       {
64          $access_string .= " password=" . $pw;
65       }
66
67       $param = $this->find_parameter("database", "host");
68       if ($param != "")
69       {
70          $access_string .= " host=" . $param;
71       }
72
73       $param = $this->find_parameter("database", "port");
74       if ($param != "")
75       {
76          $access_string .= " port=" . $param;
77       }
78       return $access_string;
79    }
80 };
81 ?>