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         parent::save();
00049 
00050         $soxId = $this->getEditObjectId();
00051 
00052         if ( !$this->_allowAdminEdit( $soxId ) )
00053             return false;
00054 
00055         $aParams       = oxConfig::getParameter( "editval" );
00056 
00057         $oUser = oxNew( "oxuser" );
00058         if ( $soxId != "-1" ) {
00059             $oUser->load( $soxId );
00060         } else {
00061             $aParams['oxuser__oxid'] = null;
00062         }
00063 
00064         // checkbox handling
00065         $aParams['oxuser__oxactive'] = $oUser->oxuser__oxactive->value;
00066 
00067         $blNewsParams  = oxConfig::getParameter( "editnews" );
00068         if ( isset( $blNewsParams ) ) {
00069             $oNewsSubscription = $oUser->getNewsSubscription();
00070             $oNewsSubscription->setOptInStatus( (int) $blNewsParams );
00071             $oNewsSubscription->setOptInEmailStatus( (int) oxConfig::getParameter( "emailfailed" ) );
00072         }
00073 
00074         $oUser->assign( $aParams );
00075         $oUser->save();
00076 
00077         // set oxid if inserted
00078         $this->setEditObjectId( $oUser->getId() );
00079     }
00080 }