OXID eShop CE  4.10.5
 All Classes Namespaces Files Functions Variables Pages
deliveryset_rdfa.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
16  protected $_sThisTemplate = "deliveryset_rdfa.tpl";
17 
23  protected $_aRDFaDeliveries = array(
24  "DeliveryModeDirectDownload" => 0,
25  "DeliveryModeFreight" => 0,
26  "DeliveryModeMail" => 0,
27  "DeliveryModeOwnFleet" => 0,
28  "DeliveryModePickUp" => 0,
29  "DHL" => 1,
30  "FederalExpress" => 1,
31  "UPS" => 1
32  );
33 
37  public function save()
38  {
39  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
40  $aRDFaDeliveries = (array) oxRegistry::getConfig()->getRequestParameter("ardfadeliveries");
41 
42  // Delete old mappings
43  $oDb = oxDb::getDb();
44  $sOxIdParameter = oxRegistry::getConfig()->getRequestParameter("oxid");
45  $sSql = "DELETE FROM oxobject2delivery WHERE oxdeliveryid = '{$sOxIdParameter}' AND OXTYPE = 'rdfadeliveryset'";
46  $oDb->execute($sSql);
47 
48  // Save new mappings
49  foreach ($aRDFaDeliveries as $sDelivery) {
50  $oMapping = oxNew("oxbase");
51  $oMapping->init("oxobject2delivery");
52  $oMapping->assign($aParams);
53  $oMapping->oxobject2delivery__oxobjectid = new oxField($sDelivery);
54  $oMapping->save();
55  }
56  }
57 
63  public function getAllRDFaDeliveries()
64  {
65  $aRDFaDeliveries = array();
66  $aAssignedRDFaDeliveries = $this->getAssignedRDFaDeliveries();
67  foreach ($this->_aRDFaDeliveries as $sName => $iType) {
68  $oDelivery = new stdClass();
69  $oDelivery->name = $sName;
70  $oDelivery->type = $iType;
71  $oDelivery->checked = in_array($sName, $aAssignedRDFaDeliveries);
72  $aRDFaDeliveries[] = $oDelivery;
73  }
74 
75  return $aRDFaDeliveries;
76  }
77 
83  public function getAssignedRDFaDeliveries()
84  {
85  $oDb = oxDb::getDb();
86  $aRDFaDeliveries = array();
87  $sSelect = 'select oxobjectid from oxobject2delivery where oxdeliveryid=' . $oDb->quote(oxRegistry::getConfig()->getRequestParameter("oxid")) . ' and oxtype = "rdfadeliveryset" ';
88  $rs = $oDb->execute($sSelect);
89  if ($rs && $rs->recordCount()) {
90  while (!$rs->EOF) {
91  $aRDFaDeliveries[] = $rs->fields[0];
92  $rs->moveNext();
93  }
94  }
95 
96  return $aRDFaDeliveries;
97  }
98 }