user_main.php

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

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5