00001 <?php 00002 00006 class oxRequiredAddressFields 00007 { 00008 00014 private $_aDefaultRequiredFields = array( 00015 'oxuser__oxfname', 00016 'oxuser__oxlname', 00017 'oxuser__oxstreetnr', 00018 'oxuser__oxstreet', 00019 'oxuser__oxzip', 00020 'oxuser__oxcity' 00021 ); 00022 00028 private $_aRequiredFields = array(); 00029 00034 public function __construct() 00035 { 00036 $this->setRequiredFields($this->_aDefaultRequiredFields); 00037 00038 $aRequiredFields = oxRegistry::getConfig()->getConfigParam('aMustFillFields'); 00039 if (is_array($aRequiredFields)) { 00040 $this->setRequiredFields($aRequiredFields); 00041 } 00042 } 00043 00049 public function setRequiredFields($aRequiredFields) 00050 { 00051 $this->_aRequiredFields = $aRequiredFields; 00052 } 00053 00059 public function getRequiredFields() 00060 { 00061 return $this->_aRequiredFields; 00062 } 00063 00069 public function getBillingFields() 00070 { 00071 $aRequiredFields = $this->getRequiredFields(); 00072 00073 return $this->_filterFields($aRequiredFields, 'oxuser__'); 00074 } 00075 00081 public function getDeliveryFields() 00082 { 00083 $aRequiredFields = $this->getRequiredFields(); 00084 00085 return $this->_filterFields($aRequiredFields, 'oxaddress__'); 00086 } 00087 00096 private function _filterFields($aFields, $sPrefix) 00097 { 00098 $aAllowed = array(); 00099 foreach ($aFields as $sKey => $sValue) { 00100 if (strpos($sValue, $sPrefix) === 0) { 00101 $aAllowed[] = $aFields[$sKey]; 00102 } 00103 } 00104 00105 return $aAllowed; 00106 } 00107 }