ILIAS  Release_4_0_x_branch Revision 61816
 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  $res = $this->db->queryf('
94  SELECT bmf FROM payment_settings
95  WHERE settings_id = %s',
96  array('integer'),
97  array($this->getSettingsId())
98  );
99 
100  $result = $this->db->fetchObject($res);
101 
102  $data = array();
103 
104  if (is_object($result))
105  {
106 
107  if ($result->bmf != "")
108  {
109  $data = unserialize($result->bmf);
110  }
111  else
112  {
113  $data = array();
114  }
115  }
116 
117  $this->setClientId($data["mandantNr"]);
118  $this->setBewirtschafterNr($data["bewirtschafterNr"]);
119  $this->setHaushaltsstelle($data["haushaltsstelle"]);
120  $this->setObjectId($data["objektNr"]);
121  $this->setKennzeichenMahnverfahren($data["kennzeichenMahnverfahren"]);
122  $this->setWaehrungsKennzeichen($data["waehrungskennzeichen"]);
123  $this->setEpaymentServer($data["ePaymentServer"]);
124  $this->setClientCertificate($data["clientCertificate"]);
125  $this->setCaCertificate($data["caCertificate"]);
126  $this->setTimeout($data["timeOut"]);
127  }
128 
134  private function fetchSettingsId()
135  {
136  $result = $this->db->query('SELECT settings_id FROM payment_settings');
137 
138  while($row = $this->db->fetchObject($result))
139  {
140  $this->setSettingsId($row->settings_id);
141  }
142 }
143 
144  public function setSettingsId($a_settings_id = 0)
145  {
146  $this->settings_id = $a_settings_id;
147  }
148  public function getSettingsId()
149  {
150  return $this->settings_id;
151  }
152  public function setClientId($a_client_id)
153  {
154  $this->client_id = $a_client_id;
155  }
156  public function getClientId()
157  {
158  return $this->client_id;
159  }
160  public function setBewirtschafterNr($a_bewirtschafter_nr)
161  {
162  $this->bewirtschafter_nr = $a_bewirtschafter_nr;
163  }
164  public function getBewirtschafterNr()
165  {
167  }
168  public function setHaushaltsstelle($a_haushaltsstelle)
169  {
170  $this->haushaltsstelle = $a_haushaltsstelle;
171  }
172  public function getHaushaltsstelle()
173  {
174  return $this->haushaltsstelle;
175  }
176  public function setObjectId($a_object_id)
177  {
178  $this->object_id = $a_object_id;
179  }
180  public function getObjectId()
181  {
182  return $this->object_id;
183  }
184  public function setKennzeichenMahnverfahren($a_kennzeichen_mahnverfahren)
185  {
186  $this->kennzeichen_mahnverfahren = $a_kennzeichen_mahnverfahren;
187  }
188  public function getKennzeichenMahnverfahren()
189  {
191  }
192  public function setWaehrungsKennzeichen($a_waehrungs_kennzeichen)
193  {
194  $this->waehrungs_kennzeichen = $a_waehrungs_kennzeichen;
195  }
196  public function getWaehrungsKennzeichen()
197  {
199  }
200  public function setEpaymentServer($a_epayment_server)
201  {
202  $this->epayment_server = $a_epayment_server;
203  }
204  public function getEpaymentServer()
205  {
206  return $this->epayment_server;
207  }
208  public function setClientCertificate($a_client_certificate)
209  {
210  $this->client_certificate = $a_client_certificate;
211  }
212  public function getClientCertificate()
213  {
215  }
216  public function setCaCertificate($a_ca_certificate)
217  {
218  $this->ca_certificate = $a_ca_certificate;
219  }
220  public function getCaCertificate()
221  {
222  return $this->ca_certificate;
223  }
224  public function setTimeout($a_timeout)
225  {
226  $this->timeout = $a_timeout;
227  }
228  public function getTimeout()
229  {
230  return $this->timeout;
231  }
232 
239  function getAll()
240  {
241  $values = array(
242  "mandantNr" => $this->getClientId(),
243  "bewirtschafterNr" => $this->getBewirtschafterNr(),
244  "haushaltsstelle" => $this->getHaushaltsstelle(),
245  "objektNr" => $this->getObjectId(),
246  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
247  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
248  "ePaymentServer" => $this->getEpaymentServer(),
249  "clientCertificate" => $this->getClientCertificate(),
250  "caCertificate" => $this->getCaCertificate(),
251  "timeOut" => $this->getTimeOut()
252  );
253 
254  return $values;
255  }
256 
262  public function clearAll()
263  {
264  $statement = $this->db->manipulateF('
265  UPDATE payment_settings
266  SET bmf = %s
267  WHERE settings_id = %s',
268  array('text', 'integer'),
269  array('NULL', $this->getSettingsId())
270  );
271 
272  }
273 
279  public function save()
280  {
281 
282  global $ilDB;
283 
284  $values = array(
285  "mandantNr" => $this->getClientId(),
286  "bewirtschafterNr" => $this->getBewirtschafterNr(),
287  "haushaltsstelle" => $this->getHaushaltsstelle(),
288  "objektNr" => $this->getObjectId(),
289  "kennzeichenMahnverfahren" => $this->getKennzeichenMahnverfahren(),
290  "waehrungskennzeichen" => $this->getWaehrungsKennzeichen(),
291  "ePaymentServer" => $this->getEpaymentServer(),
292  "clientCertificate" => $this->getClientCertificate(),
293  "caCertificate" => $this->getCaCertificate(),
294  "timeOut" => $this->getTimeOut()
295  );
296 
297  if ($this->getSettingsId())
298  {
299 
300  $statement = $this->db->manipulateF('
301  UPDATE payment_settings
302  SET bmf = %s
303  WHERE settings_id = %s',
304  array('text', 'integer'),
305  array(serialize($values), $this->getSettingsId())
306  );
307  }
308  else
309  {
310  $next_id = $ilDB->nextId('payment_settings');
311  $statement = $this->db->manipulateF('
312  INSERT into payment_settings
313  ( settings_id,
314  bmf)
315  VALUES (%s, %s)',
316  array('integer','text'),
317  array($next_id, serialize($values))
318  );
319 
320  $this->setSettingsId($next_id);
321 
322  }
323  }
324 }
325 ?>