user_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class User_Main extends oxAdminDetails
00010 {
00011     private $_sSaveError = null;
00012 
00020     public function render()
00021     {
00022         $myConfig = $this->getConfig();
00023         $soxId = oxConfig::getParameter( "oxid");
00024 
00025         parent::render();
00026 
00027         // malladmin stuff
00028         $oAuthUser = oxUser::getAdminUser();
00029         $blisMallAdmin = $oAuthUser->oxuser__oxrights->value == "malladmin";
00030 
00031             // all usergroups
00032             $oGroups = oxNew( "oxlist" );
00033             $oGroups->init( "oxgroups" );
00034             $oGroups->selectString( "select * from oxgroups order by oxgroups.oxtitle" );
00035 
00036         // User rights
00037         $aUserRights = array();
00038 
00039         $iPos = count( $aUserRights );
00040         $aUserRights[$iPos] = new OxstdClass();
00041         $aUserRights[$iPos]->name = oxLang::getInstance()->translateString( "user", oxLang::getInstance()->getTplLanguage() );
00042         $aUserRights[$iPos]->id   = "user";
00043 
00044         if ( $blisMallAdmin ) {
00045             $iPos = count( $aUserRights );
00046             $aUserRights[$iPos] = new OxstdClass();
00047             $aUserRights[$iPos]->id   = "malladmin";
00048             $aUserRights[$iPos]->name = oxLang::getInstance()->translateString( "Admin", oxLang::getInstance()->getTplLanguage() );
00049         }
00050 
00051 
00052         $soxId = oxConfig::getParameter( "oxid");
00053         // check if we right now saved a new entry
00054         $sSavedID = oxConfig::getParameter( "saved_oxid");
00055         if ( ( $soxId == "-1" || !isset( $soxId ) ) && isset( $sSavedID ) ) {
00056             $soxId = $sSavedID;
00057             oxSession::deleteVar( "saved_oxid");
00058             $this->_aViewData["oxid"] =  $soxId;
00059             // for reloading upper frame
00060             $this->_aViewData["updatelist"] =  "1";
00061         }
00062 
00063         if ( $soxId != "-1" && isset( $soxId ) ) {
00064             // load object
00065             $oUser = oxNew( "oxuser" );
00066             $oUser->load( $soxId);
00067             $this->_aViewData["edit"] =  $oUser;
00068 
00069             if ( !( $oUser->oxuser__oxrights->value == "malladmin" && !$blisMallAdmin ) ) {
00070                 // generate selected right
00071                 reset( $aUserRights );
00072                 while ( list(, $val ) = each( $aUserRights ) ) {
00073                     if ( $val->id == $oUser->oxuser__oxrights->value) {
00074                         $val->selected = 1;
00075                         break;
00076                     }
00077                 }
00078             }
00079         }
00080 
00081         // passing country list
00082         $oCountryList = oxNew( "oxCountryList" );
00083         $oCountryList->loadActiveCountries( oxLang::getInstance()->getTplLanguage() );
00084 
00085         $this->_aViewData["countrylist"] = $oCountryList;
00086 
00087             $this->_aViewData["allgroups"] =  $oGroups;
00088 
00089         $this->_aViewData["rights"] =  $aUserRights;
00090 
00091         if ($this->_sSaveError) {
00092             $this->_aViewData["sSaveError"] = $this->_sSaveError;
00093         }
00094 
00095         if (!$this->_allowAdminEdit($soxId))
00096             $this->_aViewData['readonly'] = true;
00097         if ( oxConfig::getParameter("aoc") ) {
00098 
00099             $aColumns = array();
00100             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00101             $this->_aViewData['oxajax'] = $aColumns;
00102 
00103             return "popups/user_main.tpl";
00104         }
00105         return "user_main.tpl";
00106     }
00107 
00113     public function save()
00114     {
00115         $myConfig = $this->getConfig();
00116 
00117 
00118         $soxId      = oxConfig::getParameter( "oxid");
00119         $aParams    = oxConfig::getParameter( "editval");
00120 
00121         //allow admin information edit only for MALL admins
00122         if (!$this->_allowAdminEdit($soxId))
00123             return;
00124 
00125         // checkbox handling
00126         if ( !isset( $aParams['oxuser__oxactive']))
00127             $aParams['oxuser__oxactive'] = 0;
00128 
00129         // #1899 (R)
00130         if ( isset($aParams['oxuser__oxcompany']))
00131             oxConfig::checkSpecialChars($aParams['oxuser__oxcompany']);
00132 
00133         $oUser = oxNew( "oxuser" );
00134         if ( $soxId != "-1")
00135             $oUser->load( $soxId);
00136         else
00137             $aParams['oxuser__oxid'] = null;
00138 
00139         //setting new password
00140         if ( ( $sNewPass = oxConfig::getParameter( "newPassword" ) ) ) {
00141             $oUser->setPassword( $sNewPass );
00142         }
00143 
00144         //FS#2167 V checks for already used email
00145         if ( $oUser->checkIfEmailExists($aParams['oxuser__oxusername'])) {
00146             $this->_sSaveError = 'EXCEPTION_USER_USEREXISTS';
00147             return;
00148         }
00149 
00150         //#1006T
00151         //special treatment for newsletter fields
00152         /* $aParams["oxuser__oxdboptin"] = $oUser->oxuser__oxdboptin->value;
00153         $aParams["oxuser__oxemailfailed"] = $oUser->oxuser__oxemailfailed->value;*/
00154 
00155         //$aParams = $oUser->ConvertNameArray2Idx( $aParams);
00156         $oUser->assign( $aParams);
00157 
00158         $sRights = $oUser->oxuser__oxrights->value;
00159 
00160 
00161         // A. changing field type to save birth date correctly
00162         $oUser->oxuser__oxbirthdate->fldtype = 'char';
00163 
00164         try {
00165             $oUser->save();
00166             $this->_aViewData["updatelist"] = "1";
00167 
00168             // set oxid if inserted
00169             if ( $soxId == "-1")
00170                 oxSession::setVar( "saved_oxid", $oUser->oxuser__oxid->value);
00171 
00172             return $this->autosave();
00173         } catch (Exception $e) {
00174             $this->_sSaveError = $e->getMessage();
00175         }
00176     }
00177 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5