payment_rdfa.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class payment_rdfa extends oxAdminDetails
00009 {
00015     protected $_sThisTemplate = "payment_rdfa.tpl";
00016 
00023     protected $_aRDFaPayments = array("ByBankTransferInAdvance" => 0,
00024                                       "ByInvoice" => 0,
00025                                       "Cash" => 0,
00026                                       "CheckInAdvance" => 0,
00027                                       "COD" => 0,
00028                                       "DirectDebit" => 0,
00029                                       "GoogleCheckout" => 0,
00030                                       "PayPal" => 0,
00031                                       "PaySwarm" => 0,
00032                                       "AmericanExpress" => 1,
00033                                       "DinersClub" => 1,
00034                                       "Discover" => 1,
00035                                       "JCB" => 1,
00036                                       "MasterCard" => 1,
00037                                       "VISA" => 1);
00038 
00044     public function save()
00045     {
00046         $aParams = oxConfig::getParameter("editval");
00047         $aRDFaPayments = (array) oxConfig::getParameter("ardfapayments");
00048 
00049         // Delete old mappings
00050         $oDb = oxDb::getDb();
00051         $oDb->execute("DELETE FROM oxobject2payment WHERE oxpaymentid = '".oxConfig::getParameter("oxid")."' AND OXTYPE = 'rdfapayment'");
00052 
00053         // Save new mappings
00054         foreach ( $aRDFaPayments as $sPayment ) {
00055             $oMapping = oxNew("oxbase");
00056             $oMapping->init("oxobject2payment");
00057             $oMapping->assign($aParams);
00058             $oMapping->oxobject2payment__oxobjectid = new oxField($sPayment);
00059             $oMapping->save();
00060         }
00061     }
00062 
00068     public function getAllRDFaPayments()
00069     {
00070         $aRDFaPayments = array();
00071         $aAssignedRDFaPayments = $this->getAssignedRDFaPayments();
00072         foreach ($this->_aRDFaPayments as $sName => $iType) {
00073             $oPayment = new stdClass();
00074             $oPayment->name = $sName;
00075             $oPayment->type = $iType;
00076             $oPayment->checked = in_array($sName, $aAssignedRDFaPayments);
00077             $aRDFaPayments[] = $oPayment;
00078         }
00079         return $aRDFaPayments;
00080     }
00081 
00087     public function getAssignedRDFaPayments()
00088     {
00089         $oDb = oxDb::getDb();
00090         $aRDFaPayments = array();
00091         $sSelect = 'select oxobjectid from oxobject2payment where oxpaymentid='.$oDb->quote( oxConfig::getParameter("oxid") ).' and oxtype = "rdfapayment" ';
00092         $rs = $oDb->execute( $sSelect );
00093         if ( $rs && $rs->recordCount()) {
00094             while ( !$rs->EOF ) {
00095                 $aRDFaPayments[] = $rs->fields[0];
00096                 $rs->moveNext();
00097             }
00098         }
00099         return $aRDFaPayments;
00100     }
00101 
00102 }