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