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