HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
RightsModule.php
Go to the documentation of this file.
1 <?php
23 class RightsModule extends CWebModule
24 {
28  public $superuserName = 'Admin';
32  public $authenticatedName = 'Authenticated';
36  public $userClass = 'User';
40  public $userIdColumn = 'id';
44  public $userNameColumn = 'username';
48  public $enableBizRule = true;
52  public $enableBizRuleData = false;
57  public $displayDescription = true;
61  public $flashSuccessKey = 'RightsSuccess';
65  public $flashErrorKey = 'RightsError';
69  public $install = false;
73  public $baseUrl = '/rights';
77  public $layout = 'rights.views.layouts.main';
81  public $appLayout = 'application.views.layouts.main';
85  public $cssFile;
89  public $debug = false;
90 
91  private $_assetsUrl;
92 
96  public function init()
97  {
98  // Set required classes for import.
99  $this->setImport(array(
100  'rights.components.*',
101  'rights.components.behaviors.*',
102  'rights.components.dataproviders.*',
103  'rights.controllers.*',
104  'rights.models.*',
105  ));
106 
107  // Set the required components.
108  $this->setComponents(array(
109  'authorizer' => array(
110  'class' => 'RAuthorizer',
111  'superuserName' => $this->superuserName,
112  ),
113  'generator' => array(
114  'class' => 'RGenerator',
115  ),
116  ));
117 
118  // Normally the default controller is Assignment.
119  $this->defaultController = 'assignment';
120 
121  // Set the installer if necessary.
122  if ($this->install === true) {
123  $this->setComponents(array(
124  'installer' => array(
125  'class' => 'RInstaller',
126  'superuserName' => $this->superuserName,
127  'authenticatedName' => $this->authenticatedName,
128  'guestName' => Yii::app()->user->guestName,
129  'defaultRoles' => Yii::app()->authManager->defaultRoles,
130  ),
131  ));
132 
133  // When installing we need to set the default controller to Install.
134  $this->defaultController = 'install';
135  }
136  }
137 
141  public function registerScripts()
142  {
143  // Get the url to the module assets
144  $assetsUrl = $this->getAssetsUrl();
145 
146  // Register the necessary scripts
147  $cs = Yii::app()->getClientScript();
148  $cs->registerCoreScript('jquery');
149  $cs->registerCoreScript('jquery.ui');
150  $cs->registerScriptFile($assetsUrl.'/js/rights.js');
151  $cs->registerCssFile($assetsUrl.'/css/core.css');
152 
153  // Make sure we want to register a style sheet.
154  if ($this->cssFile !== false) {
155  // Default style sheet is used unless one is provided.
156  if ($this->cssFile === null) {
157  $this->cssFile = $assetsUrl.'/css/default.css';
158  } else {
159  $this->cssFile = Yii::app()->request->baseUrl.$this->cssFile;
160  }
161 
162  // Register the style sheet
163  $cs->registerCssFile($this->cssFile);
164  }
165  }
166 
172  public function getAssetsUrl()
173  {
174  if ($this->_assetsUrl === null) {
175  $assetsPath = Yii::getPathOfAlias('rights.assets');
176 
177  // We need to republish the assets if debug mode is enabled.
178  if ($this->debug === true) {
179  $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath, false, -1, true);
180  } else {
181  $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath);
182  }
183  }
184 
185  return $this->_assetsUrl;
186  }
187 
191  public function getAuthorizer()
192  {
193  return $this->getComponent('authorizer');
194  }
195 
199  public function getInstaller()
200  {
201  return $this->getComponent('installer');
202  }
203 
207  public function getGenerator()
208  {
209  return $this->getComponent('generator');
210  }
211 
215  public function getVersion()
216  {
217  return '1.3.0';
218  }
219 }