oxsupercfg.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxSuperCfg
00007 {
00008 
00014     protected static $_oConfig = null;
00015 
00021     protected static $_oSession = null;
00022 
00028     protected static $_oRights = null;
00029 
00035     protected static $_oActUser = null;
00036 
00042     protected static $_blIsAdmin = null;
00043 
00055     public function __call($sMethod, $aArgs)
00056     {
00057         if (defined('OXID_PHP_UNIT')) {
00058             if (substr($sMethod, 0, 4) == "UNIT") {
00059                 $sMethod = str_replace("UNIT", "_", $sMethod);
00060             }
00061             if (method_exists($this, $sMethod)) {
00062                 return call_user_func_array(array(& $this, $sMethod), $aArgs);
00063             }
00064         }
00065 
00066         throw new oxSystemComponentException("Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")" . PHP_EOL);
00067     }
00068 
00074     public function __construct()
00075     {
00076     }
00077 
00083     public function getConfig()
00084     {
00085         if (defined('OXID_PHP_UNIT')) {
00086             if (isset($this->unitCustModConf)) {
00087                 return $this->unitCustModConf;
00088             }
00089 
00090             return oxRegistry::getConfig();
00091         }
00092 
00093         if (self::$_oConfig == null) {
00094             self::$_oConfig = oxRegistry::getConfig();
00095         }
00096 
00097         return self::$_oConfig;
00098     }
00099 
00107     public function setConfig($oConfig)
00108     {
00109         if (defined('OXID_PHP_UNIT')) {
00110             $this->unitCustModConf = $oConfig;
00111 
00112             return;
00113         }
00114 
00115         self::$_oConfig = $oConfig;
00116     }
00117 
00123     public function getSession()
00124     {
00125         if (defined('OXID_PHP_UNIT')) {
00126             if (isset($this->unitCustModSess)) {
00127                 return $this->unitCustModSess;
00128             }
00129 
00130             return oxRegistry::getSession();
00131         }
00132 
00133         if (self::$_oSession == null) {
00134             self::$_oSession = oxRegistry::getSession();
00135         }
00136 
00137         return self::$_oSession;
00138     }
00139 
00147     public function setSession($oSession)
00148     {
00149         if (defined('OXID_PHP_UNIT')) {
00150             $this->unitCustModSess = $oSession;
00151 
00152             return;
00153         }
00154 
00155         self::$_oSession = $oSession;
00156     }
00157 
00163     public function getUser()
00164     {
00165         if (defined('OXID_PHP_UNIT')) {
00166             if (isset($this->unitCustModUser)) {
00167                 return $this->unitCustModUser;
00168             }
00169             $oUser = oxNew('oxuser');
00170             if ($oUser->loadActiveUser()) {
00171                 return $oUser;
00172             }
00173 
00174             return false;
00175         }
00176 
00177         if (self::$_oActUser === null) {
00178             self::$_oActUser = false;
00179             $oUser = oxNew('oxuser');
00180             if ($oUser->loadActiveUser()) {
00181                 self::$_oActUser = $oUser;
00182             }
00183         }
00184 
00185         return self::$_oActUser;
00186     }
00187 
00195     public function setUser($oUser)
00196     {
00197         if (defined('OXID_PHP_UNIT')) {
00198             $this->unitCustModUser = $oUser;
00199 
00200             return;
00201         }
00202 
00203         self::$_oActUser = $oUser;
00204     }
00205 
00211     public function isAdmin()
00212     {
00213         if (self::$_blIsAdmin === null) {
00214             self::$_blIsAdmin = isAdmin();
00215         }
00216 
00217         return self::$_blIsAdmin;
00218     }
00219 
00225     public function setAdminMode($blAdmin)
00226     {
00227         self::$_blIsAdmin = $blAdmin;
00228     }
00229 
00230 }