Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
FgModule.php
1 <?php
2 
3 class FgModule extends CWebModule
4 {
5  public $defaultController = 'admin';
6  public $assetsPath;
7  public $proxyPath;
8  public $clientBasePath;
9  public $clientLocalPath;
10  public $defaultLogin;
11  public $thankYouPage;
12 
13  public function init()
14  {
15  $this->setImport(array(
16  'fg.models.*',
17  'fg.components.*',
18  'fg.helpers.*',
19  ));
20 
21  $this->assetsPath = Yii::app()->assetManager->publish(dirname(__FILE__).'/assets', false, -1, YII_DEBUG);
22  }
23 
24  public function beforeControllerAction($controller, $action)
25  {
26  if(parent::beforeControllerAction($controller, $action))
27  {
28  $this->loginDummyUser();
29  return true;
30  }
31  else
32  return false;
33  }
34 
35  public function loginDummyUser()
36  {
37  $identity = new UserIdentity($this->defaultLogin['username'], $this->defaultLogin['password']);
38  if($identity->authenticate())
39  Yii::app()->user->login($identity, 0);
40  }
41 
42  public static function isUserAdmin()
43  {
44  return Yii::app()->user->getName() == 'admin';
45  }
46 
47  public static function getConfig()
48  {
49  $my = Yii::app()->getModules(false);
50  static $config;
51  if(!isset($config)) {
52  $config = $my['fg'];
53  }
54  return $config;
55  }
56 
57  public static function t($message, $category = 'main')
58  {
59  $category = 'FgModule.'.$category;
60  return Yii::t($category, $message);
61  }
62 }