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