[Solved]Install dan implementasi ext. Right

agan2, ane newbie nih. mau tanya cara install rights gimana? udh baca dan coba2 tidak berhasil.

akhirnya coba digabungi dengan yii-user, tetap aja nggk bisa. errornya RWebUser tdk ada padahal sudah diimport di config.

ada yg bisa bantu?

trus implementasinya gimana?

sebelumnys thx.

coba liat confignya agan…biar kita check sama2

coba dicek gan,


<?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.user.models.*',

                'application.modules.user.components.*',

                'application.modules.rights.*',

                'application.modules.rights.components,*',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'silahkan',

		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

                'user',

                'rights'=>array(

                    'install'=>true,

                ),

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

                        'class'=>'RWebUser',

			'allowAutoLogin'=>true,

                        'loginUrl' => array('/user/login'),

		),

		// 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>',

			),

		),

                'authManager'=>array(

                        'class'=>'RDbAuthManager',

                ),


		/*

		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

		// uncomment the following to use a MySQL database

		*/

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=test',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		'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',

	),

);




<?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'=>'Product Management',

	'language'=>'id',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		'application.extensions.fpdf.*',

		'application.modules.rights.*',

		'application.modules.rights.components.*',

		

		//'application.modules.srbac.controllers.SBaseController',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'onetwo',

		),

		

		 'rights'=>array(

		'superuserName'=>'admin',

		 'authenticatedName'=>'Authenticated',

		'userClass'=>'Users',

		'userIdColumn'=>'id',

		'userNameColumn'=>'username',

		 'enableBizRule'=>true,

		 'enableBizRuleData'=>false,

		 'displayDescription'=>true,

		 'flashSuccessKey'=>'RightsSuccess',

		'flashErrorKey'=>'RightsError',

		'install'=>true,//mode install

		'baseUrl'=>'/rights',

		'layout'=>'rights.views.layouts.main',

		'appLayout'=>'application.views.layouts.main',

		 'cssFile'=>'rights.css',

		// 'install'=>false, kalo udah diinstal pake ini

		'debug'=>false,

		),


		

	),


	// application components

	'components'=>array(


	

	

	

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'class'=>'RWebUser',

		),

		// uncomment the following to enable URLs in path-format

		

		

		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=product_database',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		'authManager'=>array(

               'class'=>'RDbAuthManager',

                // The database component used

                'connectionID'=>'db',

                // The itemTable name (default:authitem)

                'itemTable'=>'pd_authitems',

                // The assignmentTable name (default:authassignment)

                'assignmentTable'=>'pd_assignments',

                // The itemChildTable name (default:authitemchild)

                'itemChildTable'=>'pd_authitemchildren',

				'rightsTable'=>'pd_authitemweight',

              ),

		

		'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',

				),

				*/

			),

		),

	),


	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'bob.hartanto@gmail.com',

	),

);




coba di cek config ane gan

muncul ini, gan!


There must be at least one superuser!

sekalian boleh ane lihat schema db ente gan?

Gan, klo cara instal Yii nya sendiri gimana ya ?

ane masih bingung nih ?

sebenernya paling gampang pelajari dari ext rights yang sekaligus demo blog

tablenyakan

pd_authitem

pd_authitemchild

pd_authassignment

pd_rights

kalo loginnya pake model User dari sample blog yang udah ke db gak sulit

kalo udah nanti tinggal disinkron kan dengan table user agan.

di pd_authassignment field userid dimasukan sesuai data id tbl_user

ex. 1 cek di pd_user ada id 1 kagak ?

nah kalo udah disesuaikan juga sama user loginnya




class RightsModule extends CWebModule

{

	public $superuserName = 'Admin';

	public $authenticatedName = 'Authenticated';

	public $userClass = 'User';

	public $userIdColumn = 'id';

	public $userNameColumn = 'username';

...



nih schema ane




Tabel Users


-id

-name

-department

-username

-password



perhatikan ini gan




                 'superuserName'=>'admin',

                 'authenticatedName'=>'Authenticated',

                'userClass'=>'Users',

                'userIdColumn'=>'id',

