Go to the documentation of this file.00001 <?php
00002
00008 class User_Main extends oxAdminDetails
00009 {
00010 private $_sSaveError = null;
00011
00019 public function render()
00020 {
00021 $myConfig = $this->getConfig();
00022 $soxId = $this->getEditObjectId();
00023
00024 parent::render();
00025
00026
00027 $oAuthUser = oxNew( 'oxuser' );
00028 $oAuthUser->loadAdminUser();
00029 $blisMallAdmin = $oAuthUser->oxuser__oxrights->value == "malladmin";
00030
00031
00032 $sViewName = getViewName( "oxgroups", $this->_iEditLang );
00033 $oGroups = oxNew( "oxlist" );
00034 $oGroups->init( "oxgroups" );
00035 $oGroups->selectString( "select * from {$sViewName} order by {$sViewName}.oxtitle" );
00036
00037
00038 $aUserRights = array();
00039 $oLang = oxLang::getInstance();
00040 $iTplLang = $oLang->getTplLanguage();
00041
00042 $iPos = count( $aUserRights );
00043 $aUserRights[$iPos] = new OxstdClass();
00044 $aUserRights[$iPos]->name = $oLang->translateString( "user", $iTplLang );
00045 $aUserRights[$iPos]->id = "user";
00046
00047 if ( $blisMallAdmin ) {
00048 $iPos = count( $aUserRights );
00049 $aUserRights[$iPos] = new OxstdClass();
00050 $aUserRights[$iPos]->id = "malladmin";
00051 $aUserRights[$iPos]->name = $oLang->translateString( "Admin", $iTplLang );
00052 }
00053
00054
00055 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00056 if ( $soxId != "-1" && isset( $soxId ) ) {
00057
00058 $oUser = oxNew( "oxuser" );
00059 $oUser->load( $soxId);
00060 $this->_aViewData["edit"] = $oUser;
00061
00062 if ( !( $oUser->oxuser__oxrights->value == "malladmin" && !$blisMallAdmin ) ) {
00063
00064 reset( $aUserRights );
00065 while ( list(, $val ) = each( $aUserRights ) ) {
00066 if ( $val->id == $oUser->oxuser__oxrights->value) {
00067 $val->selected = 1;
00068 break;
00069 }
00070 }
00071 }
00072 }
00073
00074
00075 $oCountryList = oxNew( "oxCountryList" );
00076 $oCountryList->loadActiveCountries( $oLang->getObjectTplLanguage() );
00077
00078 $this->_aViewData["countrylist"] = $oCountryList;
00079
00080 $this->_aViewData["allgroups"] = $oGroups;
00081
00082 $this->_aViewData["rights"] = $aUserRights;
00083
00084 if ($this->_sSaveError) {
00085 $this->_aViewData["sSaveError"] = $this->_sSaveError;
00086 }
00087
00088 if (!$this->_allowAdminEdit($soxId))
00089 $this->_aViewData['readonly'] = true;
00090 if ( oxConfig::getParameter("aoc") ) {
00091
00092 $aColumns = array();
00093 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00094 $this->_aViewData['oxajax'] = $aColumns;
00095
00096 return "popups/user_main.tpl";
00097 }
00098 return "user_main.tpl";
00099 }
00100
00106 public function save()
00107 {
00108 parent::save();
00109
00110
00111 $soxId = $this->getEditObjectId();
00112 if ( $this->_allowAdminEdit( $soxId ) ) {
00113
00114 $aParams = oxConfig::getParameter( "editval");
00115
00116
00117 if ( !isset( $aParams['oxuser__oxactive'] ) ) {
00118 $aParams['oxuser__oxactive'] = 0;
00119 }
00120
00121 $oUser = oxNew( "oxuser" );
00122 if ( $soxId != "-1" ) {
00123 $oUser->load( $soxId );
00124 } else {
00125 $aParams['oxuser__oxid'] = null;
00126 }
00127
00128
00129 if ( ( $sNewPass = oxConfig::getParameter( "newPassword" ) ) ) {
00130 $oUser->setPassword( $sNewPass );
00131 }
00132
00133
00134 if ( $oUser->checkIfEmailExists( $aParams['oxuser__oxusername'] ) ) {
00135 $this->_sSaveError = 'EXCEPTION_USER_USEREXISTS';
00136 return;
00137 }
00138
00139 $oUser->assign( $aParams );
00140
00141
00142
00143 $oUser->oxuser__oxbirthdate->fldtype = 'char';
00144
00145 try {
00146 $oUser->save();
00147
00148
00149 $this->setEditObjectId( $oUser->getId() );
00150 } catch ( Exception $oExcp ) {
00151 $this->_sSaveError = $oExcp->getMessage();
00152 }
00153 }
00154 }
00155 }