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

Generated by  doxygen 1.6.2