deliveryset_rdfa.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class deliveryset_rdfa extends payment_rdfa
00009 {
00015     protected $_sThisTemplate = "deliveryset_rdfa.tpl";
00016 
00022     protected $_aRDFaDeliveries = array(
00023                                         "DeliveryModeDirectDownload" => 0,
00024                                         "DeliveryModeFreight" => 0,
00025                                         "DeliveryModeMail" => 0,
00026                                         "DeliveryModeOwnFleet" => 0,
00027                                         "DeliveryModePickUp" => 0,
00028                                         "DHL" => 1,
00029                                         "FederalExpress" => 1,
00030                                         "UPS" => 1
00031                                             );
00032 
00038     public function save()
00039     {
00040         $aParams = oxConfig::getParameter("editval");
00041         $aRDFaDeliveries = (array) oxConfig::getParameter("ardfadeliveries");
00042 
00043         // Delete old mappings
00044         $oDb = oxDb::getDb();
00045         $oDb->execute("DELETE FROM oxobject2delivery WHERE oxdeliveryid = '".oxConfig::getParameter("oxid")."' AND OXTYPE = 'rdfadeliveryset'");
00046 
00047         // Save new mappings
00048         foreach ( $aRDFaDeliveries as $sDelivery ) {
00049             $oMapping = oxNew("oxbase");
00050             $oMapping->init("oxobject2delivery");
00051             $oMapping->assign($aParams);
00052             $oMapping->oxobject2delivery__oxobjectid = new oxField($sDelivery);
00053             $oMapping->save();
00054         }
00055     }
00056 
00062     public function getAllRDFaDeliveries()
00063     {
00064         $aRDFaDeliveries = array();
00065         $aAssignedRDFaDeliveries = $this->getAssignedRDFaDeliveries();
00066         foreach ($this->_aRDFaDeliveries as $sName => $iType) {
00067             $oDelivery = new stdClass();
00068             $oDelivery->name = $sName;
00069             $oDelivery->type = $iType;
00070             $oDelivery->checked = in_array($sName, $aAssignedRDFaDeliveries);
00071             $aRDFaDeliveries[] = $oDelivery;
00072         }
00073         return $aRDFaDeliveries;
00074     }
00075 
00081     public function getAssignedRDFaDeliveries()
00082     {
00083         $oDb = oxDb::getDb();
00084         $aRDFaDeliveries = array();
00085         $sSelect = 'select oxobjectid from oxobject2delivery where oxdeliveryid='.$oDb->quote( oxConfig::getParameter("oxid") ).' and oxtype = "rdfadeliveryset" ';
00086         $rs = $oDb->execute( $sSelect );
00087         if ( $rs && $rs->recordCount()) {
00088             while ( !$rs->EOF ) {
00089                 $aRDFaDeliveries[] = $rs->fields[0];
00090                 $rs->moveNext();
00091             }
00092         }
00093         return $aRDFaDeliveries;
00094     }
00095 
00096 }