                'userNameColumn'=>'username',




saya rasa muncul error kayak gitu,mungkin si agan ga punya yang username nya ‘admin’

makanya coba di ganti bagian ‘superuserName’=>‘admin’,//ganti ke username adminnya agan

@tuna thx gan. ternyata mmg kesalahan db nya. installasinya Rights tanpa blog msh bermasalah. jadi stlh sy lihat cth db dr blognya baru ngerti. :)

@ressaince thx gan. atas bantu dan kesabarannya menjelaskan ke ane. :)

next step : implementasi… :)

mohon pencerahannya:

saya sudah seting main.php yang ada di config

seperti ini


<?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'=>'Masyar Syauqi System',

	'theme'=>'classic',

	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		'application.modules.rights.*',

		'application.modules.rights.components.*',

		'application.extensions.debugtoolbar.*',

	),

	'modules'=>array(

		// uncomment the following to enable the Gii tool

		'AjaxModule',

		'UiModule',

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'mashar123',

		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		'rights'=>array(

            	'superuserName'=>'admin',

             	'authenticatedName'=>'Authenticated',

            	'userClass'=>'Users',

            	'userIdColumn'=>'id',

            	'userNameColumn'=>'username',

             	'enableBizRule'=>true,

             	'enableBizRuleData'=>false,

             	'displayDescription'=>true,

             	'flashSuccessKey'=>'RightsSuccess',

            	'flashErrorKey'=>'RightsError',

            	'install'=>false,//mode install

            	'baseUrl'=>'/rights',

            	'layout'=>'rights.views.layouts.main',

            	'appLayout'=>'application.views.layouts.main',

             	'cssFile'=>'rights.css',

            	// 'install'=>false, kalo udah diinstal pake ini

            	'debug'=>false,

            	),

		

	),


	// application components untuk menampilkan data dari view selain di protected>views>... (protected>modules>)

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'class'=>'RWebUser',

		),

			'uiSettings'=>array(

			'class'=>'UiSettings',

		),

		'db'=>array(

			'autoConnect'=>false, // we will activate the connection from dbManager

			'connectionString' => '', // we set connectionString from dbManager

			'tablePrefix'=>'tbl_',

		),

		'sc'=>array(

			'class' => 'application.components.SrcCollect',

		),

		'dbManager'=>array(

			'class' => 'application.components.DbManager',

		),

		'lc'=>array(

			'class' => 'application.components.LocaleManager',

		),

		

		// uncomment the following to enable URLs in path-format

		//untuk seting tampilan dan variasi url

		/*

		'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(

			'connectionString' => 'mysql:host=localhost;dbname=yii',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),

		 'authManager'=>array(

        	'class'=>'RDbAuthManager',

        	'connectionID'=>'db',

        	'itemTable'=>'tbl_authitem',

			'itemChildTable'=>'tbl_authitemchild',

			'assignmentTable'=>'tbl_authassignment',

			'rightsTable'=>'tbl_rights',

    	),

		

		'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'=>'didit.tri.harsono@gmail.com',

	),

);

dan sudah membuat table nya di phpmyadminnya


create table tbl_authitem

(

   name varchar(64) not null,

   type integer not null,

   description text,

   bizrule text,

   data text,

   primary key (name)

);


create table tbl_authitemchild

(

   parent varchar(64) not null,

   child varchar(64) not null,

   primary key (parent,child),

   foreign key (parent) references tbl_authitem (name) on delete cascade on update cascade,

   foreign key (child) references tbl_authitem (name) on delete cascade on update cascade

);


create table tbl_authassignment

(

   itemname varchar(64) not null,

   userid varchar(64) not null,

   bizrule text,

   data text,

   primary key (itemname,userid),

   foreign key (itemname) references tbl_authitem (name) on delete cascade on update cascade

);


create table tbl_rights

(

	itemname varchar(64) not null,

	type integer not null,

	weight integer not null,

	primary key (itemname),

	foreign key (itemname) references tbl_authitem (name) on delete cascade on update cascade

);



sudah tidak eror lagi, cuma pas login pake admin.

menu rights nya tidak muncul,padahal saya sudah nambahin di views>layout>main.php


array('label'=>'Rights', 'url'=>array('/rights'), 'visible'=>Yii::app()->user->checkAccess(Rights::module()->superuserName)),

itu kenapa ya?