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 getConfig()
00074 {
00075 if ( defined( 'OXID_PHP_UNIT' ) ) {
00076 if ( isset( $this->unitCustMOD ) ) {
00077 return $this->unitCustMOD;
00078 }
00079 return oxConfig::getInstance();
00080 }
00081
00082 if ( self::$_oConfig == null ) {
00083 self::$_oConfig = oxConfig::getInstance();
00084 }
00085
00086 return self::$_oConfig;
00087 }
00088
00096 public function setConfig( $oConfig )
00097 {
00098 if ( defined( 'OXID_PHP_UNIT' ) ) {
00099 $this->unitCustMOD = $oConfig;
00100 return;
00101 }
00102
00103 self::$_oConfig = $oConfig;
00104 }
00105
00111 public function getSession()
00112 {
00113 if ( defined( 'OXID_PHP_UNIT' ) ) {
00114 if ( isset( $this->unitCustMOD ) ) {
00115 return $this->unitCustMOD;
00116 }
00117 return oxSession::getInstance();
00118 }
00119
00120 if ( self::$_oSession == null ) {
00121 self::$_oSession = oxSession::getInstance();
00122 }
00123
00124 return self::$_oSession;
00125 }
00126
00134 public function setSession( $oSession )
00135 {
00136 if ( defined( 'OXID_PHP_UNIT' ) ) {
00137 $this->unitCustMOD = $oSession;
00138 return;
00139 }
00140
00141 self::$_oSession = $oSession;
00142 }
00143
00149 public function getUser()
00150 {
00151 if ( defined( 'OXID_PHP_UNIT' ) ) {
00152 if ( isset( $this->unitCustModUser ) ) {
00153 return $this->unitCustModUser;
00154 }
00155 $oUser = oxNew( 'oxuser' );
00156 if ( $oUser->loadActiveUser() ) {
00157 return $oUser;
00158 }
00159 return false;
00160 }
00161
00162 if ( self::$_oActUser == null ) {
00163 $oUser = oxNew( 'oxuser' );
00164 if ( $oUser->loadActiveUser() ) {
00165 self::$_oActUser = $oUser;
00166 }
00167 }
00168
00169 return self::$_oActUser;
00170 }
00171
00179 public function setUser( $oUser )
00180 {
00181 if ( defined( 'OXID_PHP_UNIT' ) ) {
00182 $this->unitCustModUser = $oUser;
00183 return;
00184 }
00185
00186 self::$_oActUser = $oUser;
00187 }
00188
00194 public function isAdmin()
00195 {
00196 if ( self::$_blIsAdmin === null ) {
00197 self::$_blIsAdmin = isAdmin();
00198 }
00199
00200 return self::$_blIsAdmin;
00201 }
00202
00210 public function setAdminMode( $blAdmin )
00211 {
00212 self::$_blIsAdmin = $blAdmin;
00213 }
00214
00215 }