ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBMFSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
17  private $db;
18 
19  private $settings_id;
20 
21  private $client_id;
24  private $object_id;
29  private $ca_certificate;
30  private $timeout;
31 
32  static private $instance = null;
33 
40  static public function getInstance()
41  {
42  if (!self::$instance)
43  {
44  self::$instance = new ilBMFSettings();
45  }
46 
47  return self::$instance;
48  }
49 
55  private function ilBMFSettings()
56  {
57  global $ilDB;
58 
59  $this->db = $ilDB;
60 
61  $this->getSettings();
62  }
63 
69  private function getSettings()
70  {
71  $this->fetchSettingsId();
72 
73  $res = $this->db->queryf('
74  SELECT bmf FROM payment_settings
75  WHERE settings_id = %s',
76  array('integer'),
77  array($this->getSettingsId())
78  );
79 
80  $result = $this->db->fetchObject($res);
81 
82  $data = array();
83 
84  if (is_object($result))
85  {
86 
87  if ($result->bmf != "")
88  {
89  $data = unserialize($result->bmf);
90  }
91  else
92  {
93  $data = array();
94  }
95  }
96 
97  $this->setClientId($data["mandantNr"]);
98  $this->setBewirtschafterNr($data["bewirtschafterNr"]);
99  $this->setHaushaltsstelle($data["haushaltsstelle"]);
100  $this->setObjectId($data["objektNr"]);
101  $this->setKennzeichenMahnverfahren($data["kennzeichenMahnverfahren"]);
102  $this->setWaehrungsKennzeichen($data["waehrungskennzeichen"]);
103  $this->setEpaymentServer($data["ePaymentServer"]);
104  $this->setClientCertificate($data["clientCertificate"]);
105  $this->setCaCertificate($data["caCertificate"]);
106  $this->setTimeout($data["timeOut"]);
107  }
108 
114  private function fetchSettingsId()
115  {
116  $result = $this->db->query('SELECT settings_id FROM payment_settings');
117 
118  while($row = $this->db->fetchObject($result))
119  {
120  $this->setSettingsId($row->settings_id);
121  }
122 }
123 
124  public function setSettingsId($a_settings_id = 0)
125  {
126  $this->settings_id = $a_settings_id;
127  }
128  public function getSettingsId()
129  {
130  return $this->settings_id;
131  }
132  public function setClientId($a_client_id)
133  {
134  $this->client_id = $a_client_id;
135  }
136  public function getClientId()
137  {
138  return $this->client_id;
139  }
140  public function setBewirtschafterNr($a_bewirtschafter_nr)
141  {
142  $this->bewirtschafter_nr = $a_bewirtschafter_nr;
143  }
144  public function getBewirtschafterNr()
145  {
147  }
148  public function setHaushaltsstelle($a_haushaltsstelle)
149  {
150  $this->haushaltsstelle = $a_haushaltsstelle;
151  }
152  public function getHaushaltsstelle()
153  {
154  return $this->haushaltsstelle;
155  }
156  public function setObjectId($a_object_id)
157  {
158  $this->object_id = $a_object_id;
159  }
160  public function getObjectId()
161  {
162  return $this->object_id;
163  }
164  public function setKennzeichenMahnverfahren($a_kennzeichen_mahnverfahren)
165  {
166  $this->kennzeichen_mahnverfahren = $a_kennzeichen_mahnverfahren;
167  }
168  public function getKennzeichenMahnverfahren()
169  {
171  }
172  public function setWaehrungsKennzeichen($a_waehrungs_kennzeichen)
173  {
174  $this->waehrungs_kennzeichen = $a_waehrungs_kennzeichen;
175  }
176  public function getWaehrungsKennzeichen()
177  {
179  }
180  public function setEpaymentServer($a_epayment_server)
181  {
182  $this->epayment_server = $a_epayment_server;
183  }
184  public function getEpaymentServer()
185  {
186  return $this->epayment_server;
187  }
188  public function setClientCertificate($a_client_certificate)
189  {
190  $this->client_certificate = $a_client_certificate;
191  }
192  public function getClientCertificate()
193  {
195  }
196  public function setCaCertificate($a_ca_certificate)
197  {
198  $this->ca_certificate = $a_ca_certificate;
199  }
200  public function getCaCertificate()
201  {
202  return $this->ca_certificate;
203  }
204  public function setTimeout($a_timeout)
205  {
206  $this->timeout = $a_timeout;
207  }
208  public function getTimeout()
209  {
210  return $this->timeout;
211  }
212 
219  function getAll()
220  {
221  $values = array(
222  "mandantNr" => $this->getClientId(),
223  "bewirtschafterNr" => $this->getBewirtschafterNr(),
224  "haushaltsstelle" => $this->getHaushaltsstelle(),
225  "objektNr" => $this->getObjectId(),
226  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
227  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
228  "ePaymentServer" => $this->getEpaymentServer(),
229  "clientCertificate" => $this->getClientCertificate(),
230  "caCertificate" => $this->getCaCertificate(),
231  "timeOut" => $this->getTimeOut()
232  );
233 
234  return $values;
235  }
236 
242  public function clearAll()
243  {
244  $statement = $this->db->manipulateF('
245  UPDATE payment_settings
246  SET bmf = %s
247  WHERE settings_id = %s',
248  array('text', 'integer'),
249  array('NULL', $this->getSettingsId())
250  );
251 
252  }
253 
259  public function save()
260  {
261 
262  global $ilDB;
263 
264  $values = array(
265  "mandantNr" => $this->getClientId(),
266  "bewirtschafterNr" => $this->getBewirtschafterNr(),
267  "haushaltsstelle" => $this->getHaushaltsstelle(),
268  "objektNr" => $this->getObjectId(),
269  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
270  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
271  "ePaymentServer" => $this->getEpaymentServer(),
272  "clientCertificate" => $this->getClientCertificate(),
273  "caCertificate" => $this->getCaCertificate(),
274  "timeOut" => $this->getTimeOut()
275  );
276 
277  if ($this->getSettingsId())
278  {
279 
280  $statement = $this->db->manipulateF('
281  UPDATE payment_settings
282  SET bmf = %s
283  WHERE settings_id = %s',
284  array('text', 'integer'),
285  array(serialize($values), $this->getSettingsId())
286  );
287  }
288  else
289  {
290  $next_id = $ilDB->nextId('payment_settings');
291  $statement = $this->db->manipulateF('
292  INSERT into payment_settings
293  ( settings_id,
294  bmf)
295  VALUES (%s, %s)',
296  array('integer','text'),
297  array($next_id, serialize($values))
298  );
299 
300  $this->setSettingsId($next_id);
301 
302  }
303  }
304 }
305 ?>