[module] userGroups

hi nick!! thank you so much for this module… i 've used it in many of my pprojects… just one issue with htaccess file…

i ve put file on the server. and my link is this: http://174.120.148.251/~metprogo/metpro. this gives me 404 error. m guessing its because of the htaccess file. if i change the link to http:/174.120.148.251/~metprogo/index.php/metpro it works.

heres the .htaccess file…


Options +FollowSymLinks


IndexIgnore */*


RewriteEngine on





# if a directory or a file exists, use it directly


RewriteCond %{REQUEST_FILENAME} !-f


RewriteCond %{REQUEST_FILENAME} !-d





# otherwise forward it to index.php


RewriteRule . index.php



please suggest what changes to make for it to work without index.php

I was trying to set up this module in Windows 7 + WAMP, but I got a 404 error.

I was reading this topic and moving things I got the module working.

I’m attaching a zip file including all the files. One should check the .htaccess and the main.php, I consider those files the most importants in order to configure this module.

Regards,

Diego


.htaccess




Options +FollowSymLinks

IndexIgnore */*

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteBase /moneylog/


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>




protected/config/main.php




<?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'=>'YOUR APP NAME',


	// preloading 'log' component

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


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		'application.modules.userGroups.models.*',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool		

		'gii'=>array(

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

			'password'=>'YOURPASS',

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

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

		),

		'userGroups'=>array(

			'accessCode'=>'YOURCODE',

			),


		

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

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

			),

			'showScriptName'=>false,

			


		),

		'db'=>array(

			'class'=>'CDbConnection',

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

			'emulatePrepare' => true,

			'username' => 'YOURUSER',

			'password' => 'YOURPASS',

			'charset' => 'utf8',

			'tablePrefix' => 'YOURPREFIX',

			'enableProfiling'=>'true'	

		),		

		'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'=>'diego@diegotoala.com',

	),

);



Hi! Great extention=) I’m trying to get the profile extention to work.

I downloaded the userExtentions sample (for some reason my xp computer wanted to make one single .txt of all the files) but I created

app/protected/models/Profile.php

app/protected/controllers/ProfileController.php and

And copied your sample code into those files.

Also Created

app/proteted/views/Profile/index.php (empty file)

Then I created tbl_profile in my database, tbl_ is set as table prefix in my main config file.

I get the following error when I try to browse to any view within the userGroups module:

