user_extend.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class User_Extend extends oxAdminDetails
00009 {
00016     public function render()
00017     {
00018         parent::render();
00019 
00020         $soxId = $this->getEditObjectId();
00021         if ( $soxId != "-1" && isset( $soxId ) ) {
00022             // load object
00023             $oUser = oxNew( "oxuser" );
00024             $oUser->load( $soxId );
00025 
00026             //show country in active language
00027             $oCountry = oxNew( "oxCountry" );
00028             $oCountry->loadInLang( oxLang::getInstance()->getObjectTplLanguage(), $oUser->oxuser__oxcountryid->value );
00029             $oUser->oxuser__oxcountry = new oxField( $oCountry->oxcountry__oxtitle->value);
00030 
00031             $this->_aViewData["edit"] =  $oUser;
00032         }
00033 
00034         if ( !$this->_allowAdminEdit( $soxId ) ) {
00035             $this->_aViewData['readonly'] = true;
00036         }
00037 
00038         return "user_extend.tpl";
00039     }
00040 
00046     public function save()
00047     {
00048 
00049         $soxId = $this->getEditObjectId();
00050 
00051         if ( !$this->_allowAdminEdit( $soxId ) )
00052             return false;
00053 
00054         $aParams       = oxConfig::getParameter( "editval" );
00055 
00056         $oUser = oxNew( "oxuser" );
00057         if ( $soxId != "-1" ) {
00058             $oUser->load( $soxId );
00059         } else {
00060             $aParams['oxuser__oxid'] = null;
00061         }
00062 
00063         // checkbox handling
00064         $aParams['oxuser__oxactive'] = $oUser->oxuser__oxactive->value;
00065 
00066         $blNewsParams  = oxConfig::getParameter( "editnews" );
00067         if ( isset( $blNewsParams ) ) {
00068             $oNewsSubscription = $oUser->getNewsSubscription();
00069             $oNewsSubscription->setOptInStatus( (int) $blNewsParams );
00070             $oNewsSubscription->setOptInEmailStatus( (int) oxConfig::getParameter( "emailfailed" ) );
00071         }
00072 
00073         $oUser->assign( $aParams );
00074         $oUser->save();
00075 
00076         // set oxid if inserted
00077         $this->setEditObjectId( $oUser->getId() );
00078     }
00079 }