user_address.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class User_Address extends oxAdminDetails
00009 {
00013     protected $_blDelete = false;
00014 
00022     public function render()
00023     {
00024         parent::render();
00025 
00026         $soxId = oxConfig::getParameter( "oxid");
00027         if ( $soxId != "-1" && isset( $soxId)) {
00028             // load object
00029             $oUser = oxNew( "oxuser" );
00030             $oUser->load( $soxId);
00031 
00032             // load adress
00033             $soxAddressId = isset($this->sSavedOxid)?$this->sSavedOxid:oxConfig::getParameter( "oxaddressid");
00034             if ( $soxAddressId != "-1" && isset( $soxAddressId ) ) {
00035                 $oAdress = oxNew( "oxbase" );
00036                 $oAdress->init( "oxaddress" );
00037                 $oAdress->load( $soxAddressId );
00038                 $this->_aViewData["edit"] = $oAdress;
00039             }
00040 
00041             $this->_aViewData["oxaddressid"] = $soxAddressId;
00042 
00043             // generate selected
00044             $oAddressList = $oUser->getUserAddresses();
00045             foreach ( $oAddressList as $oAddress ) {
00046                 if ( $oAddress->oxaddress__oxid->value == $soxAddressId ) {
00047                     $oAddress->selected = 1;
00048                     break;
00049                 }
00050             }
00051 
00052             $this->_aViewData["edituser"] = $oUser;
00053         }
00054 
00055         $oCountryList = oxNew( "oxCountryList" );
00056         $oCountryList->loadActiveCountries( oxLang::getInstance()->getTplLanguage() );
00057 
00058         $this->_aViewData["countrylist"] = $oCountryList;
00059 
00060         if (!$this->_allowAdminEdit($soxId))
00061             $this->_aViewData['readonly'] = true;
00062 
00063         return "user_address.tpl";
00064     }
00065 
00071     public function save()
00072     {
00073 
00074         if ( !$this->_allowAdminEdit( oxConfig::getParameter( "oxid" ) ) )
00075             return false;
00076 
00077         $aParams = oxConfig::getParameter( "editval");
00078 
00079         $oAdress = oxNew( "oxbase" );
00080         $oAdress->init( "oxaddress" );
00081 
00082         if ( $aParams['oxaddress__oxid'] == "-1")
00083             $aParams['oxaddress__oxid'] = null;
00084         // #1899 (R)
00085         if ( isset($aParams['oxaddress__oxcompany']))
00086             oxConfig::checkSpecialChars($aParams['oxaddress__oxcompany']);
00087         //$aParams = $oAdress->ConvertNameArray2Idx( $aParams);
00088         $oAdress->assign( $aParams);
00089         $oAdress->save();
00090 
00091         $this->sSavedOxid = $oAdress->getId();
00092     }
00093 
00099     public function delAddress()
00100     {
00101         $aParams = oxConfig::getParameter( "editval" );
00102         if ( !$this->_allowAdminEdit( oxConfig::getParameter( "oxid" ) ) )
00103             return false;
00104 
00105         $oAdress = oxNew( "oxbase" );
00106         $oAdress->init( "oxaddress" );
00107 
00108         if ( $aParams['oxaddress__oxid'] != "-1") {
00109             $oAdress->load( $aParams['oxaddress__oxid']);
00110             $oAdress->delete();
00111             $this->_blDelete = true;
00112         }
00113     }
00114 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5