-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathUserGroupsModule.php
executable file
·80 lines (76 loc) · 2.78 KB
/
UserGroupsModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* This Module is for Users and Groups management
* For more info check the documentation inside the module.
* You can access documentation just when the module is installed.
* if you want to check the documentation before installing the module
* go to the module page on Yii website
* @author Nicola Puddu
* @package userGroups
*/
class UserGroupsModule extends CWebModule
{
/**
* access code for authentication during installation
* @var string
*/
public $accessCode;
/**
* additional salt to use for cripting the user password
* @var string
*/
public $salt;
/**
* additional cronjobs to run
* every value in this array must be the class name of an
* implementation of UGCronJob
* @var array
*/
public $crons = array();
/**
* additional profile models
* every value in this array must be a CActiveRecord
* class name.
* @var array
*/
public $profile = array();
/**
* specify the classes containing the mail messages
* @var array
*/
public $mailMessages = array();
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
$this->defaultController = 'UGDefault';
// import the module-level models and components
$this->setImport(array(
'userGroups.models.*',
'userGroups.components.*',
));
// register the css and js files
Yii::app()->clientScript->registerCoreScript('jquery');
// load css and js if the page wasn't loaded with ajax
if (!Yii::app()->request->isAjaxRequest) {
Yii::app()->clientScript->registerCssFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('userGroups') . '/css').'/userGroups.css');
Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('userGroups') . '/js/userGroups.js'));
}
}
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
// check if the module is installed and make the right redirections
if (!in_array(Yii::app()->db->tablePrefix.'usergroups_configuration', Yii::app()->db->getSchema()->getTableNames()) && strpos(Yii::app()->request->pathInfo, 'userGroups/install') === false)
Yii::app()->request->redirect(Yii::app()->baseUrl . '/userGroups/install');
if (in_array(Yii::app()->db->tablePrefix.'usergroups_configuration', Yii::app()->db->getSchema()->getTableNames()) && strpos(Yii::app()->request->pathInfo, 'userGroups/install') !== false)
Yii::app()->request->redirect(Yii::app()->baseUrl . '/userGroups/');
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}
}