ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBMFSettings.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 
36 {
37  private $db;
38 
39  private $settings_id;
40 
41  private $client_id;
44  private $object_id;
49  private $ca_certificate;
50  private $timeout;
51 
52  static private $instance = null;
53 
60  static public function getInstance()
61  {
62  if (!self::$instance)
63  {
64  self::$instance = new ilBMFSettings();
65  }
66 
67  return self::$instance;
68  }
69 
75  private function ilBMFSettings()
76  {
77  global $ilDB;
78 
79  $this->db =& $ilDB;
80 
81  $this->getSettings();
82  }
83 
89  private function getSettings()
90  {
91  $this->fetchSettingsId();
92 
93  $query = "SELECT bmf FROM payment_settings WHERE settings_id = '" . $this->getSettingsId() . "'";
94  $result = $this->db->getrow($query);
95 
96  $data = array();
97  if (is_object($result))
98  {
99  if ($result->bmf != "") $data = unserialize($result->bmf);
100  else $data = array();
101  }
102 
103  $this->setClientId($data["mandantNr"]);
104  $this->setBewirtschafterNr($data["bewirtschafterNr"]);
105  $this->setHaushaltsstelle($data["haushaltsstelle"]);
106  $this->setObjectId($data["objektNr"]);
107  $this->setKennzeichenMahnverfahren($data["kennzeichenMahnverfahren"]);
108  $this->setWaehrungsKennzeichen($data["waehrungskennzeichen"]);
109  $this->setEpaymentServer($data["ePaymentServer"]);
110  $this->setClientCertificate($data["clientCertificate"]);
111  $this->setCaCertificate($data["caCertificate"]);
112  $this->setTimeout($data["timeOut"]);
113  }
114 
120  private function fetchSettingsId()
121  {
122  $query = "SELECT * FROM payment_settings";
123  $result = $this->db->getrow($query);
124 
125  $this->setSettingsId($result->settings_id);
126  }
127 
128  public function setSettingsId($a_settings_id = 0)
129  {
130  $this->settings_id = $a_settings_id;
131  }
132  public function getSettingsId()
133  {
134  return $this->settings_id;
135  }
136  public function setClientId($a_client_id)
137  {
138  $this->client_id = $a_client_id;
139  }
140  public function getClientId()
141  {
142  return $this->client_id;
143  }
144  public function setBewirtschafterNr($a_bewirtschafter_nr)
145  {
146  $this->bewirtschafter_nr = $a_bewirtschafter_nr;
147  }
148  public function getBewirtschafterNr()
149  {
151  }
152  public function setHaushaltsstelle($a_haushaltsstelle)
153  {
154  $this->haushaltsstelle = $a_haushaltsstelle;
155  }
156  public function getHaushaltsstelle()
157  {
158  return $this->haushaltsstelle;
159  }
160  public function setObjectId($a_object_id)
161  {
162  $this->object_id = $a_object_id;
163  }
164  public function getObjectId()
165  {
166  return $this->object_id;
167  }
168  public function setKennzeichenMahnverfahren($a_kennzeichen_mahnverfahren)
169  {
170  $this->kennzeichen_mahnverfahren = $a_kennzeichen_mahnverfahren;
171  }
172  public function getKennzeichenMahnverfahren()
173  {
175  }
176  public function setWaehrungsKennzeichen($a_waehrungs_kennzeichen)
177  {
178  $this->waehrungs_kennzeichen = $a_waehrungs_kennzeichen;
179  }
180  public function getWaehrungsKennzeichen()
181  {
183  }
184  public function setEpaymentServer($a_epayment_server)
185  {
186  $this->epayment_server = $a_epayment_server;
187  }
188  public function getEpaymentServer()
189  {
190  return $this->epayment_server;
191  }
192  public function setClientCertificate($a_client_certificate)
193  {
194  $this->client_certificate = $a_client_certificate;
195  }
196  public function getClientCertificate()
197  {
199  }
200  public function setCaCertificate($a_ca_certificate)
201  {
202  $this->ca_certificate = $a_ca_certificate;
203  }
204  public function getCaCertificate()
205  {
206  return $this->ca_certificate;
207  }
208  public function setTimeout($a_timeout)
209  {
210  $this->timeout = $a_timeout;
211  }
212  public function getTimeout()
213  {
214  return $this->timeout;
215  }
216 
223  function getAll()
224  {
225  $values = array(
226  "mandantNr" => $this->getClientId(),
227  "bewirtschafterNr" => $this->getBewirtschafterNr(),
228  "haushaltsstelle" => $this->getHaushaltsstelle(),
229  "objektNr" => $this->getObjectId(),
230  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
231  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
232  "ePaymentServer" => $this->getEpaymentServer(),
233  "clientCertificate" => $this->getClientCertificate(),
234  "caCertificate" => $this->getCaCertificate(),
235  "timeOut" => $this->getTimeOut()
236  );
237 
238  return $values;
239  }
240 
246  public function clearAll()
247  {
248  $query = "UPDATE payment_settings "
249  ."SET bmf = '' "
250  ."WHERE settings_id = '" . $this->getSettingsId() . "'";
251  $this->db->query($query);
252  }
253 
259  public function save()
260  {
261  global $ilDB;
262 
263  $values = array(
264  "mandantNr" => $this->getClientId(),
265  "bewirtschafterNr" => $this->getBewirtschafterNr(),
266  "haushaltsstelle" => $this->getHaushaltsstelle(),
267  "objektNr" => $this->getObjectId(),
268  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
269  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
270  "ePaymentServer" => $this->getEpaymentServer(),
271  "clientCertificate" => $this->getClientCertificate(),
272  "caCertificate" => $this->getCaCertificate(),
273  "timeOut" => $this->getTimeOut()
274  );
275 
276  if ($this->getSettingsId())
277  {
278  $query = "UPDATE payment_settings "
279  ."SET bmf = " . $ilDB->quote(serialize($values)). " "
280  ."WHERE settings_id = '" . $this->getSettingsId() . "'";
281  $this->db->query($query);
282  }
283  else
284  {
285  $query = "INSERT INTO payment_settings (bmf) VALUES (" . $ilDB->quote(serialize($values)). ") ";
286 
287  $this->db->query($query);
288 
289  $this->setSettingsId($this->db->getLastInsertId());
290  }
291  }
292 }
293 ?>