deliveryset_rdfa.php

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