ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGeneralSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
25 {
26  private static $_instance;
27 
28  var $db;
29  var $settings;
30 
31  public static function _getInstance()
32  {
33  if(!isset(self::$_instance))
34  {
35  self::$_instance = new ilGeneralSettings();
36  }
37 
38  return self::$_instance;
39  }
40 
41  function ilGeneralSettings()
42  {
43  global $ilDB;
44 
45  $this->db =& $ilDB;
46 
47  $this->__getSettings();
48  }
49 
55  private function fetchSettingsId()
56  {
57  $query = "SELECT * FROM payment_settings";
58  $result = $this->db->getrow($query);
59 
60  $this->setSettingsId($result->settings_id);
61  }
62 
63  public function setSettingsId($a_settings_id = 0)
64  {
65  $this->settings_id = $a_settings_id;
66  }
67  public function getSettingsId()
68  {
69  return $this->settings_id;
70  }
71 
72  function get($a_type)
73  {
74  return $this->settings[$a_type];
75  }
76 
77  function getAll()
78  {
79  return $this->settings;
80  }
81 
82  function clearAll()
83  {
84  $query = "UPDATE payment_settings ";
85  $query .= "SET currency_unit = '', ";
86  $query .= "currency_subunit = '', ";
87  $query .= "address = '', ";
88  $query .= "bank_data = '', ";
89  $query .= "add_info = '', ";
90  $query .= "vat_rate = '', ";
91  $query .= "pdf_path = '', ";
92  $query .= "topics_sorting_type = 1, ";
93  $query .= "topics_sorting_direction = 'asc', ";
94  $query .= "topics_allow_custom_sorting = 0, ";
95  $query .= "max_hits = 20, ";
96  $query .= "shop_enabled = 0 ";
97  $query .= "WHERE settings_id = '" . $this->getSettingsId() . "'";
98 
99  $this->db->query($query);
100 
101  return true;
102  }
103 
104  function setAll($a_values)
105  {
106  global $ilDB;
107 
108  if ($this->getSettingsId())
109  {
110  $query = "UPDATE payment_settings ";
111  $query .= "SET currency_unit = " . $ilDB->quote($a_values["currency_unit"]) . ", ";
112  $query .= "currency_subunit = " . $ilDB->quote($a_values["currency_subunit"]) . ", ";
113  $query .= "address = " . $ilDB->quote($a_values["address"]) . ", ";
114  $query .= "bank_data = " . $ilDB->quote($a_values["bank_data"]) . ", ";
115  $query .= "add_info = " . $ilDB->quote($a_values["add_info"]) . ", ";
116  $query .= "vat_rate = " . $ilDB->quote($a_values["vat_rate"]) . ", ";
117  $query .= "pdf_path = " . $ilDB->quote($a_values["pdf_path"]) . ", ";
118  $query .= "topics_allow_custom_sorting = " . $ilDB->quote($a_values["topics_allow_custom_sorting"]) . ", ";
119  $query .= "topics_sorting_type = " . $ilDB->quote($a_values["topics_sorting_type"]) . ", ";
120  $query .= "topics_sorting_direction = " . $ilDB->quote($a_values["topics_sorting_direction"]) . ", ";
121  $query .= "max_hits = " . $ilDB->quote($a_values["max_hits"]) . ", ";
122  $query .= "shop_enabled = " . $ilDB->quote($a_values["shop_enabled"]) . " ";
123  $query .= "WHERE settings_id = '" . $this->getSettingsId() . "'";
124 
125  $this->db->query($query);
126  }
127  else
128  {
129  $query = "INSERT INTO payment_settings
130  SET
131  currency_unit = ".$ilDB->quote($a_values["currency_unit"]).",
132  currency_subunit = ".$ilDB->quote($a_values["currency_subunit"]).",
133  address = ".$ilDB->quote($a_values["address"]).",
134  bank_data = ".$ilDB->quote($a_values["bank_data"]).",
135  add_info = ".$ilDB->quote($a_values["add_info"]).",
136  vat_rate = ".$ilDB->quote($a_values["vat_rate"]).",
137  pdf_path = ".$ilDB->quote($a_values["pdf_path"]).",
138  topics_allow_custom_sorting = ".$ilDB->quote($a_values["topics_allow_custom_sorting"]).",
139  topics_sorting_type = ".$ilDB->quote($a_values["topics_sorting_type"]).",
140  topics_sorting_direction = ".$ilDB->quote($a_values["topics_sorting_direction"]).",
141  shop_enabled = ".$ilDB->quote($a_values["shop_enabled"]).",
142  max_hits = ".$ilDB->quote($a_values["topics_sorting_direction"]);
143  $this->db->query($query);
144 
145  $this->setSettingsId($this->db->getLastInsertId());
146  }
147 
148  $this->__getSettings();
149 
150  return true;
151  }
152 
153  function __getSettings()
154  {
155  $this->fetchSettingsId();
156 
157  $query = "SELECT * FROM payment_settings";
158  $result = $this->db->getrow($query);
159 
160  $data = array();
161  if (is_object($result))
162  {
163  $data["currency_unit"] = $result->currency_unit;
164  $data["currency_subunit"] = $result->currency_subunit;
165  $data["address"] = $result->address;
166  $data["bank_data"] = $result->bank_data;
167  $data["add_info"] = $result->add_info;
168  $data["vat_rate"] = $result->vat_rate;
169  $data["pdf_path"] = $result->pdf_path;
170  $data["topics_allow_custom_sorting"] = $result->topics_allow_custom_sorting;
171  $data["topics_sorting_type"] = $result->topics_sorting_type;
172  $data["topics_sorting_direction"] = $result->topics_sorting_direction;
173  $data["max_hits"] = $result->max_hits;
174  $data["shop_enabled"] = $result->shop_enabled;
175  }
176 
177  $this->settings = $data;
178  }
179 
180 }
181 ?>