OXID eShop CE  4.10.3
 All Classes Namespaces Files Functions Variables Pages
payment_rdfa.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
16  protected $_sThisTemplate = "payment_rdfa.tpl";
17 
24  protected $_aRDFaPayments = array("ByBankTransferInAdvance" => 0,
25  "ByInvoice" => 0,
26  "Cash" => 0,
27  "CheckInAdvance" => 0,
28  "COD" => 0,
29  "DirectDebit" => 0,
30  "GoogleCheckout" => 0,
31  "PayPal" => 0,
32  "PaySwarm" => 0,
33  "AmericanExpress" => 1,
34  "DinersClub" => 1,
35  "Discover" => 1,
36  "JCB" => 1,
37  "MasterCard" => 1,
38  "VISA" => 1);
39 
43  public function save()
44  {
45  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
46  $aRDFaPayments = (array) oxRegistry::getConfig()->getRequestParameter("ardfapayments");
47 
48  // Delete old mappings
49  $oDb = oxDb::getDb();
50  $oDb->execute("DELETE FROM oxobject2payment WHERE oxpaymentid = '" . oxRegistry::getConfig()->getRequestParameter("oxid") . "' AND OXTYPE = 'rdfapayment'");
51 
52  // Save new mappings
53  foreach ($aRDFaPayments as $sPayment) {
54  $oMapping = oxNew("oxbase");
55  $oMapping->init("oxobject2payment");
56  $oMapping->assign($aParams);
57  $oMapping->oxobject2payment__oxobjectid = new oxField($sPayment);
58  $oMapping->save();
59  }
60  }
61 
67  public function getAllRDFaPayments()
68  {
69  $aRDFaPayments = array();
70  $aAssignedRDFaPayments = $this->getAssignedRDFaPayments();
71  foreach ($this->_aRDFaPayments as $sName => $iType) {
72  $oPayment = new stdClass();
73  $oPayment->name = $sName;
74  $oPayment->type = $iType;
75  $oPayment->checked = in_array($sName, $aAssignedRDFaPayments);
76  $aRDFaPayments[] = $oPayment;
77  }
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(oxRegistry::getConfig()->getRequestParameter("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 
100  return $aRDFaPayments;
101  }
102 }