Hi,
Thanks for the code!
I’m a Yii newbie and downloaded the srbac version 1.1.1 and have been trying to run it but got some issues.
Since i’m new to yii i’m probably missing some steps or making some config errors somewhere.
It probably is something glaring obvious that i’ve missed or haven’t done.
If anyone could help me to get this up and running i’d be really greateful.
Many thanks.
Bartes
Here’s what I’ve done so far:
updated the config/main.php following the instructions on the install guide pdf.
create the following tables on the database:
tbl_user
AuthAssginment
AuthItem
AuthItemChild
Then updated my config file as follows:
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias(‘local’,‘path/to/local-folder’);
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.srbac.controllers.SBaseController',
),
/*
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
),
),
*/
'modules' => array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'admin',
),
'srbac' => array(
'userclass'=>'User', //default: User
'userid'=>'user_ID', //default: userid
'username'=>'username', //default:username
'debug'=>true, //default :false
'pageSize'=>10, // default : 15
'superUser' =>'Authority', //default: Authorizer
'css'=>'srbac.css', //default: srbac.css
'layout'=>
'application.views.layouts.main', //default: application.views.layouts.main,
//must be an existing alias
'notAuthorizedView'=> 'srbac.views.authitem.unauthorized', // default:
//srbac.views.authitem.unauthorized, must be an existing alias
'alwaysAllowed'=>array( //default: array()
'SiteLogin','SiteLogout','SiteIndex','SiteAdmin',
'SiteError', 'SiteContact'),
'userActions'=>array('Show','View','List'), //default: array()
'listBoxNumberOfLines' => 15, //default : 10
'imagesPath' => 'srbac.images', // default: srbac.images
'imagesPack'=>'noia', //default: noia
'iconText'=>true, // default : false
'header'=>'srbac.views.authitem.header', //default : srbac.views.authitem.header,
//must be an existing alias
'footer'=>'srbac.views.authitem.footer', //default: srbac.views.authitem.footer,
//must be an existing alias
'showHeader'=>true, // default: false
'showFooter'=>true, // default: false
'alwaysAllowedPath'=>'srbac.components', // default: srbac.components
// must be an existing alias
)
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl' => array('/user/user/login'),
),
'authManager'=>array(
// Path to SDbAuthManager in srbac module if you want to use case insensitive
//access checking (or CDbAuthManager for case sensitive access checking)
'class'=>'modules.srbac.components.SDbAuthManager',
// The database component used
'connectionID'=>'db',
// The itemTable name (default:authitem)
//'itemTable'=>'items',
'itemTable'=>'AuthItem',
// The assignmentTable name (default:authassignment)
//'assignmentTable'=>'assignments',
'assignmentTable'=>'AuthAssignment',
// The itemChildTable name (default:authitemchild)
//'itemChildTable'=>'itemchildren',
'itemChildTable'=>'AuthItemChild',
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=testdrive',
'username'=>'root',
'password'=>'root',
'tablePrefix' => 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);
Then when i go to http://localhost/testdrive/index.php?r=srbac/authitem/frontpage I get the following error message:
CException
Description
Alias "modules.srbac.components.SDbAuthManager" is invalid. Make sure it points to an existing directory or file.
Source File
/Applications/MAMP/htdocs/testdrive/protected/modules/srbac/SrbacModule.php(242)
00230: public function getShowFooter() {
00231: return $this->_showFooter;
00232: }
00233:
00234:
00235:
00236: /**
00237: * Checks if srbac is installed by checking if Auth items table exists.
00238: * @return boolean Whether srbac is installed or not
00239: */
00240: public function isInstalled() {
00241: try {
00242: $tables = Yii::app()->authManager->db->schema->tableNames;
00243: $itemTableName = Yii::app()->authManager->itemTable;
00244: $itemChildTableName = Yii::app()->authManager->itemChildTable ;
00245: $assignmentTableName = Yii::app()->authManager->assignmentTable ;
00246: $tablePrefix = AuthItem::model()->getDbConnection()->tablePrefix;
00247: if(!is_null($tablePrefix)) {
00248: $itemTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$itemTableName);
00249: $itemChildTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$itemChildTableName);
00250: $assignmentTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$assignmentTableName);
00251: }
00252: if(in_array($itemTableName, $tables) &&
00253: in_array($itemChildTableName, $tables) &&
00254: in_array($assignmentTableName, $tables)) {
Stack Trace
#0 /Applications/MAMP/htdocs/yii/framework/YiiBase.php(184): YiiBase::import(‘modules.srbac.c…’, true)
#1 /Applications/MAMP/htdocs/yii/framework/base/CModule.php(362): YiiBase::createComponent(Array)
#2 /Applications/MAMP/htdocs/yii/framework/base/CModule.php(86): CModule->getComponent(‘authManager’)
#3 /Applications/MAMP/htdocs/testdrive/protected/modules/srbac/SrbacModule.php(242): CModule->__get(‘authManager’)
#4 /Applications/MAMP/htdocs/testdrive/protected/modules/srbac/controllers/AuthitemController.php(42): SrbacModule->isInstalled()
#5 /Applications/MAMP/htdocs/yii/framework/web/CController.php(298): AuthitemController->beforeAction(Object(CInlineAction))
#6 /Applications/MAMP/htdocs/yii/framework/web/CController.php(278): CController->runAction(Object(CInlineAction))
#7 /Applications/MAMP/htdocs/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#8 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(324): CController->run(‘frontpage’)
#9 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(121): CWebApplication->runController(‘srbac/authitem/…’)
#10 /Applications/MAMP/htdocs/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#11 /Applications/MAMP/htdocs/testdrive/index.php(13): CApplication->run()
#12 {main}