ILIAS  Release_5_0_x_branch Revision 61816
 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  self::delete($a_key);
93 
94  $ilDB->insert("payment_settings", array(
95  "keyword" => array("text", $a_key),
96  "value" => array("clob", $a_val),
97  "scope" => array("text", $a_scope)));
98 
99  self::$_instance->setting[$a_key] = $a_val;
100 
101  return true;
102  }
103 
104  public function delete($a_key)
105  {
106  global $ilDB;
107 
108  $ilDB->manipulateF('
109  DELETE FROM payment_settings
110  WHERE keyword = %s',
111  array('text'), array($a_key));
112  }
113 
114  public static function _isPaymentEnabled()
115  {
116  if(!isset(self::$_instance))
117  {
119  }
120 
121  return self::$_instance->setting['shop_enabled'];
122  }
123  public static function setMailUsePlaceholders($a_mail_use_placeholders)
124  {
125  self::set('mail_use_placeholders',$a_mail_use_placeholders);
126  }
127 
128  public static function getMailUsePlaceholders()
129  {
130  if(!isset(self::$_instance))
131  {
133  }
134 
135  return self::$_instance->setting['mail_use_placeholders'];
136  }
137 
138  public static function setMailBillingText($a_mail_billing_text)
139  {
140  self::set('mail_billing_text',$a_mail_billing_text);
141  }
142 
143  public static function getMailBillingText()
144  {
145  if(!isset(self::$_instance))
146  {
148  }
149 
150  return self::$_instance->setting['mail_billing_text'];
151 
152  }
153 
154  public static function useShopSpecials()
155  {
156  if(!isset(self::$_instance))
157  {
159  }
160 
161  return self::$_instance->setting['use_shop_specials'];
162 
163  }
164 }