include(ProfileController.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory

If I change the name of protected/controllers/ProfilController.php to anything.php I get

include(anything.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory

I’ve been trying to solve this for a couple of days but failed:/

I read the documentation but I did not understand how to do business rules with userGroups (maybe due to my English skills or else)…

some example

if the user owns only his post on a forum and is allowed to edit ONLY his post:

http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#defining-authorization-hierarchy


$bizRule='return Yii::app()->user->id==$params["post"]->authID;';

$task=$auth->createTask('updateOwnPost','update a post by author himself',$bizRule);

How do i set that rule with userGroups module? So when I check access for example it returns true/false that the user can edit the post and allows/denies him to access the Update action?

Hi

I know how to get from the sql a list of emails from the users in a group. But I didnt find a way to do this with the class. is there something I m not seeng or it really is not in the extension?

Any idea how I can use one form to register two types of users with different inputs?

There would be a dropdown list or some radio buttons to select which group the user wants to belong to and depending on the choice new profile inputs should become visible (and the old ones should disappear). The current profile extension isn’t capable of doing that right? Also to me it seems only one profile extension can work at one time.

hello and sorry for my bad english…

i`m novice in yii, but start using userGroups module and would suggest some improvements(maybe of course):

  • it would be convenient, if the path to the all controllers of application in UserGroupsAccess.php was isolated in the modules config.. or it can understand the CBehaviors(for example frontend or bakend).. so people dont need to edit in controllerList function path to controllers… in my case it look "application.controllers.backend" because i generate my controllers in this uri /localhost/projectName/backent/gii/ from backend behavior…

  • maybe it will be good, if rules would be isolated too… for example rule "view" or smth can be added to "admin", "read", "write" in config file…

anyway it`s great ext… thank you…

I hope you can understand what I wrote… )

Ok, so I’m new to MVC Frameworks, new to Yii and (you guessed) new to UserGroups.

First, I’ve gone through the UserGroups documentation and I can’t seem to find a way to add custom permissions. When you go in the Root tools interface, you can set Read/Write/Admin rights for users/groups… I would like to be able to add a permission so I could set Read/Write/Custom/Admin or something like that. Is it possible? If not I think it would be a nice feature to add.

Also, I tried adding a profile extension… When I log on my user and try to save the modifications to the new section of my profile I keep getting the following message (saving the other parts of the profile works fine):

Error 403

You are not authorized to perform this action.

I followed the instructions in the documentation… is there something else I should know that might be the source of the problem?

The file permissions seem to be ok… unless it needs writing rights somewhere that I’m not aware of… I already gave write permissions to the apache user for the whole userGroups module folder.

How does the settings that I make for a specific controller (i.e. "TestController") in "Root Tools" take effect?

The restrictions for a group doesn’t work. Everybody can perform “write” action in the TestController.

Thanks

Does anyone have the extension available for download? The dl from the extension page keeps saying its corrupt.

Edit: Nevermind, it was WinRAR’s fault. Yay for 7zip!

I have installed userGroup extension with fresh project, but once I have loged in as admin I got this exception "UserIdentity and its behaviour do not have method or closure named getGroup"

/var/www/YiiRoot/framework/base/CComponent.php(266)

254 public function __call($name,$parameters)

255 {

256 if($this->_m!==null)

257 {

258 foreach($this->_m as $object)

259 {

260 if($object->getEnabled() && method_exists($object,$name))

261 return call_user_func_array(array($object,$name),$parameters);

262 }

263 }

264 if(class_exists(‘Closure’, false) && $this->canGetProperty($name) && $this->$name instanceof Closure)

265 return call_user_func_array($this->$name, $parameters);

266 throw new CException(Yii::t(‘yii’,’{class} and its behaviors do not have a method or closure named “{name}”.’,

267 array(’{class}’=>get_class($this), ‘{name}’=>$name)));

268 }

->it shows exception at line no:266

I have a custom controller and when I try to create a new user or a new group I get the following error:




[Wed Jun 20 12:34:15 2012] [error] [client 127.0.0.1] PHP Fatal error:  Cannot redeclare class YWebServiceController in /home/maxxer/work/www/management_site/protected/controllers/YwebserviceController.php on line 99, referer: http://localhost/work/www/management_site/userGroups/admin/documentation



any way to fix?

Line 99 is the closing of YWebServiceController class…

hi,

i m using userGroups for the first time. i wana know if it is possible to assign group to user at run time?

i mean in my system i m loading user from third party service and then assign roles/groups to them. is it possible with userGroups?

EOAuthUserIdentity and its behaviors do not have a method or closure named "getGroup".

Above error when i am trying to authenticate user with extension eoauth…

Any help will be greatly appreciated…

I have been using Yii and UserGroups to replace a manual club member registration with something a bit more modern. It is all working quite well and almost ready to launch.

I have a spreadsheet of current users that I would like to import. The data matches the models that I’ve created with Yii, including data in a userGroups profile extension.

Is there a convenient way of importing this data to create new users with userGroups?

I have figured out the minimum form to post to create new accounts that I copied from the "add user" form in the admin (POSTING to /members/userGroups/admin which seems to ignore input of profile extension data). I could write something to POST each new user, and then another script to update the profile extension data for each user, but I was hoping for something a bit easier that I missed.

I doubt there is anything built in (or I am complete idiot) to import the data from a csv or something, but it would be cool if someone could point me in the right direction for a good way to create such a script. What are the internal classes that I need to use to write my own controller that could handle this?

Thanks for any help.

EDIT: I took care of this by making an Admin controller in my Module that exposed actions with views for uploading and parsing the CSV files.

sorry but i have a question:

if i have a generic user "user" different by Yii::app()->user, there is a method to interrogate pbac?

for example:

user->pbac ??

tnx

Thanks for the great extension!

Only question is about setting default rights for ALL controllers (I’m a bit nuts of security, and usually use “default deny” rules (in iptables, squid and so on (lol) )) and allow only needed things in each one.

So I want to DENY access to all but site controller (to get access to site at all?) by default, and force users to login on any action ("disable" guests).

Could not find anything in documentation.

Where can I found default rules?

Thanks and awaiting for your answer.

PS sorry for my English.

PPS. While some experiments there was born another question. Is it possible to set returnURL to redirect after login back to page which I was trying to access? Right now I’m always redirected to userGroups/admin/documentation (if I’m root admin), or to home path set for ordinary user/group.

Quick permission question about account activations and password reset.

I have users complaining about 403 errors they get when trying to activate their new accounts and I believe I have reproduced the problem.

If you click on the activation link (or password reset) from the email that is sent, close the window, and click on the link again, you get a 403 permission denied showing the logged in user as "Recovery Mode".

Can someone point me in the direction of the specific permission changes needed to allow recovery mode partial login to still access the activation link without error?

EDIT:

I found a change that seems to work in UserController.php. Is this safe? Can anyone see a security issue with allowing recovery users to be able to activate accounts?


array('allow',  // actions users can access while in recovery mode

	'actions'=>array('recovery','logout',


'activate','passRequest'  // Added these


	),

	'users'=>array('#'),

),



after installing usergroups, i cant access Gii… it’s always bounce back to the homepage

nevermind… just solved it… hahahaha… thanks anyway