OXID eShop CE  4.10.5
 All Classes Namespaces Files Functions Variables Pages
user_extend.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
17  public function render()
18  {
20 
21  $soxId = $this->getEditObjectId();
22  if ($soxId != "-1" && isset($soxId)) {
23  // load object
24  $oUser = oxNew("oxuser");
25  $oUser->load($soxId);
26 
27  //show country in active language
28  $oCountry = oxNew("oxCountry");
29  $oCountry->loadInLang(oxRegistry::getLang()->getObjectTplLanguage(), $oUser->oxuser__oxcountryid->value);
30  $oUser->oxuser__oxcountry = new oxField($oCountry->oxcountry__oxtitle->value);
31 
32  $this->_aViewData["edit"] = $oUser;
33  }
34 
35  if (!$this->_allowAdminEdit($soxId)) {
36  $this->_aViewData['readonly'] = true;
37  }
38 
39  return "user_extend.tpl";
40  }
41 
47  public function save()
48  {
49  parent::save();
50 
51  $soxId = $this->getEditObjectId();
52 
53  if (!$this->_allowAdminEdit($soxId)) {
54  return false;
55  }
56 
57  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
58 
59  $oUser = oxNew("oxuser");
60  if ($soxId != "-1") {
61  $oUser->load($soxId);
62  } else {
63  $aParams['oxuser__oxid'] = null;
64  }
65 
66  // checkbox handling
67  $aParams['oxuser__oxactive'] = $oUser->oxuser__oxactive->value;
68 
69  $blNewsParams = oxRegistry::getConfig()->getRequestParameter("editnews");
70  if (isset($blNewsParams)) {
71  $oNewsSubscription = $oUser->getNewsSubscription();
72  $oNewsSubscription->setOptInStatus((int) $blNewsParams);
73  $oNewsSubscription->setOptInEmailStatus((int) oxRegistry::getConfig()->getRequestParameter("emailfailed"));
74  }
75 
76  $oUser->assign($aParams);
77  $oUser->save();
78 
79  // set oxid if inserted
80  $this->setEditObjectId($oUser->getId());
81  }
82 }