Go to the documentation of this file.00001 <?php
00002
00008 class User_Address extends oxAdminDetails
00009 {
00010
00016 protected $_blDelete = false;
00017
00025 public function render()
00026 {
00027 parent::render();
00028
00029 $soxId = $this->getEditObjectId();
00030 if ($soxId != "-1" && isset($soxId)) {
00031
00032 $oUser = oxNew("oxuser");
00033 $oUser->load($soxId);
00034
00035
00036 $sAddressIdParameter = oxRegistry::getConfig()->getRequestParameter("oxaddressid");
00037 $soxAddressId = isset($this->sSavedOxid) ? $this->sSavedOxid : $sAddressIdParameter;
00038 if ($soxAddressId != "-1" && isset($soxAddressId)) {
00039 $oAdress = oxNew("oxaddress");
00040 $oAdress->load($soxAddressId);
00041 $this->_aViewData["edit"] = $oAdress;
00042 }
00043
00044 $this->_aViewData["oxaddressid"] = $soxAddressId;
00045
00046
00047 $oAddressList = $oUser->getUserAddresses();
00048 foreach ($oAddressList as $oAddress) {
00049 if ($oAddress->oxaddress__oxid->value == $soxAddressId) {
00050 $oAddress->selected = 1;
00051 break;
00052 }
00053 }
00054
00055 $this->_aViewData["edituser"] = $oUser;
00056 }
00057
00058 $oCountryList = oxNew("oxCountryList");
00059 $oCountryList->loadActiveCountries(oxRegistry::getLang()->getObjectTplLanguage());
00060
00061 $this->_aViewData["countrylist"] = $oCountryList;
00062
00063 if (!$this->_allowAdminEdit($soxId)) {
00064 $this->_aViewData['readonly'] = true;
00065 }
00066
00067 return "user_address.tpl";
00068 }
00069
00073 public function save()
00074 {
00075 parent::save();
00076
00077 if ($this->_allowAdminEdit($this->getEditObjectId())) {
00078 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00079 $oAdress = oxNew("oxaddress");
00080 if (isset($aParams['oxaddress__oxid']) && $aParams['oxaddress__oxid'] == "-1") {
00081 $aParams['oxaddress__oxid'] = null;
00082 } else {
00083 $oAdress->load($aParams['oxaddress__oxid']);
00084 }
00085
00086 $oAdress->assign($aParams);
00087 $oAdress->save();
00088
00089 $this->sSavedOxid = $oAdress->getId();
00090 }
00091 }
00092
00096 public function delAddress()
00097 {
00098 $this->_blDelete = false;
00099 if ($this->_allowAdminEdit($this->getEditObjectId())) {
00100 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00101 if (isset($aParams['oxaddress__oxid']) && $aParams['oxaddress__oxid'] != "-1") {
00102 $oAdress = oxNew("oxaddress");
00103 $this->_blDelete = $oAdress->delete($aParams['oxaddress__oxid']);
00104 }
00105 }
00106 }
00107 }