OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
payment_rdfa.php
Go to the documentation of this file.
1 <?php
2 
9 {
15  protected $_sThisTemplate = "payment_rdfa.tpl";
16 
23  protected $_aRDFaPayments = array("ByBankTransferInAdvance" => 0,
24  "ByInvoice" => 0,
25  "Cash" => 0,
26  "CheckInAdvance" => 0,
27  "COD" => 0,
28  "DirectDebit" => 0,
29  "GoogleCheckout" => 0,
30  "PayPal" => 0,
31  "PaySwarm" => 0,
32  "AmericanExpress" => 1,
33  "DinersClub" => 1,
34  "Discover" => 1,
35  "JCB" => 1,
36  "MasterCard" => 1,
37  "VISA" => 1);
38 
44  public function save()
45  {
46  $aParams = oxConfig::getParameter("editval");
47  $aRDFaPayments = (array) oxConfig::getParameter("ardfapayments");
48 
49  // Delete old mappings
50  $oDb = oxDb::getDb();
51  $oDb->execute("DELETE FROM oxobject2payment WHERE oxpaymentid = '".oxConfig::getParameter("oxid")."' AND OXTYPE = 'rdfapayment'");
52 
53  // Save new mappings
54  foreach ( $aRDFaPayments as $sPayment ) {
55  $oMapping = oxNew("oxbase");
56  $oMapping->init("oxobject2payment");
57  $oMapping->assign($aParams);
58  $oMapping->oxobject2payment__oxobjectid = new oxField($sPayment);
59  $oMapping->save();
60  }
61  }
62 
68  public function getAllRDFaPayments()
69  {
70  $aRDFaPayments = array();
71  $aAssignedRDFaPayments = $this->getAssignedRDFaPayments();
72  foreach ($this->_aRDFaPayments as $sName => $iType) {
73  $oPayment = new stdClass();
74  $oPayment->name = $sName;
75  $oPayment->type = $iType;
76  $oPayment->checked = in_array($sName, $aAssignedRDFaPayments);
77  $aRDFaPayments[] = $oPayment;
78  }
79  return $aRDFaPayments;
80  }
81 
87  public function getAssignedRDFaPayments()
88  {
89  $oDb = oxDb::getDb();
90  $aRDFaPayments = array();
91  $sSelect = 'select oxobjectid from oxobject2payment where oxpaymentid='.$oDb->quote( oxConfig::getParameter("oxid") ).' and oxtype = "rdfapayment" ';
92  $rs = $oDb->execute( $sSelect );
93  if ( $rs && $rs->recordCount()) {
94  while ( !$rs->EOF ) {
95  $aRDFaPayments[] = $rs->fields[0];
96  $rs->moveNext();
97  }
98  }
99  return $aRDFaPayments;
100  }
101 
102 }