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
00109
00110 $soxId = $this->getEditObjectId();
00111 if ( $this->_allowAdminEdit( $soxId ) ) {
00112
00113 $aParams = oxConfig::getParameter( "editval");
00114
00115
00116 if ( !isset( $aParams['oxuser__oxactive'] ) ) {
00117 $aParams['oxuser__oxactive'] = 0;
00118 }
00119
00120 $oUser = oxNew( "oxuser" );
00121 if ( $soxId != "-1" ) {
00122 $oUser->load( $soxId );
00123 } else {
00124 $aParams['oxuser__oxid'] = null;
00125 }
00126
00127
00128 if ( ( $sNewPass = oxConfig::getParameter( "newPassword" ) ) ) {
00129 $oUser->setPassword( $sNewPass );
00130 }
00131
00132
00133 if ( $oUser->checkIfEmailExists( $aParams['oxuser__oxusername'] ) ) {
00134 $this->_sSaveError = 'EXCEPTION_USER_USEREXISTS';
00135 return;
00136 }
00137
00138 $oUser->assign( $aParams );
00139
00140
00141
00142 $oUser->oxuser__oxbirthdate->fldtype = 'char';
00143
00144 try {
00145 $oUser->save();
00146
00147
00148 $this->setEditObjectId( $oUser->getId() );
00149 } catch ( Exception $oExcp ) {
00150 $this->_sSaveError = $oExcp->getMessage();
00151 }
00152 }
00153 }
00154 }