• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/classes/class.ilPaypalSettings.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00032 class ilPaypalSettings
00033 {
00034         private $db;
00035 
00036         private $settings;
00037         private $settings_id;
00038         
00039         private $server_host;
00040         private $server_path;
00041         private $vendor;
00042         private $auth_token;
00043         private $page_style;
00044         private $ssl;
00045         
00046         static private $instance = null;
00047         
00054         static public function getInstance()
00055         {
00056                 if (!self::$instance)
00057                 {
00058                 self::$instance = new ilPaypalSettings();
00059             }
00060             
00061             return self::$instance;                 
00062         }
00063 
00069         private function ilPaypalSettings()
00070         {
00071                 global $ilDB;
00072 
00073                 $this->db =& $ilDB;
00074 
00075                 $this->getSettings();
00076         }
00077         
00083         private function getSettings()
00084         {
00085                 $this->fetchSettingsId();
00086                 
00087                 $query = "SELECT paypal FROM payment_settings WHERE settings_id = '" .  $this->getSettingsId() . "'";
00088                 $result = $this->db->getrow($query);
00089 
00090                 $data = array();
00091                 if (is_object($result))
00092                 {
00093                         if ($result->paypal != "") $data = unserialize($result->paypal);
00094                         else $data = array();
00095                 }
00096 
00097                 $this->setServerHost($data["server_host"]);
00098                 $this->setServerPath($data["server_path"]);
00099                 $this->setVendor($data["vendor"]);
00100                 $this->setAuthToken($data["auth_token"]);
00101                 $this->setPageStyle($data["page_style"]);
00102                 $this->setSsl($data["ssl"]);
00103         }       
00104         
00110         private function fetchSettingsId()
00111         {
00112                 $query = "SELECT * FROM payment_settings";
00113                 $result = $this->db->getrow($query);
00114                 
00115                 $this->setSettingsId($result->settings_id);
00116         }
00117         
00118         public function setSettingsId($a_settings_id = 0)
00119         {
00120                 $this->settings_id = $a_settings_id;
00121         }
00122         public function getSettingsId()
00123         {
00124                 return $this->settings_id;
00125         }
00126         public function setServerHost($a_server_host)
00127         {
00128                 $this->server_host = $a_server_host;
00129         }
00130         public function getServerHost()
00131         {
00132                 return $this->server_host;
00133         }
00134         public function setServerPath($a_server_path)
00135         {
00136                 $this->server_path = $a_server_path;
00137         }
00138         public function getServerPath()
00139         {
00140                 return $this->server_path;
00141         }
00142         public function setVendor($a_vendor)
00143         {
00144                 $this->vendor = $a_vendor;
00145         }
00146         public function getVendor()
00147         {
00148                 return $this->vendor;
00149         }
00150         public function setAuthToken($a_auth_token)
00151         {
00152                 $this->auth_token = $a_auth_token;
00153         }
00154         public function getAuthToken()
00155         {
00156                 return $this->auth_token;
00157         }
00158         public function setPageStyle($a_page_style)
00159         {
00160                 $this->page_style = $a_page_style;
00161         }
00162         public function getPageStyle()
00163         {
00164                 return $this->page_style;
00165         }
00166         public function setSsl($a_ssl)
00167         {
00168                 $this->ssl = $a_ssl;
00169         }
00170         public function getSsl()
00171         {
00172                 return $this->ssl;
00173         }
00174         
00181         function getAll()
00182         {
00183                 $values = array(
00184                         "server_host" => $this->getServerHost(),
00185                         "server_path" => $this->getServerPath(),
00186                         "vendor" => $this->getVendor(),
00187                         "auth_token" => $this->getAuthToken(),
00188                         "page_style" => $this->getPageStyle(),
00189                         "ssl" => $this->getSsl()
00190                 );
00191                 
00192                 return $values;
00193         }
00194 
00200         function clearAll()
00201         {
00202                 $query = "UPDATE payment_settings "
00203                                 ."SET paypal = '' "
00204                                 ."WHERE settings_id = '" . $this->settings_id . "'";
00205                 $this->db->query($query);
00206 
00207                 $this->settings = array();
00208         }
00209                 
00215         public function save()
00216         {
00217                 global $ilDB;
00218                 
00219                 $values = array(
00220                         "server_host" => $this->getServerHost(),
00221                         "server_path" => $this->getServerPath(),
00222                         "vendor" => $this->getVendor(),
00223                         "auth_token" => $this->getAuthToken(),
00224                         "page_style" => $this->getPageStyle(),
00225                         "ssl" => $this->getSsl()                        
00226                 );              
00227                 
00228                 if ($this->getSettingsId())
00229                 {               
00230                         $query = "UPDATE payment_settings "
00231                                         ."SET paypal = " . $ilDB->quote(serialize($values)). " "
00232                                         ."WHERE settings_id = '" . $this->getSettingsId() . "'";
00233                         $this->db->query($query);
00234                 }
00235                 else
00236                 {
00237                         $query = "INSERT INTO payment_settings (paypal) VALUES (" . $ilDB->quote(serialize($values)). ") ";
00238                         
00239                         $this->db->query($query);               
00240                         
00241                         $this->setSettingsId($this->db->getLastInsertId());
00242                 }               
00243         }
00244 }
00245 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1