oxsupercfg.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxSuperCfg
00007 {
00013     protected static $_oConfig = null;
00014 
00020     protected static $_oSession = null;
00021 
00027     protected static $_oRights = null;
00028 
00034     protected static $_oActUser = null;
00035 
00041     protected static $_blIsAdmin = null;
00042 
00054     public function __call( $sMethod, $aArgs )
00055     {
00056         if ( defined( 'OXID_PHP_UNIT' ) ) {
00057             if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00058                 $sMethod = str_replace( "UNIT", "_", $sMethod );
00059             }
00060             if ( method_exists( $this, $sMethod)) {
00061                 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00062             }
00063         }
00064 
00065         throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00066     }
00067 
00073     public function __construct()
00074     {
00075     }
00076 
00082     public function getConfig()
00083     {
00084         if ( defined( 'OXID_PHP_UNIT' ) ) {
00085             if ( isset( $this->unitCustModConf ) ) {
00086                 return $this->unitCustModConf;
00087             }
00088             return oxConfig::getInstance();
00089         }
00090 
00091         if ( self::$_oConfig == null ) {
00092             self::$_oConfig = oxConfig::getInstance();
00093         }
00094 
00095         return self::$_oConfig;
00096     }
00097 
00105     public function setConfig( $oConfig )
00106     {
00107         if ( defined( 'OXID_PHP_UNIT' ) ) {
00108             $this->unitCustModConf = $oConfig;
00109             return;
00110         }
00111 
00112         self::$_oConfig = $oConfig;
00113     }
00114 
00120     public function getSession()
00121     {
00122         if ( defined( 'OXID_PHP_UNIT' ) ) {
00123             if ( isset( $this->unitCustModSess ) ) {
00124                 return $this->unitCustModSess;
00125             }
00126             return oxSession::getInstance();
00127         }
00128 
00129         if ( self::$_oSession == null ) {
00130             self::$_oSession = oxSession::getInstance();
00131         }
00132 
00133         return self::$_oSession;
00134     }
00135 
00143     public function setSession( $oSession )
00144     {
00145         if ( defined( 'OXID_PHP_UNIT' ) ) {
00146             $this->unitCustModSess = $oSession;
00147             return;
00148         }
00149 
00150         self::$_oSession = $oSession;
00151     }
00152 
00158     public function getUser()
00159     {
00160         if ( defined( 'OXID_PHP_UNIT' ) ) {
00161             if ( isset( $this->unitCustModUser ) ) {
00162                 return $this->unitCustModUser;
00163             }
00164             $oUser = oxNew( 'oxuser' );
00165             if ( $oUser->loadActiveUser() ) {
00166                 return $oUser;
00167             }
00168             return false;
00169         }
00170 
00171         if ( self::$_oActUser === null ) {
00172             self::$_oActUser = false;
00173             $oUser = oxNew( 'oxuser' );
00174             if ( $oUser->loadActiveUser() ) {
00175                 self::$_oActUser = $oUser;
00176             }
00177         }
00178 
00179         return self::$_oActUser;
00180     }
00181 
00189     public function setUser( $oUser )
00190     {
00191         if ( defined( 'OXID_PHP_UNIT' ) ) {
00192             $this->unitCustModUser = $oUser;
00193             return;
00194         }
00195 
00196         self::$_oActUser = $oUser;
00197     }
00198 
00204     public function isAdmin()
00205     {
00206         if ( self::$_blIsAdmin === null ) {
00207             self::$_blIsAdmin = isAdmin();
00208         }
00209 
00210         return self::$_blIsAdmin;
00211     }
00212 
00220     public function setAdminMode( $blAdmin )
00221     {
00222         self::$_blIsAdmin = $blAdmin;
00223     }
00224 
00225 }