OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxsupercfg.php
Go to the documentation of this file.
1 <?php
2 
6 class oxSuperCfg
7 {
13  protected static $_oConfig = null;
14 
20  protected static $_oSession = null;
21 
27  protected static $_oRights = null;
28 
34  protected static $_oActUser = null;
35 
41  protected static $_blIsAdmin = null;
42 
54  public function __call( $sMethod, $aArgs )
55  {
56  if ( defined( 'OXID_PHP_UNIT' ) ) {
57  if ( substr( $sMethod, 0, 4) == "UNIT" ) {
58  $sMethod = str_replace( "UNIT", "_", $sMethod );
59  }
60  if ( method_exists( $this, $sMethod)) {
61  return call_user_func_array( array( & $this, $sMethod ), $aArgs );
62  }
63  }
64 
65  throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
66  }
67 
73  public function __construct()
74  {
75  }
76 
82  public function getConfig()
83  {
84  if ( defined( 'OXID_PHP_UNIT' ) ) {
85  if ( isset( $this->unitCustModConf ) ) {
86  return $this->unitCustModConf;
87  }
88  return oxRegistry::getConfig();
89  }
90 
91  if ( self::$_oConfig == null ) {
92  self::$_oConfig = oxRegistry::getConfig();
93  }
94 
95  return self::$_oConfig;
96  }
97 
105  public function setConfig( $oConfig )
106  {
107  if ( defined( 'OXID_PHP_UNIT' ) ) {
108  $this->unitCustModConf = $oConfig;
109  return;
110  }
111 
112  self::$_oConfig = $oConfig;
113  }
114 
120  public function getSession()
121  {
122  if ( defined( 'OXID_PHP_UNIT' ) ) {
123  if ( isset( $this->unitCustModSess ) ) {
124  return $this->unitCustModSess;
125  }
126  return oxRegistry::getSession();
127  }
128 
129  if ( self::$_oSession == null ) {
130  self::$_oSession = oxRegistry::getSession();
131  }
132 
133  return self::$_oSession;
134  }
135 
143  public function setSession( $oSession )
144  {
145  if ( defined( 'OXID_PHP_UNIT' ) ) {
146  $this->unitCustModSess = $oSession;
147  return;
148  }
149 
150  self::$_oSession = $oSession;
151  }
152 
158  public function getUser()
159  {
160  if ( defined( 'OXID_PHP_UNIT' ) ) {
161  if ( isset( $this->unitCustModUser ) ) {
162  return $this->unitCustModUser;
163  }
164  $oUser = oxNew( 'oxuser' );
165  if ( $oUser->loadActiveUser() ) {
166  return $oUser;
167  }
168  return false;
169  }
170 
171  if ( self::$_oActUser === null ) {
172  self::$_oActUser = false;
173  $oUser = oxNew( 'oxuser' );
174  if ( $oUser->loadActiveUser() ) {
175  self::$_oActUser = $oUser;
176  }
177  }
178 
179  return self::$_oActUser;
180  }
181 
189  public function setUser( $oUser )
190  {
191  if ( defined( 'OXID_PHP_UNIT' ) ) {
192  $this->unitCustModUser = $oUser;
193  return;
194  }
195 
196  self::$_oActUser = $oUser;
197  }
198 
204  public function isAdmin()
205  {
206  if ( self::$_blIsAdmin === null ) {
207  self::$_blIsAdmin = isAdmin();
208  }
209 
210  return self::$_blIsAdmin;
211  }
212 
220  public function setAdminMode( $blAdmin )
221  {
222  self::$_blIsAdmin = $blAdmin;
223  }
224 
225 }