本文整理汇总了PHP中CWebModule类的典型用法代码示例。如果您正苦于以下问题:PHP CWebModule类的具体用法?PHP CWebModule怎么用?PHP CWebModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CWebModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkModuleRights
public function checkModuleRights(CWebModule $module)
{
$items = $module->getAuthItems();
if (empty($items) || Yii::app()->getUser()->checkAccess(AuthItem::ROLE_ADMIN)) {
return true;
}
foreach ($items as $task) {
if (Yii::app()->getUser()->checkAccess($task['name'])) {
return true;
}
foreach ($task['items'] as $item) {
if (Yii::app()->getUser()->checkAccess($item['name'])) {
return true;
}
}
}
return false;
}
示例2: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (!Yum::hasModule('role')) {
throw new Exception('Using the membership submodule requires the role module activated');
}
return parent::beforeControllerAction($controller, $action);
}
示例3: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
$aDevController = array('oauth', 'default', 'client', 'session', 'test', 'site');
//not need to authenticate
$aPublicController = array('users', 'listings');
//two-legged
$this->oauth_init();
if (!in_array($controller->id, $aDevController)) {
// $oauth_version = $this->getParam('oauth_version');
// $msg = 'consumerkey'. $this->consumer_key;
// throw new CHttpException(401,$msg);
// exit();
if (in_array($controller->id, $aPublicController)) {
$this->authentication();
} else {
$this->authorization();
}
}
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else {
return false;
}
}
示例4: getControllerPath
public function getControllerPath($controller = null)
{
if ($controller != null) {
return parent::getControllerPath() . DS . ucfirst($controller) . '.php';
}
return parent::getControllerPath();
}
示例5: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
return parent::beforeControllerAction($controller, $action);
}
return false;
}
示例6: init
/**
* Module constructor - Builds the initial module data
*
*
* @author vadim
*
*/
public function init()
{
// If the langauge is set then set the application
// Language appropriatly
if (isset($_GET['lang']) && in_array($_GET['lang'], array_keys(Yii::app()->params['languages']))) {
Yii::app()->setLanguage($_GET['lang']);
}
// Convert application name
Yii::app()->name = Yii::app()->settings->applicationName != '' ? Yii::app()->settings->applicationName : Yii::app()->name;
// Other settings
if (count(Yii::app()->params)) {
foreach (Yii::app()->params as $key => $value) {
// Skip the ones that does not exists
if (!Yii::app()->settings->{$key}) {
continue;
}
// Add them anyways
Yii::app()->params[$key] = Yii::app()->settings->{$key} != '' ? Yii::app()->settings->{$key} : Yii::app()->params[$key];
}
}
// Convert settings into params
if (count(Yii::app()->settings->settings)) {
foreach (Yii::app()->settings->settings as $settingKey => $settingValue) {
Yii::app()->params[$settingKey] = $settingValue;
}
}
parent::init();
}
示例7: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
$roles = Rights::getAssignedRoles(Yii::app()->user->Id);
// check for single role
foreach ($roles as $role) {
if (sizeof($roles) == 1 and $role->name == 'parent') {
$controller->layout = 'none';
}
if (sizeof($roles) == 1 and $role->name == 'student') {
$controller->layout = 'studentmain';
}
}
if (Yii::app()->user->isGuest) {
if (Yii::app()->user->loginUrl) {
$controller->redirect($controller->createUrl(reset(Yii::app()->user->loginUrl)));
} else {
$controller->redirect($controller->createUrl('/'));
}
} else {
if (parent::beforeControllerAction($controller, $action)) {
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else {
return false;
}
}
}
示例8: beforeControllerAction
/**
* The pre-filter for controller actions.
*
* @param CController $controller the controller
* @param CAction $action the action
* @return boolean whether the action should be executed.
*/
public function beforeControllerAction($controller, $action)
{
if (Yii::app()->user->isGuest) {
Yii::app()->user->loginRequired();
}
return parent::beforeControllerAction($controller, $action);
}
示例9: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
$array = array('default', 'client');
Yii::app()->params['api_request'] = true;
//This is to indicate to some models its an api request(ie:a captcha not to be used in subject add form since is an api request)
$arr_controllers = array('v1/live', 'v1/subject');
$arr_action = array('sendcomment', 'add');
//print_r($action);
if (in_array($controller->id, $arr_controllers) and in_array($action->id, $arr_action) and $_REQUEST['anonymously'] != '1') {
$this->oauth_init();
$oauth_version = $this->getParam('oauth_version');
//oauth 不需要验证
if ($controller->id != 'oauth') {
$this->authorization();
}
} else {
}
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else {
return false;
}
}
示例10: __call
public function __call($name, $parameters)
{
// magic for create
if (preg_match('/^create(.+)$/', $name)) {
return $this->_instantiateByConfig($name, $parameters);
}
return parent::__call($name, $parameters);
}
示例11: init
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
// import the module-level models and components
$this->setImport(array('integration.models.*', 'integration.components.*', 'integration.controllers.*'));
parent::init();
}
示例12: init
public function init()
{
parent::init();
$this->setImport(array('admin.components.*', 'admin.models.*'));
Yii::app()->setComponents(array('errorHandler' => array('class' => 'CErrorHandler', 'errorAction' => 'admin/site/error'), 'user' => array('allowAutoLogin' => false, 'class' => 'BWebUser')));
//$base_dir = $this->getBasePath();
//$layoutPath = $base_dir.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'layouts';
//$this->setLayoutPath($layoutPath);
}
示例13: init
/**
* Module constructor - Builds the initial module data
*
*
* @author vadim
*
*/
public function init()
{
// If the langauge is set then set the application
// Language appropriatly
if (isset($_GET['lang']) && in_array($_GET['lang'], array_keys(Yii::app()->params['languages']))) {
Yii::app()->setLanguage($_GET['lang']);
}
parent::init();
}
示例14: init
public function init()
{
parent::init();
// $this->setImport(array(
// 'application.models.*',
// 'auth.models.*',
// 'auth.components.*',
// ));
}
示例15: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
$controller->layout = 'fronlay';
return true;
} else {
return false;
}
}