Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 class ilGeneralSettings
00025 {
00026 var $db;
00027
00028 var $settings;
00029
00030 function ilGeneralSettings()
00031 {
00032 global $ilDB;
00033
00034 $this->db =& $ilDB;
00035
00036 $this->__getSettings();
00037 }
00038
00044 private function fetchSettingsId()
00045 {
00046 $query = "SELECT * FROM payment_settings";
00047 $result = $this->db->getrow($query);
00048
00049 $this->setSettingsId($result->settings_id);
00050 }
00051
00052 public function setSettingsId($a_settings_id = 0)
00053 {
00054 $this->settings_id = $a_settings_id;
00055 }
00056 public function getSettingsId()
00057 {
00058 return $this->settings_id;
00059 }
00060
00061 function get($a_type)
00062 {
00063 return $this->settings[$a_type];
00064 }
00065
00066 function getAll()
00067 {
00068 return $this->settings;
00069 }
00070
00071 function clearAll()
00072 {
00073 $query = "UPDATE payment_settings ";
00074 $query .= "SET currency_unit = '', ";
00075 $query .= "currency_subunit = '', ";
00076 $query .= "address = '', ";
00077 $query .= "bank_data = '', ";
00078 $query .= "add_info = '', ";
00079 $query .= "vat_rate = '', ";
00080 $query .= "pdf_path = '' ";
00081 $query .= "WHERE settings_id = '" . $this->getSettingsId() . "'";
00082
00083 $this->db->query($query);
00084
00085 return true;
00086 }
00087
00088 function setAll($a_values)
00089 {
00090 global $ilDB;
00091
00092 if ($this->getSettingsId())
00093 {
00094 $query = "UPDATE payment_settings ";
00095 $query .= "SET currency_unit = " . $ilDB->quote($a_values["currency_unit"]) . ", ";
00096 $query .= "currency_subunit = " . $ilDB->quote($a_values["currency_subunit"]) . ", ";
00097 $query .= "address = " . $ilDB->quote($a_values["address"]) . ", ";
00098 $query .= "bank_data = " . $ilDB->quote($a_values["bank_data"]) . ", ";
00099 $query .= "add_info = " . $ilDB->quote($a_values["add_info"]) . ", ";
00100 $query .= "vat_rate = " . $ilDB->quote($a_values["vat_rate"]) . ", ";
00101 $query .= "pdf_path = " . $ilDB->quote($a_values["pdf_path"]) . " ";
00102 $query .= "WHERE settings_id = '" . $this->getSettingsId() . "'";
00103
00104 $this->db->query($query);
00105 }
00106 else
00107 {
00108 $query = "INSERT INTO payment_settings (currency_unit, currency_subunit, address, bank_data, add_info, vat_rate, pdf_path) VALUES (";
00109 $query .= $ilDB->quote($a_values["currency_unit"]) . ", ";
00110 $query .= $ilDB->quote($a_values["currency_subunit"]) . ", ";
00111 $query .= $ilDB->quote($a_values["address"]) . ", ";
00112 $query .= $ilDB->quote($a_values["bank_data"]) . ", ";
00113 $query .= $ilDB->quote($a_values["add_info"]) . ", ";
00114 $query .= $ilDB->quote($a_values["vat_rate"]) . ", ";
00115 $query .= $ilDB->quote($a_values["pdf_path"]) . ")";
00116 $this->db->query($query);
00117
00118 $this->setSettingsId($this->db->getLastInsertId());
00119 }
00120
00121
00122 $this->__getSettings();
00123
00124 return true;
00125 }
00126
00127 function __getSettings()
00128 {
00129 $this->fetchSettingsId();
00130
00131 $query = "SELECT * FROM payment_settings";
00132 $result = $this->db->getrow($query);
00133
00134 $data = array();
00135 if (is_object($result))
00136 {
00137 $data["currency_unit"] = $result->currency_unit;
00138 $data["currency_subunit"] = $result->currency_subunit;
00139 $data["address"] = $result->address;
00140 $data["bank_data"] = $result->bank_data;
00141 $data["add_info"] = $result->add_info;
00142 $data["vat_rate"] = $result->vat_rate;
00143 $data["pdf_path"] = $result->pdf_path;
00144 }
00145
00146 $this->settings = $data;
00147 }
00148
00149 }
00150 ?>