HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
InstallController.php
Go to the documentation of this file.
1 <?php
11 {
15  private $_authorizer;
19  private $_installer;
20 
24  public function init()
25  {
26  if ($this->module->install !== true) {
27  $this->redirect(Yii::app()->homeUrl);
28  }
29 
30  $this->_authorizer = $this->module->getAuthorizer();
31  $this->_installer = $this->module->getInstaller();
32  $this->layout = $this->module->layout;
33  $this->defaultAction = 'run';
34 
35  // Register the scripts.
36  $this->module->registerScripts();
37  }
38 
42  public function filters()
43  {
44  // Use access control when installed.
45  return $this->_installer->installed === true ? array('accessControl') : array();
46  }
47 
54  public function accessRules()
55  {
56  return array(
57  array('allow', // Allow superusers to access Rights
58  'actions' => array(
59  'confirm',
60  'run',
61  'error',
62  'ready',
63  ),
64  'users' => $this->_authorizer->getSuperusers(),
65  ),
66  array('deny', // Deny all users
67  'users' => array('*'),
68  ),
69  );
70  }
71 
75  public function actionConfirm()
76  {
77  $this->render('confirm');
78  }
79 
85  public function actionRun()
86  {
87  // Make sure the user is not a guest.
88  if (Yii::app()->user->isGuest === false) {
89  // Make sure that the module is not already installed.
90  if (isset($_GET['confirm']) === true || $this->_installer->installed === false) {
91  // Run the installer and check for an error.
92  if ($this->_installer->run() === RInstaller::ERROR_NONE) {
93  // Mark the user to have superuser privileges.
94  Yii::app()->user->isSuperuser = true;
95  $this->redirect(array('install/ready'));
96  }
97 
98  // Redirect to the error page.
99  $this->redirect(array('install/error'));
100  }
101  // Module is already installed.
102  else {
103  $this->redirect(array('install/confirm'));
104  }
105  }
106  // User is guest, deny access.
107  else {
108  $this->accessDenied(Rights::t('install', 'You must be logged in to install Rights.'));
109  }
110  }
111 
115  public function actionReady()
116  {
117  $this->render('ready');
118  }
119 
123  public function actionError()
124  {
125  $this->render('error');
126  }
127 }