ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPaymentSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 {
6  private static $_instance;
7 
8  public $db;
9  public $setting = array();
10 
11  public static function _getInstance()
12  {
13  if(!isset(self::$_instance))
14  {
15  self::$_instance = new ilPaymentSettings();
16  }
17 
18  return self::$_instance;
19  }
20 
21  private function __construct()
22  {
23  global $ilDB;
24 
25  $this->db = $ilDB;
26  $this->__getSettings();
27  }
28 
29  private function __getSettings()
30  {
31  $res = $this->db->query('SELECT * FROM payment_settings');
32 
33  $this->setting = array();
34  while($row = $this->db->fetchAssoc($res))
35  {
36  $this->setting[$row["keyword"]] = $row["value"];
37  }
38  }
39 
40  public function getAll()
41  {
42  return $this->setting;
43  }
44 
45  public function get($a_key)
46  {
47  return $this->setting[$a_key];
48  }
49 
50  public function getValuesByScope($a_scope)
51  {
52  global $ilDB;
53 
54  $res = $ilDB->queryF('
55  SELECT * FROM payment_settings
56  WHERE scope = %s',
57  array('text'), array($a_scope));
58 
59  $settings = array();
60  while($row = $this->db->fetchAssoc($res))
61  {
62  $settings[$row["keyword"]] = $row["value"];
63  }
64  return $settings;
65  }
66 
75  public function set($a_key, $a_val, $a_scope = null)
76  {
77  global $ilDB;
78 
79  if($a_scope == null)
80  {
81  // check if scope is already set
82  $res = $ilDB->queryF('
83  SELECT scope FROM payment_settings
84  WHERE keyword = %s',
85  array('text'), array($a_key));
86 
87  $row = $ilDB->fetchAssoc($res);
88  $a_scope = $row['scope'];
89 
90  }
91 
92 
93  self::delete($a_key);
94 
95  $ilDB->insert("payment_settings", array(
96  "keyword" => array("text", $a_key),
97  "value" => array("clob", $a_val),
98  "scope" => array("text", $a_scope)));
99 
100  self::$_instance->setting[$a_key] = $a_val;
101 
102  return true;
103  }
104 
105  public function delete($a_key)
106  {
107  global $ilDB;
108 
109  $ilDB->manipulateF('
110  DELETE FROM payment_settings
111  WHERE keyword = %s',
112  array('text'), array($a_key));
113  }
114 
115  public static function _isPaymentEnabled()
116  {
117  if(!isset(self::$_instance))
118  {
120  }
121 
122  return self::$_instance->setting['shop_enabled'];
123  }
124  public static function setMailUsePlaceholders($a_mail_use_placeholders)
125  {
126 
127  self::set('mail_use_placeholders',$a_mail_use_placeholders);
128 
129 
130 # global $ilDB;
131 #
132 # $res = $ilDB->manipulateF('UPDATE payment_settings
133 # SET mail_use_placeholders = %s',
134 # array('integer'), array($a_mail_use_placeholders));
135 
136  }
137 
138  public static function getMailUsePlaceholders()
139  {
140  if(!isset(self::$_instance))
141  {
143  }
144 
145  return self::$_instance->setting['mail_use_placeholders'];
146  }
147 
148  public static function setMailBillingText($a_mail_billing_text)
149  {
150  self::set('mail_billing_text',$a_mail_billing_text);
151 
152  # global $ilDB;
153 
154  # $ilDB->update('payment_settings',
155  # array('mail_billing_text' => array('clob', $a_mail_billing_text)),
156  # array('settings_id' => array('integer',1)));
157  }
158 
159  public static function getMailBillingText()
160  {
161  if(!isset(self::$_instance))
162  {
164  }
165 
166  return self::$_instance->setting['mail_billing_text'];
167 
168  }
169 
170  public static function useShopSpecials()
171  {
172  if(!isset(self::$_instance))
173  {
175  }
176 
177  return self::$_instance->setting['use_shop_specials'];
178 
179  }
180 
181  public function clearAll()
182  {
183  // NO !
184  }
185  public function setAll($a_array)
186  {
187  // NO !
188  }
189 
190 }
191 ?>