OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
user_address.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
16  protected $_blDelete = false;
17 
25  public function render()
26  {
28 
29  $soxId = $this->getEditObjectId();
30  if ($soxId != "-1" && isset($soxId)) {
31  // load object
32  $oUser = oxNew("oxuser");
33  $oUser->load($soxId);
34 
35  // load adress
36  $sAddressIdParameter = oxRegistry::getConfig()->getRequestParameter("oxaddressid");
37  $soxAddressId = isset($this->sSavedOxid) ? $this->sSavedOxid : $sAddressIdParameter;
38  if ($soxAddressId != "-1" && isset($soxAddressId)) {
39  $oAdress = oxNew("oxaddress");
40  $oAdress->load($soxAddressId);
41  $this->_aViewData["edit"] = $oAdress;
42  }
43 
44  $this->_aViewData["oxaddressid"] = $soxAddressId;
45 
46  // generate selected
47  $oAddressList = $oUser->getUserAddresses();
48  foreach ($oAddressList as $oAddress) {
49  if ($oAddress->oxaddress__oxid->value == $soxAddressId) {
50  $oAddress->selected = 1;
51  break;
52  }
53  }
54 
55  $this->_aViewData["edituser"] = $oUser;
56  }
57 
58  $oCountryList = oxNew("oxCountryList");
59  $oCountryList->loadActiveCountries(oxRegistry::getLang()->getObjectTplLanguage());
60 
61  $this->_aViewData["countrylist"] = $oCountryList;
62 
63  if (!$this->_allowAdminEdit($soxId)) {
64  $this->_aViewData['readonly'] = true;
65  }
66 
67  return "user_address.tpl";
68  }
69 
73  public function save()
74  {
75  parent::save();
76 
77  if ($this->_allowAdminEdit($this->getEditObjectId())) {
78  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
79  $oAdress = oxNew("oxaddress");
80  if (isset($aParams['oxaddress__oxid']) && $aParams['oxaddress__oxid'] == "-1") {
81  $aParams['oxaddress__oxid'] = null;
82  } else {
83  $oAdress->load($aParams['oxaddress__oxid']);
84  }
85 
86  $oAdress->assign($aParams);
87  $oAdress->save();
88 
89  $this->sSavedOxid = $oAdress->getId();
90  }
91  }
92 
96  public function delAddress()
97  {
98  $this->_blDelete = false;
99  if ($this->_allowAdminEdit($this->getEditObjectId())) {
100  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
101  if (isset($aParams['oxaddress__oxid']) && $aParams['oxaddress__oxid'] != "-1") {
102  $oAdress = oxNew("oxaddress");
103  $this->_blDelete = $oAdress->delete($aParams['oxaddress__oxid']);
104  }
105  }
106  }
107 }